Example #1
0
QList< QWidget* > NodeTypesDelegate::createItemWidgets(const QModelIndex &index) const
{
    // items created by this method and added to the return-list will be
    // deleted by KWidgetItemDelegate

    KColorButton *colorButton = new KColorButton(index.data(NodeTypeModel::ColorRole).value<QColor>());
    colorButton->setFlat(true);
    QLineEdit *title = new QLineEdit(index.data(NodeTypeModel::TitleRole).toString());
    title->setMinimumWidth(100);
    QLabel *idLabel = new QLabel(index.data(NodeTypeModel::IdRole).toString());
    idLabel->setToolTip(i18n("Unique ID of the node type."));
    QToolButton *propertiesButton = new QToolButton();
    propertiesButton->setIcon(QIcon::fromTheme("document-properties"));

    connect(colorButton, &KColorButton::changed,
        this, &NodeTypesDelegate::onColorChanged);
    connect(colorButton, &KColorButton::pressed,
        this, &NodeTypesDelegate::onColorDialogOpened);
    connect(title, &QLineEdit::textEdited,
        this, &NodeTypesDelegate::onNameChanged);
    connect(propertiesButton, &QToolButton::clicked,
        this, &NodeTypesDelegate::showPropertiesDialog);

    return QList<QWidget*>() << colorButton
                             << title
                             << idLabel
                             << propertiesButton;
}
Example #2
0
//-----------------------------------------------------------------------------
// dialog to setup screen saver parameters
//
KBlankSetup::KBlankSetup(QWidget *parent, const char *name) : KDialogBase(parent, name, true, i18n("Setup Blank Screen Saver"), Ok | Cancel, Ok, true)
{
    readSettings();

    QFrame *main = makeMainWidget();
    QGridLayout *grid = new QGridLayout(main, 4, 2, 0, spacingHint());

    QLabel *label = new QLabel(i18n("Color:"), main);
    grid->addWidget(label, 0, 0);

    KColorButton *colorPush = new KColorButton(color, main);
    colorPush->setMinimumWidth(80);
    connect(colorPush, SIGNAL(changed(const QColor &)), SLOT(slotColor(const QColor &)));
    grid->addWidget(colorPush, 1, 0);

    preview = new QWidget(main);
    preview->setFixedSize(220, 165);
    preview->setBackgroundColor(black);
    preview->show(); // otherwise saver does not get correct size
    saver = new KBlankSaver(preview->winId());
    grid->addMultiCellWidget(preview, 0, 2, 1, 1);

    grid->setRowStretch(2, 10);
    grid->setRowStretch(3, 20);

    setMinimumSize(sizeHint());
}
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;	
}
Example #4
0
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));
}
Example #5
0
//-----------------------------------------------------------------------------
// dialog to setup screen saver parameters
//
KBlankSetup::KBlankSetup( QWidget *parent, const char *name )
	: KDialog( parent )
{
  setObjectName( name );
  setModal( true );
  setCaption( i18n( "Setup Blank Screen Saver" ) );
  setButtons( Ok | Cancel );

	readSettings();

	QFrame *main = new QFrame( this );
  setMainWidget( main );
	QGridLayout *grid = new QGridLayout(main);
	grid->setSpacing(spacingHint());
	grid->setMargin(0);

	QLabel *label = new QLabel( i18n("Color:"), main );
	grid->addWidget(label, 0, 0);

	KColorButton *colorPush = new KColorButton( color, main );
	colorPush->setMinimumWidth(80);
	connect( colorPush, SIGNAL(changed(QColor)),
		SLOT(slotColor(QColor)) );
	grid->addWidget(colorPush, 1, 0);

	preview = new QWidget( main );
	preview->setFixedSize( 220, 165 );
	QPalette palette;
	palette.setColor( preview->backgroundRole(), Qt::black );
	preview->setPalette(palette);
	preview->setAutoFillBackground(true);
	preview->show();    // otherwise saver does not get correct size
	saver = new KBlankSaver( preview->winId() );
	grid->addWidget(preview, 0, 1, 3, 1);

	grid->setRowStretch( 2, 10 );
	grid->setRowStretch( 3, 20 );

	setMinimumSize( sizeHint() );
	connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
}
Example #6
0
AppearanceConfig::AppearanceConfig()
    : QWidget(0, "appearance_config_widget")
{
    QVBoxLayout *top = new QVBoxLayout(this, KDialog::spacingHint());

    QHBoxLayout *hbox = new QHBoxLayout(top);
    QGrid *grid = new QGrid(2, this);
    grid->setSpacing(KDialog::spacingHint());
    hbox->addWidget(grid);
    for (uint i=0; i<Settings::EnumType::COUNT; i++) {
        (void)new QLabel(i18n(COLOR_LABELS[i]), grid);
        KColorButton *cb = new KColorButton(grid, COLOR_CONFIG_NAMES[i]);
        cb->setFixedWidth(100);
    }
    for (uint i=0; i<NB_N_COLORS; i++) {
        (void)new QLabel(i18n("%n mine color:", "%n mines color:", i+1), grid);
        KColorButton *cb = new KColorButton(grid, N_COLOR_CONFIG_NAMES[i]);
        cb->setFixedWidth(100);
    }
    hbox->addStretch(1);

    top->addStretch(1);
}
QString ColorThemeParameter::valueFromWidget(QWidget* widget) const {
	KColorButton* button = static_cast<KColorButton*>(widget);
	return button->color().name();
}
QWidget* ColorThemeParameter::createWidget(QWidget* parent, const QString& value) const {
	KColorButton* button = new KColorButton(parent);
	QColor color(value);
	button->setColor(color);
	return button;
}
Example #9
0
void KisWdgIndexColors::setup(QStringList shadesLabels, int ramps)
{
    int rows     = shadesLabels.length();
    int collumns = ramps;

    m_colorSelectors.resize(rows);
    m_stepSpinners.resize(rows-1);
    // Labels for the shades
    for(int row = 0; row < rows; ++row)
    {
        QLabel* l = new QLabel(shadesLabels[row], ui->colorsBox);
        ui->layoutColors->addWidget(l, row+1, 0);
        m_colorSelectors[row].resize(collumns);
    }
    // Labels for the ramps
    /*for(int col = 0; col < collumns; ++col)
    {
    	QLabel* l = new QLabel(rampsLabels[col], ui->colorsBox);
    	l->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    	ui->layoutColors->addWidget(l, 0, col+1);
    }*/
    // Step selectors for the shade gradients
    for(int row = 0; row < (rows-1); ++row)
    {
        QLabel* l0 = new QLabel(shadesLabels[row+1]);
        QLabel* l1 = new QLabel(QString::fromUtf8("↔"));
        QLabel* l2 = new QLabel(shadesLabels[row]);

        QSpinBox* s = new QSpinBox();
        s->setMinimum(0);
        s->setMaximum(32);
        s->setValue(2);

        connect(s, SIGNAL(valueChanged(int)), this, SIGNAL(sigConfigurationItemChanged()));
        m_stepSpinners[row] = s;

        ui->layoutRowSteps->addWidget(l0, row, 0);
        ui->layoutRowSteps->addWidget(l1, row, 1);
        ui->layoutRowSteps->addWidget(l2, row, 2);
        ui->layoutRowSteps->addWidget(s,  row, 3);
    }
    // Color selectors
    for(int y = 0; y < rows; ++y)
        for(int x = 0; x < collumns; ++x)
        {
            KColorButton* b = new KColorButton;
            QCheckBox* c = new QCheckBox;
            c->setChecked(false);
            b->setEnabled(false);
            b->setMaximumWidth(50);
            c->setMaximumWidth(21); // Ugh. I hope this won't be causing any issues. Trying to get rid of the unnecessary spacing after it.

            connect(c, SIGNAL(toggled(bool)), b, SLOT(setEnabled(bool)));
            connect(c, SIGNAL(toggled(bool)), this, SIGNAL(sigConfigurationItemChanged()));
            connect(b, SIGNAL(changed(QColor)), this, SIGNAL(sigConfigurationItemChanged()));

            QHBoxLayout* cell = new QHBoxLayout();
            cell->setSpacing(0);
            cell->setContentsMargins(0, 0, 0, 0);
            cell->addWidget(c);
            cell->addWidget(b);
            ui->layoutColors->addLayout(cell, 1+y, 1+x);

            m_colorSelectors[y][x].button = b;
            m_colorSelectors[y][x].checkbox = c;
        }
}