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();
106 if (!
mPresets->getPresetList().isEmpty())
107 preset =
mPresets->getPresetList().first();
111 QString lastUsedPresetName =
settings()->
value(
id).toString();
112 return lastUsedPresetName;
117 mPresetsComboBox->setCurrentIndex(0);
149 while ((child = mButtonLayout->takeAt(0)) != 0)
152 QWidget* widget = child->widget();
156 delete mButtonLayout;
160 mButtonLayout =
new QHBoxLayout;
161 mLayout->addLayout(mButtonLayout);
164 for (
int i=0; i<actions.size(); ++i)
166 QToolButton* button =
new QToolButton(
this);
167 button->setDefaultAction(actions[i]);
169 mButtonLayout->addWidget(button);
171 mButtonLayout->addStretch();
176 mPresetsComboBox->blockSignals(
true);
177 mPresetsComboBox->clear();
179 mPresetsComboBox->addItem(
"<Default preset>");
181 mPresetsComboBox->addItems(list);
183 mPresetsComboBox->blockSignals(
false);
192 if (!
mPresets->getPresetList(
"").contains(newName))
193 newName =
"custom preset";
194 if (
mPresets->isDefaultPreset(newName))
198 QString text = QInputDialog::getText(
this,
"Save Preset",
199 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
200 if (!ok || text.isEmpty())
205 retval = retval.replace(
" ",
"-");
210 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.