Skip to content
Snippets Groups Projects
Commit 5c217097 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

merge fcts -> GUI::Util::createComboBox

parent eb9d3973
No related branches found
No related tags found
1 merge request!2082GUI various cleanup
......@@ -73,7 +73,7 @@ void IntensityDataPropertyWidget::createPanelElements()
item->setCurrentGradient(newVal);
gProjectDocument.value()->setModified();
},
&m_updaters));
false, &m_updaters));
m_mainLayout->addRow(GUI::Util::createCheckBox(
"Interpolate", [this] { return currentData2DItem()->isInterpolated(); },
......
......@@ -61,7 +61,7 @@ void MinimizerSettingsWidget::setMinContainerItem(MinimizerContainerItem* contai
m_containerItem->setCurrentObjectiveMetric(t);
gProjectDocument.value()->setModified();
},
&m_updaters,
false, &m_updaters,
"Objective metric to use for estimating distance between simulated "
"and experimental data"));
m_mainLayout->addRow("Norm function:",
......@@ -71,7 +71,7 @@ void MinimizerSettingsWidget::setMinContainerItem(MinimizerContainerItem* contai
m_containerItem->setCurrentNormFunction(t);
gProjectDocument.value()->setModified();
},
&m_updaters,
false, &m_updaters,
"Normalization to use for estimating distance between simulated and "
"experimental data"));
......
......@@ -158,12 +158,13 @@ DetectorEditor::DetectorEditor(QWidget* parent, GISASInstrumentItem* instrItem)
auto* aliForm = new QFormLayout;
aliLine->addLayout(aliForm);
auto* aliCombo = GUI::Util::createSafeComboBox(
[detectorItem] { return detectorItem->detectorAlignmentCombo(); },
[this, detectorItem](const QString& t) {
detectorItem->setDetectorAlignment(t);
emit dataChanged();
});
auto* aliCombo =
GUI::Util::createComboBox([detectorItem] { return detectorItem->detectorAlignmentCombo(); },
[this, detectorItem](const QString& t) {
detectorItem->setDetectorAlignment(t);
emit dataChanged();
},
true);
aliForm->addRow("Alignment:", aliCombo);
auto* detposLayout = new QFormLayout;
......
......@@ -21,9 +21,8 @@
using std::function;
QComboBox* GUI::Util::createComboBox(function<ComboProperty()> comboFunction,
function<void(const QString&)> slot,
QList<function<void()>>* updaters, QString tooltip,
bool isScrollable)
function<void(const QString&)> slot, bool inScrollArea,
QList<function<void()>>* updaters, QString tooltip)
{
QComboBox* combo = new QComboBox;
combo->addItems(comboFunction().values());
......@@ -35,7 +34,8 @@ QComboBox* GUI::Util::createComboBox(function<ComboProperty()> comboFunction,
for (int index = 0; index < combo->count(); index++)
combo->setItemData(index, comboFunction().toolTips().at(index), Qt::ToolTipRole);
if (!isScrollable)
if (inScrollArea)
// Ignore mouse wheel events, since they may be meant for scrolling at large.
WheelEventEater::install(combo);
QObject::connect(combo, &QComboBox::currentTextChanged, [=] { slot(combo->currentText()); });
......@@ -49,13 +49,6 @@ QComboBox* GUI::Util::createComboBox(function<ComboProperty()> comboFunction,
return combo;
}
QComboBox* GUI::Util::createSafeComboBox(function<ComboProperty()> comboFunction,
function<void(const QString&)> slot,
QList<function<void()>>* updaters, QString tooltip)
{
return createComboBox(comboFunction, slot, updaters, tooltip, false);
}
QComboBox* GUI::Util::createUnitsComboBox(const QStringList& list, function<QString()> currentUnits,
function<void(const QString&)> slot,
QList<function<void()>>* updaters, bool isScrollable)
......
......@@ -27,20 +27,15 @@ namespace GUI::Util {
//!
//! The combo box will be filled with the available options and will get the found tooltips,
//! the common one and individual for each item. The current text will be just passes to "slot"
//! function. Furthermore, the combo box can prohibit accidental changes by the mouse wheel.
//! Otherwise it would be dangerous if the combo is on a scrollable form - unintended and unnoticed
//! changes would take place when just scrolling through the form.
//! function.
//!
//! If this combox box resides in a scroll area, we ignore mouse wheel events.
//!
//! The combo can be updated from outside using "updaters" list.
//!
QComboBox* createComboBox(std::function<ComboProperty()> comboFunction,
std::function<void(const QString&)> slot,
QList<std::function<void()>>* updaters = nullptr, QString tooltip = "",
bool isScrollable = true);
QComboBox* createSafeComboBox(std::function<ComboProperty()> comboFunction,
std::function<void(const QString&)> slot,
QList<std::function<void()>>* updaters = nullptr,
QString tooltip = "");
std::function<void(const QString&)> slot, bool inScrollArea,
QList<std::function<void()>>* updaters = nullptr, QString tooltip = "");
QComboBox* createUnitsComboBox(const QStringList& list, std::function<QString()> currentUnits,
std::function<void(const QString&)> slot,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment