36 #include <QInputDialog>
43 BaseWidget(parent,
"PresetWidget",
"Presets"), mLayout(new QVBoxLayout(this))
45 this->setToolTip(
"Select a predefined set of options");
46 mPresetsComboBox =
new QComboBox(
this);
47 mPresetsComboBox->setToolTip(
"Select a preset to use");
48 connect(mPresetsComboBox, SIGNAL(currentIndexChanged(
const QString&)),
this,
54 QIcon(
":/icons/preset_reset.png"),
55 "Reset all transfer function values to the defaults",
"",
59 QIcon(
":/icons/preset_remove.png"),
60 "Delete the current preset",
"",
64 QIcon(
":/icons/preset_save.png"),
65 "Add the current setting as a preset",
"",
68 mLayout->addWidget(mPresetsComboBox);
73 this->setLayout(mLayout);
78 if(mPresetsComboBox->findText(name) == -1)
81 mPresetsComboBox->setCurrentIndex(mPresetsComboBox->findText(name));
87 return mPresetsComboBox->currentText();
95 for(
int i=0; i < mButtonLayout->count(); ++i)
97 QWidget* widget = mButtonLayout->itemAt(i)->widget();
120 this->selectLastUsedPreset();
128 QString lastUsedPresetName =
settings()->
value(
id).toString();
129 return lastUsedPresetName;
134 mPresetsComboBox->setCurrentIndex(0);
166 while ((child = mButtonLayout->takeAt(0)) != 0)
169 QWidget* widget = child->widget();
173 delete mButtonLayout;
177 mButtonLayout =
new QHBoxLayout;
178 mLayout->addLayout(mButtonLayout);
181 for (
int i=0; i<actions.size(); ++i)
183 QToolButton* button =
new QToolButton(
this);
184 button->setDefaultAction(actions[i]);
186 mButtonLayout->addWidget(button);
188 mButtonLayout->addStretch();
193 mPresetsComboBox->blockSignals(
true);
194 mPresetsComboBox->clear();
196 mPresetsComboBox->addItem(
"<Default preset>");
198 mPresetsComboBox->addItems(list);
200 mPresetsComboBox->blockSignals(
false);
209 if (!
mPresets->getPresetList(
"").contains(newName))
210 newName =
"custom preset";
211 if (
mPresets->isDefaultPreset(newName))
215 QString text = QInputDialog::getText(
this,
"Save Preset",
216 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
217 if (!ok || text.isEmpty())
222 retval = retval.replace(
" ",
"-");
227 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)