15 #include <QInputDialog> 23 BaseWidget(parent,
"PresetWidget",
"Presets"), mLayout(new QVBoxLayout(this))
25 this->setToolTip(
"Select a predefined set of options");
26 mPresetsComboBox =
new QComboBox(
this);
27 mPresetsComboBox->setToolTip(
"Select a preset to use");
28 connect(mPresetsComboBox, SIGNAL(currentIndexChanged(
const QString&)),
this,
34 QIcon(
":/icons/preset_reset.png"),
35 "Reset all transfer function values to the defaults",
"",
39 QIcon(
":/icons/preset_remove.png"),
40 "Delete the current preset",
"",
44 QIcon(
":/icons/preset_save.png"),
45 "Add the current setting as a preset",
"",
48 mLayout->addWidget(mPresetsComboBox);
53 this->setLayout(mLayout);
58 if(mPresetsComboBox->findText(name) == -1)
61 mPresetsComboBox->setCurrentIndex(mPresetsComboBox->findText(name));
67 return mPresetsComboBox->currentText();
75 for(
int i=0; i < mButtonLayout->count(); ++i)
77 QWidget* widget = mButtonLayout->itemAt(i)->widget();
100 this->selectLastUsedPreset();
105 IMAGE_MODALITY
id =
mPresets->getId();
107 if (!
mPresets->getPresetList().isEmpty())
108 preset =
mPresets->getPresetList().first();
113 return lastUsedPresetName;
118 mPresetsComboBox->setCurrentIndex(0);
150 while ((child = mButtonLayout->takeAt(0)) != 0)
153 QWidget* widget = child->widget();
157 delete mButtonLayout;
161 mButtonLayout =
new QHBoxLayout;
162 mLayout->addLayout(mButtonLayout);
165 for (
int i=0; i<actions.size(); ++i)
167 QToolButton* button =
new QToolButton(
this);
168 button->setDefaultAction(actions[i]);
170 mButtonLayout->addWidget(button);
172 mButtonLayout->addStretch();
177 mPresetsComboBox->blockSignals(
true);
178 mPresetsComboBox->clear();
180 mPresetsComboBox->addItem(
"<Default preset>");
182 mPresetsComboBox->addItems(list);
184 mPresetsComboBox->blockSignals(
false);
194 newName =
"custom preset";
195 if (
mPresets->isDefaultPreset(newName))
199 QString text = QInputDialog::getText(
this,
"Save Preset",
200 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
201 if (!ok || text.isEmpty())
206 retval = retval.replace(
" ",
"-");
211 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)
QString enum2string(const ENUM &val)
Namespace for all CustusX production code.