15 #include <QInputDialog> 22 BaseWidget(parent,
"PresetWidget",
"Presets"), mLayout(new QVBoxLayout(this))
24 this->setToolTip(
"Select a predefined set of options");
25 mPresetsComboBox =
new QComboBox(
this);
26 mPresetsComboBox->setToolTip(
"Select a preset to use");
27 connect(mPresetsComboBox, SIGNAL(currentIndexChanged(
const QString&)),
this,
33 QIcon(
":/icons/preset_reset.png"),
34 "Reset all transfer function values to the defaults",
"",
38 QIcon(
":/icons/preset_remove.png"),
39 "Delete the current preset",
"",
43 QIcon(
":/icons/preset_save.png"),
44 "Add the current setting as a preset",
"",
47 mLayout->addWidget(mPresetsComboBox);
52 this->setLayout(mLayout);
57 if(mPresetsComboBox->findText(name) == -1)
60 mPresetsComboBox->setCurrentIndex(mPresetsComboBox->findText(name));
66 return mPresetsComboBox->currentText();
74 for(
int i=0; i < mButtonLayout->count(); ++i)
76 QWidget* widget = mButtonLayout->itemAt(i)->widget();
99 this->selectLastUsedPreset();
107 QString lastUsedPresetName =
settings()->
value(
id).toString();
108 return lastUsedPresetName;
113 mPresetsComboBox->setCurrentIndex(0);
145 while ((child = mButtonLayout->takeAt(0)) != 0)
148 QWidget* widget = child->widget();
152 delete mButtonLayout;
156 mButtonLayout =
new QHBoxLayout;
157 mLayout->addLayout(mButtonLayout);
160 for (
int i=0; i<actions.size(); ++i)
162 QToolButton* button =
new QToolButton(
this);
163 button->setDefaultAction(actions[i]);
165 mButtonLayout->addWidget(button);
167 mButtonLayout->addStretch();
172 mPresetsComboBox->blockSignals(
true);
173 mPresetsComboBox->clear();
175 mPresetsComboBox->addItem(
"<Default preset>");
177 mPresetsComboBox->addItems(list);
179 mPresetsComboBox->blockSignals(
false);
188 if (!
mPresets->getPresetList(
"").contains(newName))
189 newName =
"custom preset";
190 if (
mPresets->isDefaultPreset(newName))
194 QString text = QInputDialog::getText(
this,
"Save Preset",
195 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
196 if (!ok || text.isEmpty())
201 retval = retval.replace(
" ",
"-");
206 void PresetWidget::selectLastUsedPreset()
void reportError(QString msg)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
Settings * settings()
Shortcut for accessing the settings instance.
boost::shared_ptr< class Presets > PresetsPtr
void fillDefault(QString name, T value)
Namespace for all CustusX production code.