StringListSelectWidget::StringListSelectWidget(QWidget* parent, StringListPropertyPtr property,
	QGridLayout* gridLayout, int row) :
	BaseWidget(parent, "StringListSelectWidget", "StringListSelectWidget"),
	mData(property)
{
	connect(mData.get(), &Property::changed, this, &StringListSelectWidget::setModified);

	this->setEnabled(mData->getEnabled());

	mLabel = new QLabel(this);
	mLabel->setText(mData->getDisplayName());

	mMenu = new QMenu(this);
	mButton = new CXSmallToolButton();
	mButton->setIcon(QIcon(":icons/open_icon_library/go-down-4.png"));
	mButton->setPopupMode(QToolButton::InstantPopup);
	mButton->setMenu(mMenu);

	if (gridLayout) // add to input gridlayout
	{
		gridLayout->addLayout(mergeWidgetsIntoHBoxLayout(mLabel, addDummyMargin(this)), row, 0);
		gridLayout->addWidget(mButton, row, 1);
	}
	else // add directly to this
	{
		mTopLayout = new QHBoxLayout;
		mTopLayout->setMargin(0);
		this->setLayout(mTopLayout);

		mTopLayout->addWidget(mLabel);
		mTopLayout->addWidget(mButton, 1);
	}

	this->setModified();
}
Example #2
0
void SliderRangeGroupWidget::init(QGridLayout *gridLayout, int row)
{
	mLabel = new QLabel(this);
	mLabel->setText(mData->getDisplayName());
	mLowerEdit = new QDoubleSpinBox(this);
	mSpanSlider = new DoubleSpanSlider(this);
	mSpanSlider->setOrientation(Qt::Horizontal);
	mSpanSlider->setHandleMovementMode(QxtSpanSlider::NoOverlapping);
	mUpperEdit = new QDoubleSpinBox(this);

	this->setDecimals(mData->getValueDecimals());

	if (gridLayout) // add to input gridlayout
	{
			gridLayout->addLayout(mergeWidgetsIntoHBoxLayout(mLabel, addDummyMargin(this)), row, 0);

			QHBoxLayout* controlsLayout = new QHBoxLayout;
			controlsLayout->setSpacing(0);
			controlsLayout->setMargin(0);
			gridLayout->addLayout(controlsLayout, row, 1);

			controlsLayout->addWidget(mLowerEdit);
			controlsLayout->addWidget(mSpanSlider, 1);
			controlsLayout->addWidget(mUpperEdit);
	}
	else // add directly to this
	{
		QHBoxLayout* topLayout = new QHBoxLayout;
		topLayout->setMargin(0);
		this->setLayout(topLayout);

		topLayout->addWidget(mLabel);
		topLayout->addWidget(mLowerEdit);
		topLayout->addWidget(mSpanSlider, 1);
		topLayout->addWidget(mUpperEdit);
	}

	connect(mLowerEdit, SIGNAL(valueChanged(double)), this, SLOT(textEditedSlot()));
	// connect to slider
	connect(mSpanSlider, SIGNAL(doubleSpanChanged(double, double)), this, SLOT(doubleSpanChangedSlot(double, double)));
	connect(mUpperEdit, SIGNAL(valueChanged(double)), this, SLOT(textEditedSlot()));

	// connect to backend
	connect(mData.get(), SIGNAL(changed()), this, SLOT(dataChanged()));
	this->dataChanged();
}