36 #include <QInputDialog>
42 BaseWidget(parent,
"PresetWidget",
"Presets"), mLayout(new QVBoxLayout(this))
44 mPresetsComboBox =
new QComboBox(
this);
45 mPresetsComboBox->setToolTip(
"Select a preset to use");
46 connect(mPresetsComboBox, SIGNAL(currentIndexChanged(
const QString&)),
this,
52 QIcon(
":/icons/preset_reset.png"),
53 "Reset all transfer function values to the defaults",
"",
57 QIcon(
":/icons/preset_remove.png"),
58 "Delete the current preset",
"",
62 QIcon(
":/icons/preset_save.png"),
63 "Add the current setting as a preset",
"",
66 mLayout->addWidget(mPresetsComboBox);
71 this->setLayout(mLayout);
78 "<p>Lets you select a predefined set of options.</p>"
85 if(mPresetsComboBox->findText(name) == -1)
88 mPresetsComboBox->setCurrentIndex(mPresetsComboBox->findText(name));
94 return mPresetsComboBox->currentText();
102 for(
int i=0; i < mButtonLayout->count(); ++i)
104 QWidget* widget = mButtonLayout->itemAt(i)->widget();
131 mPresetsComboBox->setCurrentIndex(0);
162 while ((child = mButtonLayout->takeAt(0)) != 0)
165 QWidget* widget = child->widget();
169 delete mButtonLayout;
173 mButtonLayout =
new QHBoxLayout;
174 mLayout->addLayout(mButtonLayout);
177 for (
int i=0; i<actions.size(); ++i)
179 QToolButton* button =
new QToolButton(
this);
180 button->setDefaultAction(actions[i]);
182 mButtonLayout->addWidget(button);
184 mButtonLayout->addStretch();
189 mPresetsComboBox->blockSignals(
true);
190 mPresetsComboBox->clear();
192 mPresetsComboBox->addItem(
"<Default preset>");
194 mPresetsComboBox->addItems(list);
196 mPresetsComboBox->blockSignals(
false);
205 if (!
mPresets->getPresetList(
"").contains(newName))
206 newName =
"custom preset";
207 if (
mPresets->isDefaultPreset(newName))
211 QString text = QInputDialog::getText(
this,
"Save Preset",
212 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
213 if (!ok || text.isEmpty())
218 retval = retval.replace(
" ",
"-");
void reportError(QString msg)
boost::shared_ptr< class Presets > PresetsPtr