コード例 #1
0
QWidget * DataRecorderChannelBoolean::getPropertyWidget(QWidget * parent, const char * name)
{
	if (!m_propertyWidget)
	{
		// Setup widget
		QVBox * widget = new QVBox(parent,name);
		Q_CHECK_PTR(widget);
		widget->setMargin(KDialog::marginHint());
		widget->setSpacing(KDialog::spacingHint());
		
		QLabel * lab;
		lab = new QLabel(i18n("DataRecorder", "Channel:"), widget);
		Q_CHECK_PTR(lab);
		
		KSimLineEdit * conName;
		conName = new KSimLineEdit(widget);
		Q_CHECK_PTR(conName);
		conName->setText(getConnector()->getName());
		connect(getConnector(), SIGNAL(signalSetName(const QString &)), conName, SLOT(setText(const QString &)));
		connect(conName, SIGNAL(changed(const QString &)), SLOT(setChannelName(const QString &)));
		lab->setBuddy(conName);
		// TODO add ToolTip

		
		ChannelPositionWidget * pos;
		pos = new ChannelPositionWidget(this, widget);
		Q_CHECK_PTR(pos);
		pos->setGainValue(getVerticalGain());
		pos->setOffsetValue(getVerticalOffset());
		connect(pos, SIGNAL(gainChanged(double)), SLOT(setVerticalGain(double)));
		connect(pos, SIGNAL(offsetChanged(double)), SLOT(setVerticalOffset(double)));
		
		
		KColorButton * color = new KColorButton(widget);
		Q_CHECK_PTR(color);
		color->setColor(getLineColor());
		connect(color, SIGNAL(changed(const QColor &)), SLOT(setLineColor(const QColor &)));
		
		
		m_propertyWidget = widget;
	}
	else
	{
		if (parent)
		{
			KSIMDEBUG("Only one widget allowed");
		}
	}
		
	return m_propertyWidget;	
}
コード例 #2
0
ファイル: nodetypesdelegate.cpp プロジェクト: KDE/rocs
void NodeTypesDelegate::updateItemWidgets(const QList< QWidget* > widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const
{
    // widgets:
    // ColorButton | Title | ID

    if (!index.isValid()) {
        return;
    }

    Q_ASSERT(widgets.size() == 4);

    KColorButton *colorButton = qobject_cast<KColorButton*>(widgets.at(0));
    QLineEdit *title = qobject_cast<QLineEdit*>(widgets.at(1));
    QLabel *id = qobject_cast<QLabel*>(widgets.at(2));
    QToolButton *propertiesButton = qobject_cast<QToolButton*>(widgets.at(3));

    Q_ASSERT(title);
    Q_ASSERT(colorButton);
    Q_ASSERT(id);
    Q_ASSERT(propertiesButton);

    colorButton->setColor(index.data(NodeTypeModel::ColorRole).value<QColor>());
    title->setText(index.data(NodeTypeModel::TitleRole).toString());
    id->setText(index.data(NodeTypeModel::IdRole).toString());

    QRect outerRect(0, 0, option.rect.width(), option.rect.height());
    QRect contentRect = outerRect.adjusted(m_hPadding, m_vPadding, -m_hPadding, -m_vPadding);

    int colorButtonLeftMargin = contentRect.left();
    int colorButtonTopMargin = (outerRect.height() - colorButton->height()) / 2;
    colorButton->move(colorButtonLeftMargin, colorButtonTopMargin);

    int titleLeftMargin = colorButtonLeftMargin + colorButton->width() + 10;
    int titleTopMargin = (outerRect.height() - title->height()) / 2;
    title->move(titleLeftMargin, titleTopMargin);

    // construct remaining from right to left
    int propertiesLeftMargin = contentRect.right() - propertiesButton->width() - m_hPadding;
    int propertiesTopMargin = (outerRect.height() - propertiesButton->height()) / 2;
    propertiesButton->move(propertiesLeftMargin, propertiesTopMargin);

    int idLeftMargin = propertiesLeftMargin - id->width() - 10;
    int idTopMargin = (outerRect.height() - id->height()) / 2;
    id->move(idLeftMargin, idTopMargin);

    // title gets remaining space
    title->setFixedWidth(qMax(0, idLeftMargin - titleLeftMargin - 10));
}
コード例 #3
0
QWidget* ColorThemeParameter::createWidget(QWidget* parent, const QString& value) const {
	KColorButton* button = new KColorButton(parent);
	QColor color(value);
	button->setColor(color);
	return button;
}