mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #512, GUI improvements
* menu widget to correct margin * optimized stylesheet by adding dynamic properties for CDockWidget widgets (allows better qss selection)
This commit is contained in:
@@ -308,12 +308,6 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle COM 1 standby/active</string>
|
||||
</property>
|
||||
@@ -368,12 +362,6 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle COM 2 standby/active</string>
|
||||
</property>
|
||||
|
||||
75
src/blackgui/components/marginsinput.cpp
Normal file
75
src/blackgui/components/marginsinput.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "marginsinput.h"
|
||||
#include "ui_marginsinput.h"
|
||||
#include <QIntValidator>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CMarginsInput::CMarginsInput(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CMarginsInput)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &CMarginsInput::ps_Confirmed);
|
||||
connect(ui->le_Bottom, &QLineEdit::returnPressed, this, &CMarginsInput::ps_Confirmed);
|
||||
connect(ui->le_Left, &QLineEdit::returnPressed, this, &CMarginsInput::ps_Confirmed);
|
||||
connect(ui->le_Right, &QLineEdit::returnPressed, this, &CMarginsInput::ps_Confirmed);
|
||||
connect(ui->le_Top, &QLineEdit::returnPressed, this, &CMarginsInput::ps_Confirmed);
|
||||
|
||||
QIntValidator *v = new QIntValidator(0, 100, this);
|
||||
ui->le_Bottom->setValidator(v);
|
||||
ui->le_Left->setValidator(v);
|
||||
ui->le_Right->setValidator(v);
|
||||
ui->le_Top->setValidator(v);
|
||||
this->setMargins(QMargins());
|
||||
}
|
||||
|
||||
CMarginsInput::~CMarginsInput()
|
||||
{ }
|
||||
|
||||
void CMarginsInput::setMargins(const QMargins &margins)
|
||||
{
|
||||
ui->le_Left->setText(QString::number(margins.left()));
|
||||
ui->le_Right->setText(QString::number(margins.right()));
|
||||
ui->le_Top->setText(QString::number(margins.top()));
|
||||
ui->le_Bottom->setText(QString::number(margins.bottom()));
|
||||
}
|
||||
|
||||
QMargins CMarginsInput::getMargins() const
|
||||
{
|
||||
int t = 0, b = 0, l = 0, r = 0;
|
||||
const QString sl(ui->le_Left->text().trimmed());
|
||||
const QString st(ui->le_Top->text().trimmed());
|
||||
const QString sr(ui->le_Right->text().trimmed());
|
||||
const QString sb(ui->le_Bottom->text().trimmed());
|
||||
bool ok = false;
|
||||
l = sl.toInt(&ok);
|
||||
l = ok ? l : 0;
|
||||
r = sr.toInt(&ok);
|
||||
r = ok ? r : 0;
|
||||
b = sb.toInt(&ok);
|
||||
b = ok ? b : 0;
|
||||
t = st.toInt(&ok);
|
||||
t = ok ? t : 0;
|
||||
const QMargins m(l, t, r, b);
|
||||
return m;
|
||||
}
|
||||
|
||||
void CMarginsInput::ps_Confirmed()
|
||||
{
|
||||
const QMargins m(this->getMargins());
|
||||
emit this->changedMargins(m);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
59
src/blackgui/components/marginsinput.h
Normal file
59
src/blackgui/components/marginsinput.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_MARGINSINPUT_H
|
||||
#define BLACKGUI_COMPONENTS_MARGINSINPUT_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QMargins>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CMarginsInput; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/*!
|
||||
* Widget alows to enter margins
|
||||
*/
|
||||
class CMarginsInput : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CMarginsInput(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CMarginsInput();
|
||||
|
||||
//! Set margins
|
||||
void setMargins(const QMargins &margins);
|
||||
|
||||
//! Current values of margins
|
||||
QMargins getMargins() const;
|
||||
|
||||
signals:
|
||||
//! Margins changed
|
||||
void changedMargins(const QMargins &margins);
|
||||
|
||||
private slots:
|
||||
//! Ok
|
||||
void ps_Confirmed();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CMarginsInput> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
99
src/blackgui/components/marginsinput.ui
Normal file
99
src/blackgui/components/marginsinput.ui
Normal file
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CMarginsInput</class>
|
||||
<widget class="QFrame" name="CMarginsInput">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>285</width>
|
||||
<height>82</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Margins input</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_MarginsInput">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_Bottom">
|
||||
<property name="maxLength">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>bottom</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pb_Ok">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_Top">
|
||||
<property name="maxLength">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>top</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="le_Right">
|
||||
<property name="placeholderText">
|
||||
<string>right</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="le_Left">
|
||||
<property name="placeholderText">
|
||||
<string>left</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user