Beispiel #1
0
CSpinBox::CSpinBox(QWidget* parent)
    : QAbstractSpinBox(parent), min_value(-100), max_value(100), value(0), base(10), num_digits(0) {
    // TODO: Might be nice to not immediately call the slot.
    //       Think of an address that is being replaced by a different one, in which case a lot
    //       invalid intermediate addresses would be read from during editing.
    connect(lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(OnEditingFinished()));

    UpdateText();
}
Beispiel #2
0
NBW_SpinBoxControls::NBW_SpinBoxControls(QWidget* parent)
    : QFrame(parent)
    , _text("value: ")
    , _rval(0)
    , _singleStep(1)
    , _min(0)
    , _max(100)
    , _typeMask(NBW_SpinBox::TypeFlags::ALL)
    , _state(STATE_NORMAL)
{
    setObjectName("nbw_spinBox_controls");
    setProperty("dragging", false);
    setMouseTracking(true);

    _lineEdit = new QLineEdit(this);
    _lineEdit->setObjectName("nbw_spinBox_lineEdit");
    _lineEdit->setAlignment(Qt::AlignCenter);
    _lineEdit->hide();
    connect(_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
}
QWidget *LineEditPropertyFactory::createEditor(QtStringPropertyManager *manager, QtProperty *property, QWidget *parent)
{
    LineEditWithButtons *editor = new LineEditWithButtons(manager->value(property), parent);
    buttonFactory = new EditorButtonFactory(parent);
    editor->layout()->addWidget(buttonFactory);

    for(uint i = 0; i < (uint)buttons_.size(); ++i)
    {
        QPushButton *button = buttonFactory->AddButton(buttons_[i].objectName, buttons_[i].text);
        connect(button, SIGNAL(clicked(bool)), SLOT(OnButtonClicked()));
    }

    propertyToWidget_[property] = editor;
    widgetToProperty_[editor] = property;

    connect(editor, SIGNAL(EditingFinished()), SLOT(OnEditingFinished()));
    connect(editor, SIGNAL(destroyed(QObject*)), SLOT(OnEditorDestroyed(QObject*)));

    emit EditorCreated(property, this);

    return editor;
}
Beispiel #4
0
void WingScaleDlg::SetupLayout()
{
	QGridLayout *pScaleLayout = new QGridLayout;
	{
		m_pctrlSpan  = new QCheckBox(tr("Span scaling"));
		m_pctrlChord = new QCheckBox(tr("Chord scaling"));
		m_pctrlSweep = new QCheckBox(tr("Sweep scaling"));
		m_pctrlTwist = new QCheckBox(tr("Twist scaling"));
		m_pctrlScaleArea = new QCheckBox(tr("Area scaling"));
		m_pctrlScaleAR   = new QCheckBox(tr("Aspect ratio scaling"));

		m_pctrlNewSpan  = new DoubleEdit(0,3);
		m_pctrlNewChord = new DoubleEdit(0,3);
		m_pctrlNewTwist = new DoubleEdit(0,3);
		m_pctrlNewSweep = new DoubleEdit(0,3);
		m_pctrlNewArea  = new DoubleEdit(0,3);
		m_pctrlNewAR    = new DoubleEdit(0,3);

		m_pctrlRefSpan  = new QLabel("0.000");
		m_pctrlRefChord = new QLabel("0.000");
		m_pctrlRefSweep = new QLabel("0.000");
		m_pctrlRefTwist = new QLabel("0.000");
		m_pctrlRefArea = new QLabel("0.000");
		m_pctrlRefAR   = new QLabel("0.000");

		m_pctrlRefSpan->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlRefChord->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlRefSweep->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlRefTwist->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlRefArea->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlRefAR->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

		m_pctrlSpanRatio  = new QLabel("1.000");
		m_pctrlChordRatio = new QLabel("1.000");
		m_pctrlSweepRatio = new QLabel("1.000");
		m_pctrlTwistRatio = new QLabel("1.000");
		m_pctrlAreaRatio = new QLabel("1.000");
		m_pctrlARRatio = new QLabel("1.000");
		m_pctrlSpanRatio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlChordRatio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlSweepRatio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlTwistRatio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlAreaRatio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_pctrlARRatio->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

		QLabel *lab11 = new QLabel(tr("Reference"));
		QLabel *lab12 = new QLabel(tr("New"));
		QLabel *lab13 = new QLabel(tr("Ratio"));
		lab11->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
		lab12->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
		lab13->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
		pScaleLayout->addWidget(lab11, 1,2);
		pScaleLayout->addWidget(lab12, 1,3);
		pScaleLayout->addWidget(lab13, 1,5);

		pScaleLayout->addWidget(m_pctrlSpan,      2,1);
		pScaleLayout->addWidget(m_pctrlRefSpan,   2,2);
		pScaleLayout->addWidget(m_pctrlNewSpan,   2,3);
		pScaleLayout->addWidget(m_pctrlSpanRatio, 2,5);

		pScaleLayout->addWidget(m_pctrlChord,     3,1);
		pScaleLayout->addWidget(m_pctrlRefChord,  3,2);
		pScaleLayout->addWidget(m_pctrlNewChord,  3,3);
		pScaleLayout->addWidget(m_pctrlChordRatio,3,5);

		pScaleLayout->addWidget(m_pctrlSweep,     4,1);
		pScaleLayout->addWidget(m_pctrlRefSweep,  4,2);
		pScaleLayout->addWidget(m_pctrlNewSweep,  4,3);
		pScaleLayout->addWidget(m_pctrlSweepRatio,4,5);

		pScaleLayout->addWidget(m_pctrlTwist,     5,1);
		pScaleLayout->addWidget(m_pctrlRefTwist,  5,2);
		pScaleLayout->addWidget(m_pctrlNewTwist,  5,3);
		pScaleLayout->addWidget(m_pctrlTwistRatio,5,5);

		pScaleLayout->addWidget(m_pctrlScaleArea, 6,1);
		pScaleLayout->addWidget(m_pctrlRefArea,   6,2);
		pScaleLayout->addWidget(m_pctrlNewArea,   6,3);
		pScaleLayout->addWidget(m_pctrlAreaRatio, 6,5);

		pScaleLayout->addWidget(m_pctrlScaleAR, 7,1);
		pScaleLayout->addWidget(m_pctrlRefAR,   7,2);
		pScaleLayout->addWidget(m_pctrlNewAR,   7,3);
		pScaleLayout->addWidget(m_pctrlARRatio, 7,5);

		QString unitLabel;
		Units::getLengthUnitLabel(unitLabel);
		QLabel *pLengthUnit1 = new QLabel(unitLabel);
		QLabel *pLengthUnit2 = new QLabel(unitLabel);

		QLabel *pAngleUnit1 = new QLabel(QString::fromUtf8("°"));
		QLabel *pAngleUnit2 = new QLabel(QString::fromUtf8("°"));

		Units::getAreaUnitLabel(unitLabel);
		QLabel *pAreaUnit = new QLabel(unitLabel);
		pScaleLayout->addWidget(pLengthUnit1, 2, 4);
		pScaleLayout->addWidget(pLengthUnit2, 3, 4);
		pScaleLayout->addWidget(pAngleUnit1,  4, 4);
		pScaleLayout->addWidget(pAngleUnit2,  5, 4);
		pScaleLayout->addWidget(pAreaUnit,    6, 4);
	}

	QHBoxLayout *pCommandButtons = new QHBoxLayout;
	{
		QPushButton *OKButton = new QPushButton(tr("OK"));
		QPushButton *CancelButton = new QPushButton(tr("Cancel"));
		pCommandButtons->addStretch(1);
		pCommandButtons->addWidget(OKButton);
		pCommandButtons->addStretch(1);
		pCommandButtons->addWidget(CancelButton);
		pCommandButtons->addStretch(1);

		connect(OKButton, SIGNAL(clicked()), this, SLOT(OnOK()));
		connect(CancelButton, SIGNAL(clicked()), this, SLOT(reject()));
	}

	QHBoxLayout *pStretchLayout = new QHBoxLayout;
	{
		pStretchLayout->addStretch(1);
		pStretchLayout->addLayout(pScaleLayout);
		pStretchLayout->addStretch(1);
	}

	QVBoxLayout *pMainLayout = new QVBoxLayout;
	{
		pMainLayout->addStretch(1);
		pMainLayout->addLayout(pStretchLayout);
		pMainLayout->addStretch(1);
		pMainLayout->addLayout(pCommandButtons);
		pMainLayout->addStretch(1);
	}

	setLayout(pMainLayout);

	connect(m_pctrlSpan,  SIGNAL(clicked()), this, SLOT(OnClickedCheckBox()));
	connect(m_pctrlChord, SIGNAL(clicked()), this, SLOT(OnClickedCheckBox()));
	connect(m_pctrlSweep, SIGNAL(clicked()), this, SLOT(OnClickedCheckBox()));
	connect(m_pctrlTwist, SIGNAL(clicked()), this, SLOT(OnClickedCheckBox()));
	connect(m_pctrlScaleArea, SIGNAL(clicked()), this, SLOT(OnClickedCheckBox()));
	connect(m_pctrlScaleAR, SIGNAL(clicked()), this, SLOT(OnClickedCheckBox()));

	connect(m_pctrlNewSpan,  SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
	connect(m_pctrlNewChord, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
	connect(m_pctrlNewSweep, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
	connect(m_pctrlNewTwist, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
	connect(m_pctrlNewArea, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
	connect(m_pctrlNewAR, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
}