36 #include <QInputDialog>
42 BaseWidget(parent,
"PresetWidget",
"Presets"), mLayout(new QVBoxLayout(this))
44 this->setToolTip(
"Select a predefined set of options");
45 mPresetsComboBox =
new QComboBox(
this);
46 mPresetsComboBox->setToolTip(
"Select a preset to use");
47 connect(mPresetsComboBox, SIGNAL(currentIndexChanged(
const QString&)),
this,
53 QIcon(
":/icons/preset_reset.png"),
54 "Reset all transfer function values to the defaults",
"",
58 QIcon(
":/icons/preset_remove.png"),
59 "Delete the current preset",
"",
63 QIcon(
":/icons/preset_save.png"),
64 "Add the current setting as a preset",
"",
67 mLayout->addWidget(mPresetsComboBox);
72 this->setLayout(mLayout);
77 if(mPresetsComboBox->findText(name) == -1)
80 mPresetsComboBox->setCurrentIndex(mPresetsComboBox->findText(name));
86 return mPresetsComboBox->currentText();
94 for(
int i=0; i < mButtonLayout->count(); ++i)
96 QWidget* widget = mButtonLayout->itemAt(i)->widget();
123 mPresetsComboBox->setCurrentIndex(0);
154 while ((child = mButtonLayout->takeAt(0)) != 0)
157 QWidget* widget = child->widget();
161 delete mButtonLayout;
165 mButtonLayout =
new QHBoxLayout;
166 mLayout->addLayout(mButtonLayout);
169 for (
int i=0; i<actions.size(); ++i)
171 QToolButton* button =
new QToolButton(
this);
172 button->setDefaultAction(actions[i]);
174 mButtonLayout->addWidget(button);
176 mButtonLayout->addStretch();
181 mPresetsComboBox->blockSignals(
true);
182 mPresetsComboBox->clear();
184 mPresetsComboBox->addItem(
"<Default preset>");
186 mPresetsComboBox->addItems(list);
188 mPresetsComboBox->blockSignals(
false);
197 if (!
mPresets->getPresetList(
"").contains(newName))
198 newName =
"custom preset";
199 if (
mPresets->isDefaultPreset(newName))
203 QString text = QInputDialog::getText(
this,
"Save Preset",
204 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
205 if (!ok || text.isEmpty())
210 retval = retval.replace(
" ",
"-");
void reportError(QString msg)
boost::shared_ptr< class Presets > PresetsPtr