/*! \reimp */ QAccessible::State QAccessibleSpinBox::state(int child) const { State state = QAccessibleAbstractSpinBox::state(child); switch(child) { case ValueUp: if (spinBox()->value() >= spinBox()->maximum()) state |= Unavailable; return state; case ValueDown: if (spinBox()->value() <= spinBox()->minimum()) state |= Unavailable; return state; default: break; } return state; }
void RegionChooser::show_region_properties() { if (!region) return; Gtk::Dialog dialog(_("Region Properties"), true /*modal*/); // add "Keygroup" checkbox Gtk::CheckButton checkBoxKeygroup(_("Member of a Keygroup (Exclusive Group)")); checkBoxKeygroup.set_active(region->KeyGroup); dialog.get_vbox()->pack_start(checkBoxKeygroup); checkBoxKeygroup.show(); // add "Keygroup" spinbox Gtk::Adjustment adjustment(1, 1, pow(2,32)); Gtk::SpinButton spinBox(adjustment); if (region->KeyGroup) spinBox.set_value(region->KeyGroup); dialog.get_vbox()->pack_start(spinBox); spinBox.show(); // add OK and CANCEL buttons to the dialog dialog.add_button(Gtk::Stock::OK, 0); dialog.add_button(Gtk::Stock::CANCEL, 1); dialog.show_all_children(); if (!dialog.run()) { // OK selected ... region->KeyGroup = (checkBoxKeygroup.get_active()) ? spinBox.get_value_as_int() : 0; } }
/*! \reimp */ bool QAccessibleSpinBox::doAction(int action, int child, const QVariantList ¶ms) { if (!widget()->isEnabled()) return false; if (action == Press) { switch(child) { case ValueUp: if (spinBox()->value() >= spinBox()->maximum()) return false; spinBox()->stepUp(); return true; case ValueDown: if (spinBox()->value() <= spinBox()->minimum()) return false; spinBox()->stepDown(); return true; default: break; } } return QAccessibleAbstractSpinBox::doAction(action, 0, params); }
void KisGmicSettingsWidget::createSettingsWidget(ROLE role) { QList<Parameter *> parameters = m_commandDefinition->m_parameters; if (parameters.size() == 0) { dbgPlugins << "No parameters!"; return; } QGridLayout * gridLayout(0); if (role == CreateRole) { gridLayout = new QGridLayout(this); } int row = 0; for (int i = 0; i < parameters.size();i++) { Parameter * p = parameters.at(i); dbgPlugins << "Processing: " << qPrintable(p->typeName()) << " " << qPrintable(p->toString()); switch (p->m_type) { case Parameter::INT_P: { IntParameter * intParam = static_cast<IntParameter *>(p); KisSliderSpinBox * spinBox(0); if (role == CreateRole) { spinBox = new KisSliderSpinBox; spinBox->setMinimum(intParam->m_minValue); spinBox->setMaximum(intParam->m_maxValue); // map widget to parameter index m_widgetToParameterIndexMapper[spinBox] = i; mapParameterWidget(intParam, spinBox); // TODO: check if it should update preview!!!, only then recompute preview connect(spinBox, SIGNAL(valueChanged(int)), this, SIGNAL(sigConfigurationItemChanged())); connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(setIntValue(int))); gridLayout->addWidget(new QLabel(intParam->name()), row, 0); gridLayout->addWidget(spinBox, row, 1, 1, 3); row++; } else if (role == LoadRole) { spinBox = qobject_cast<KisSliderSpinBox *>(widget(intParam)); } if (spinBox) { spinBox->setValue(intParam->m_value); } else { dbgPlugins << "Widget not available; Role: " << role << p->m_type; } break; } case Parameter::FLOAT_P: { FloatParameter * floatParam = static_cast<FloatParameter *>(p); KisDoubleSliderSpinBox * spinBox(0); if (role == CreateRole) { spinBox = new KisDoubleSliderSpinBox; // TODO: check if 2 decimals is correct spinBox->setRange(floatParam->m_minValue, floatParam->m_maxValue, 2); m_widgetToParameterIndexMapper[spinBox] = i; mapParameterWidget(floatParam, spinBox); connect(spinBox, SIGNAL(valueChanged(qreal)), this, SIGNAL(sigConfigurationItemChanged())); connect(spinBox, SIGNAL(valueChanged(qreal)), this, SLOT(setFloatValue(qreal))); gridLayout->addWidget(new QLabel(floatParam->name()), row, 0); gridLayout->addWidget(spinBox, row, 1, 1, 3); row++; } else if (role == LoadRole) { spinBox = qobject_cast<KisDoubleSliderSpinBox *>(widget(floatParam)); } if (spinBox) { spinBox->setValue(floatParam->m_value); } else { dbgPlugins << "Widget not available; Role: " << role << " TYPE " <<p->m_type; } break; } case Parameter::CHOICE_P: { ChoiceParameter * choiceParam = static_cast<ChoiceParameter *>(p); QComboBox * combo(0); if (role == CreateRole) { combo = new QComboBox; QStringListModel *model = new QStringListModel(); model->setStringList(choiceParam->m_choices); combo->setModel(model); m_widgetToParameterIndexMapper[combo] = i; mapParameterWidget(choiceParam, combo); connect(combo, SIGNAL(currentIndexChanged(QString)), this, SIGNAL(sigConfigurationItemChanged())); connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setChoiceIndex(int))); gridLayout->addWidget(new QLabel(choiceParam->name()), row, 0); gridLayout->addWidget(combo, row, 1, 1, 3); row++; } else if (role == LoadRole)