Skip to content
Snippets Groups Projects
Commit 62155516 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov Committed by Mikhail Svechnikov
Browse files

WidgetUtils are unified

parent 3febb81e
No related branches found
No related tags found
1 merge request!964GUI refactoring: move spinbox/combobox/textbox/checkbox creating functions to WidgetUtils
Showing
with 51 additions and 74 deletions
...@@ -16,9 +16,10 @@ ...@@ -16,9 +16,10 @@
#include "GUI/View/Tool/EditUtil.h" #include "GUI/View/Tool/EditUtil.h"
#include <QWheelEvent> #include <QWheelEvent>
DoubleSpinBox::DoubleSpinBox(QWidget* parent, const DoubleDescriptor& d) DoubleSpinBox::DoubleSpinBox(const DoubleDescriptor& d, bool easyScrollable, QWidget* parent)
: QDoubleSpinBox(parent) : QDoubleSpinBox(parent)
, m_valueDescriptor(d) , m_valueDescriptor(d)
, easyScrollable(easyScrollable)
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
GUI::View::EditUtil::configSpinbox(this, d.decimals, d.limits); GUI::View::EditUtil::configSpinbox(this, d.decimals, d.limits);
...@@ -80,10 +81,10 @@ void DoubleSpinBox::setBaseValue(double baseValue) ...@@ -80,10 +81,10 @@ void DoubleSpinBox::setBaseValue(double baseValue)
void DoubleSpinBox::wheelEvent(QWheelEvent* event) void DoubleSpinBox::wheelEvent(QWheelEvent* event)
{ {
if (!hasFocus()) if (hasFocus() || easyScrollable)
event->ignore();
else
QDoubleSpinBox::wheelEvent(event); QDoubleSpinBox::wheelEvent(event);
else
event->ignore();
} }
void DoubleSpinBox::onDisplayValueChanged(double newDisplayValue) void DoubleSpinBox::onDisplayValueChanged(double newDisplayValue)
......
...@@ -28,7 +28,7 @@ public: ...@@ -28,7 +28,7 @@ public:
//! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it //! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it
//! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed //! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed
//! changes would take place when just scrolling through the form. //! changes would take place when just scrolling through the form.
DoubleSpinBox(QWidget* parent, const DoubleDescriptor& d); DoubleSpinBox(const DoubleDescriptor& d, bool easyScrollable = false, QWidget* parent = nullptr);
//! Set a display unit. //! Set a display unit.
//! //!
...@@ -77,6 +77,7 @@ private: ...@@ -77,6 +77,7 @@ private:
Unit m_displayUnit = Unit::unitless; Unit m_displayUnit = Unit::unitless;
DoubleDescriptor m_valueDescriptor; DoubleDescriptor m_valueDescriptor;
bool easyScrollable;
//! it was decided to not show the unit as a suffix. However, this may be user //! it was decided to not show the unit as a suffix. However, this may be user
//! selectable once, therefore the code is kept and controlled by this flag //! selectable once, therefore the code is kept and controlled by this flag
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "GUI/Model/Job/JobItem.h" #include "GUI/Model/Job/JobItem.h"
#include "GUI/Model/Job/MinimizerItem.h" #include "GUI/Model/Job/MinimizerItem.h"
#include "GUI/View/Common/DoubleSpinBox.h" #include "GUI/View/Common/DoubleSpinBox.h"
#include "GUI/View/Common/SafeSpinBox.h"
#include "GUI/View/Tool/LayoutUtils.h" #include "GUI/View/Tool/LayoutUtils.h"
#include "GUI/View/Tool/WidgetUtils.h" #include "GUI/View/Tool/WidgetUtils.h"
#include <QComboBox> #include <QComboBox>
...@@ -55,7 +56,7 @@ void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem) ...@@ -55,7 +56,7 @@ void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem)
return; return;
m_mainLayout->addRow("Minimizer:", m_mainLayout->addRow("Minimizer:",
GUI::Util::createComboBox(m_currentItem->minimizers(), &m_updaters, GUI::Util::createComboBoxUpdScroll(m_currentItem->minimizers(), &m_updaters,
[=](int) { createMimimizerEdits(); })); [=](int) { createMimimizerEdits(); }));
auto* w = new QWidget(this); auto* w = new QWidget(this);
...@@ -64,39 +65,14 @@ void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem) ...@@ -64,39 +65,14 @@ void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem)
m_mainLayout->addRow(w); m_mainLayout->addRow(w);
m_mainLayout->addRow("Objective metric:", m_mainLayout->addRow("Objective metric:",
GUI::Util::createComboBox(m_currentItem->objectiveMetric(), &m_updaters)); GUI::Util::createComboBoxUpdScroll(m_currentItem->objectiveMetric(), &m_updaters));
m_mainLayout->addRow("Norm function:", m_mainLayout->addRow("Norm function:",
GUI::Util::createComboBox(m_currentItem->normFunction(), &m_updaters)); GUI::Util::createComboBoxUpdScroll(m_currentItem->normFunction(), &m_updaters));
createMimimizerEdits(); createMimimizerEdits();
updateUIValues(); updateUIValues();
} }
QWidget* MinimizerSettingsWidget::createSpinbox(UIntDescriptor d)
{
auto* spinBox = new QSpinBox(this);
spinBox->setToolTip(d.tooltip);
spinBox->setMaximum(std::numeric_limits<int>::max());
spinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
if (d.limits.hasLowerLimit())
spinBox->setMinimum(static_cast<int>(d.limits.lowerLimit()));
if (d.limits.hasUpperLimit())
spinBox->setMaximum(static_cast<int>(d.limits.upperLimit()));
spinBox->setValue(d.get());
QObject::connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged),
[=](int newValue) { d.set(newValue); });
m_updaters << [=]() {
QSignalBlocker b(spinBox);
spinBox->setValue(d.get());
};
return spinBox;
}
void MinimizerSettingsWidget::createMimimizerEdits() void MinimizerSettingsWidget::createMimimizerEdits()
{ {
GUI::Util::Layout::clearLayout(m_minimizerLayout); GUI::Util::Layout::clearLayout(m_minimizerLayout);
...@@ -107,10 +83,10 @@ void MinimizerSettingsWidget::createMimimizerEdits() ...@@ -107,10 +83,10 @@ void MinimizerSettingsWidget::createMimimizerEdits()
m_minimizerLayout->addRow(d.label + ":", GUI::Util::createDoubleSpinbox(d, &m_updaters)); m_minimizerLayout->addRow(d.label + ":", GUI::Util::createDoubleSpinbox(d, &m_updaters));
} else if (std::holds_alternative<SelectionDescriptor<QString>>(v)) { } else if (std::holds_alternative<SelectionDescriptor<QString>>(v)) {
auto d = std::get<SelectionDescriptor<QString>>(v); auto d = std::get<SelectionDescriptor<QString>>(v);
m_minimizerLayout->addRow(d.label + ":", GUI::Util::createComboBox(d, &m_updaters)); m_minimizerLayout->addRow(d.label + ":", GUI::Util::createComboBoxUpdScroll(d, &m_updaters));
} else if (std::holds_alternative<UIntDescriptor>(v)) { } else if (std::holds_alternative<UIntDescriptor>(v)) {
auto d = std::get<UIntDescriptor>(v); auto d = std::get<UIntDescriptor>(v);
m_minimizerLayout->addRow(d.label + ":", createSpinbox(d)); m_minimizerLayout->addRow(d.label + ":", GUI::Util::createSpinBoxScroll(d, &m_updaters));
} }
} }
} }
......
...@@ -42,7 +42,6 @@ public slots: ...@@ -42,7 +42,6 @@ public slots:
void setItem(MinimizerContainerItem* minimizerItem); void setItem(MinimizerContainerItem* minimizerItem);
private: private:
QWidget* createSpinbox(UIntDescriptor d);
void createMimimizerEdits(); void createMimimizerEdits();
void updateUIValues(); void updateUIValues();
......
...@@ -53,7 +53,7 @@ DetectorAlignmentEditor::DetectorAlignmentEditor(QWidget* parent, RectangularDet ...@@ -53,7 +53,7 @@ DetectorAlignmentEditor::DetectorAlignmentEditor(QWidget* parent, RectangularDet
auto* m_combo = GUI::Util::createComboBox(item->detectorAlignmentSelection(), [=](int) { auto* m_combo = GUI::Util::createComboBox(item->detectorAlignmentSelection(), [=](int) {
createAligmentWidgets(); createAligmentWidgets();
emit dataChanged(); emit dataChanged();
}, false); });
m_formLayout->addRow("Alignment:", m_combo); m_formLayout->addRow("Alignment:", m_combo);
...@@ -73,9 +73,9 @@ DoubleSpinBox* DetectorAlignmentEditor::createSpinBox(QFormLayout* parentFormLay ...@@ -73,9 +73,9 @@ DoubleSpinBox* DetectorAlignmentEditor::createSpinBox(QFormLayout* parentFormLay
return sb; return sb;
} }
DoubleSpinBox* DetectorAlignmentEditor::createSpinBox(QWidget* parent, const DoubleDescriptor& d) DoubleSpinBox* DetectorAlignmentEditor::createSpinBox(const DoubleDescriptor& d)
{ {
auto* sb = new DoubleSpinBox(parent, d); auto* sb = new DoubleSpinBox(d);
connect(sb, &DoubleSpinBox::baseValueChanged, [=](double v) { connect(sb, &DoubleSpinBox::baseValueChanged, [=](double v) {
if (d.get() != v) { if (d.get() != v) {
d.set(v); d.set(v);
...@@ -91,7 +91,7 @@ void DetectorAlignmentEditor::addVector(QFormLayout* parentLayout, const VectorD ...@@ -91,7 +91,7 @@ void DetectorAlignmentEditor::addVector(QFormLayout* parentLayout, const VectorD
const auto add = [&](const DoubleDescriptor& d) { const auto add = [&](const DoubleDescriptor& d) {
layout->addWidget(new QLabel(GUI::Util::labelWithUnit(d) + ":")); layout->addWidget(new QLabel(GUI::Util::labelWithUnit(d) + ":"));
layout->addWidget(createSpinBox(parentLayout->parentWidget(), d)); layout->addWidget(createSpinBox(d));
}; };
add(d.x); add(d.x);
......
...@@ -38,7 +38,7 @@ signals: ...@@ -38,7 +38,7 @@ signals:
private: private:
void createAligmentWidgets(); void createAligmentWidgets();
DoubleSpinBox* createSpinBox(QFormLayout* parentFormLayout, const DoubleDescriptor& d); DoubleSpinBox* createSpinBox(QFormLayout* parentFormLayout, const DoubleDescriptor& d);
DoubleSpinBox* createSpinBox(QWidget* parent, const DoubleDescriptor& d); DoubleSpinBox* createSpinBox(const DoubleDescriptor& d);
void addVector(QFormLayout* parentLayout, const VectorDescriptor& d); void addVector(QFormLayout* parentLayout, const VectorDescriptor& d);
private: private:
......
...@@ -33,7 +33,7 @@ DetectorEditor::DetectorEditor(QWidget* parent, Instrument2DItem* instrument) ...@@ -33,7 +33,7 @@ DetectorEditor::DetectorEditor(QWidget* parent, Instrument2DItem* instrument)
auto* detectorTypeCombo = GUI::Util::createComboBox(instrument->detectorSelection(), [=](int) { auto* detectorTypeCombo = GUI::Util::createComboBox(instrument->detectorSelection(), [=](int) {
createDetectorWidgets(); createDetectorWidgets();
emit dataChanged(); emit dataChanged();
}, false); });
m_formLayout->addRow("Detector:", detectorTypeCombo); m_formLayout->addRow("Detector:", detectorTypeCombo);
GroupBoxCollapser::installIntoGroupBox(this); GroupBoxCollapser::installIntoGroupBox(this);
......
...@@ -48,7 +48,7 @@ DistributionSelector::DistributionSelector(std::optional<MeanConfig> mean_config ...@@ -48,7 +48,7 @@ DistributionSelector::DistributionSelector(std::optional<MeanConfig> mean_config
m_distributionCombo = GUI::Util::createComboBox(item->distributionSelection(), [=](int) { m_distributionCombo = GUI::Util::createComboBox(item->distributionSelection(), [=](int) {
createDistributionWidgets(); createDistributionWidgets();
emit distributionChanged(); emit distributionChanged();
}, false); });
m_formLayout->addRow("Distribution:", m_distributionCombo); m_formLayout->addRow("Distribution:", m_distributionCombo);
createDistributionWidgets(); createDistributionWidgets();
......
...@@ -32,7 +32,7 @@ EnvironmentEditor::EnvironmentEditor(QWidget* parent, InstrumentItem* instrument ...@@ -32,7 +32,7 @@ EnvironmentEditor::EnvironmentEditor(QWidget* parent, InstrumentItem* instrument
GUI::Util::createComboBox(instrument->backgroundSelection(), [=](int) { GUI::Util::createComboBox(instrument->backgroundSelection(), [=](int) {
createBackgroundWidgets(); createBackgroundWidgets();
emit dataChanged(); emit dataChanged();
}, false); });
m_formLayout->addRow("Background type:", backgroundTypeCombo); m_formLayout->addRow("Background type:", backgroundTypeCombo);
createBackgroundWidgets(); createBackgroundWidgets();
...@@ -46,7 +46,7 @@ void EnvironmentEditor::createBackgroundWidgets() ...@@ -46,7 +46,7 @@ void EnvironmentEditor::createBackgroundWidgets()
auto* backgroundItem = m_instrument->backgroundSelection().currentItem(); auto* backgroundItem = m_instrument->backgroundSelection().currentItem();
if (auto* p = dynamic_cast<ConstantBackgroundItem*>(backgroundItem)) { if (auto* p = dynamic_cast<ConstantBackgroundItem*>(backgroundItem)) {
auto* spinbox = new DoubleSpinBox(this, p->backgroundValue()); auto* spinbox = new DoubleSpinBox(p->backgroundValue());
spinbox->setSingleStep(0.01); spinbox->setSingleStep(0.01);
m_formLayout->addRow("Background value:", spinbox); m_formLayout->addRow("Background value:", spinbox);
......
...@@ -31,7 +31,7 @@ FootprintCorrectionEditor::FootprintCorrectionEditor(QWidget* parent, SpecularBe ...@@ -31,7 +31,7 @@ FootprintCorrectionEditor::FootprintCorrectionEditor(QWidget* parent, SpecularBe
auto* typeCombo = GUI::Util::createComboBox(item->footprintSelection(), [=](int) { auto* typeCombo = GUI::Util::createComboBox(item->footprintSelection(), [=](int) {
createFootprintWidgets(); createFootprintWidgets();
emit dataChanged(); emit dataChanged();
}, false); });
m_formLayout->addRow("Type:", typeCombo); m_formLayout->addRow("Type:", typeCombo);
GroupBoxCollapser::installIntoGroupBox(this); GroupBoxCollapser::installIntoGroupBox(this);
...@@ -46,7 +46,7 @@ void FootprintCorrectionEditor::createFootprintWidgets() ...@@ -46,7 +46,7 @@ void FootprintCorrectionEditor::createFootprintWidgets()
auto* footprintItem = m_item->footprintSelection().currentItem(); auto* footprintItem = m_item->footprintSelection().currentItem();
if (auto* square = dynamic_cast<FootprintSquareItem*>(footprintItem)) { if (auto* square = dynamic_cast<FootprintSquareItem*>(footprintItem)) {
auto* spinbox = new DoubleSpinBox(this, square->squareFootprintValue()); auto* spinbox = new DoubleSpinBox(square->squareFootprintValue());
spinbox->setSingleStep(0.01); spinbox->setSingleStep(0.01);
m_formLayout->addRow("Width ratio:", spinbox); m_formLayout->addRow("Width ratio:", spinbox);
connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) { connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) {
...@@ -54,7 +54,7 @@ void FootprintCorrectionEditor::createFootprintWidgets() ...@@ -54,7 +54,7 @@ void FootprintCorrectionEditor::createFootprintWidgets()
emit dataChanged(); emit dataChanged();
}); });
} else if (auto* gauss = dynamic_cast<FootprintGaussianItem*>(footprintItem)) { } else if (auto* gauss = dynamic_cast<FootprintGaussianItem*>(footprintItem)) {
auto* spinbox = new DoubleSpinBox(this, gauss->gaussianFootprintValue()); auto* spinbox = new DoubleSpinBox(gauss->gaussianFootprintValue());
spinbox->setSingleStep(0.01); spinbox->setSingleStep(0.01);
m_formLayout->addRow("Width ratio:", spinbox); m_formLayout->addRow("Width ratio:", spinbox);
connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) { connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) {
......
...@@ -40,10 +40,10 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Instrume ...@@ -40,10 +40,10 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Instrume
addVector(formlayout, m_instrument->polarization()); addVector(formlayout, m_instrument->polarization());
addVector(formlayout, m_instrument->analyzerDirection()); addVector(formlayout, m_instrument->analyzerDirection());
formlayout->addRow(GUI::Util::labelWithUnit(m_instrument->analyzerEfficiency()) + ":", formlayout->addRow(GUI::Util::labelWithUnit(m_instrument->analyzerEfficiency()) + ":",
createSpinBox(polarizerAnalyzerWidget, m_instrument->analyzerEfficiency())); createSpinBox(m_instrument->analyzerEfficiency()));
formlayout->addRow( formlayout->addRow(
GUI::Util::labelWithUnit(m_instrument->analyzerTotalTransmission()) + ":", GUI::Util::labelWithUnit(m_instrument->analyzerTotalTransmission()) + ":",
createSpinBox(polarizerAnalyzerWidget, m_instrument->analyzerTotalTransmission())); createSpinBox(m_instrument->analyzerTotalTransmission()));
layout->addWidget(polarizerAnalyzerWidget); layout->addWidget(polarizerAnalyzerWidget);
polarizerAnalyzerWidget->setVisible(m_instrument->withPolarizerAnalyzer()); polarizerAnalyzerWidget->setVisible(m_instrument->withPolarizerAnalyzer());
...@@ -57,9 +57,9 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Instrume ...@@ -57,9 +57,9 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Instrume
GroupBoxCollapser::installIntoGroupBox(this); GroupBoxCollapser::installIntoGroupBox(this);
} }
DoubleSpinBox* PolarizationAnalysisEditor::createSpinBox(QWidget* parent, const DoubleDescriptor& d) DoubleSpinBox* PolarizationAnalysisEditor::createSpinBox(const DoubleDescriptor& d)
{ {
auto* sb = new DoubleSpinBox(parent, d); auto* sb = new DoubleSpinBox(d);
connect(sb, &DoubleSpinBox::baseValueChanged, [=](double v) { connect(sb, &DoubleSpinBox::baseValueChanged, [=](double v) {
if (d.get() != v) { if (d.get() != v) {
d.set(v); d.set(v);
...@@ -75,7 +75,7 @@ void PolarizationAnalysisEditor::addVector(QFormLayout* parentLayout, const Vect ...@@ -75,7 +75,7 @@ void PolarizationAnalysisEditor::addVector(QFormLayout* parentLayout, const Vect
const auto add = [&](const DoubleDescriptor& d) { const auto add = [&](const DoubleDescriptor& d) {
layout->addWidget(new QLabel(GUI::Util::labelWithUnit(d) + ":")); layout->addWidget(new QLabel(GUI::Util::labelWithUnit(d) + ":"));
layout->addWidget(createSpinBox(parentLayout->parentWidget(), d)); layout->addWidget(createSpinBox(d));
}; };
add(d.x); add(d.x);
......
...@@ -36,7 +36,7 @@ signals: ...@@ -36,7 +36,7 @@ signals:
void dataChanged(); void dataChanged();
private: private:
DoubleSpinBox* createSpinBox(QWidget* parent, const DoubleDescriptor& d); DoubleSpinBox* createSpinBox(const DoubleDescriptor& d);
void addVector(QFormLayout* parentLayout, const VectorDescriptor& d); void addVector(QFormLayout* parentLayout, const VectorDescriptor& d);
InstrumentItem* m_instrument; InstrumentItem* m_instrument;
......
...@@ -47,7 +47,7 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent, ...@@ -47,7 +47,7 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent,
xAxisNbinsSpinBox->setValue(detector->xSize()); xAxisNbinsSpinBox->setValue(detector->xSize());
xAxisFormLayout->addRow("Nbins:", xAxisNbinsSpinBox); xAxisFormLayout->addRow("Nbins:", xAxisNbinsSpinBox);
auto* widthSpinBox = new DoubleSpinBox(xAxisGroupBox, detector->width()); auto* widthSpinBox = new DoubleSpinBox(detector->width());
xAxisFormLayout->addRow("Width [mm]:", widthSpinBox); xAxisFormLayout->addRow("Width [mm]:", widthSpinBox);
connect(xAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) { connect(xAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) {
...@@ -74,7 +74,7 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent, ...@@ -74,7 +74,7 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent,
yAxisNbinsSpinBox->setValue(detector->ySize()); yAxisNbinsSpinBox->setValue(detector->ySize());
yAxisFormLayout->addRow("Nbins:", yAxisNbinsSpinBox); yAxisFormLayout->addRow("Nbins:", yAxisNbinsSpinBox);
auto* heightSpinBox = new DoubleSpinBox(yAxisGroupBox, detector->height()); auto* heightSpinBox = new DoubleSpinBox(detector->height());
yAxisFormLayout->addRow("Height [mm]:", heightSpinBox); yAxisFormLayout->addRow("Height [mm]:", heightSpinBox);
connect(yAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) { connect(yAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) {
......
...@@ -35,7 +35,7 @@ ResolutionFunctionEditor::ResolutionFunctionEditor(Unit unit, QWidget* parent, D ...@@ -35,7 +35,7 @@ ResolutionFunctionEditor::ResolutionFunctionEditor(Unit unit, QWidget* parent, D
GUI::Util::createComboBox(item->resolutionFunctionSelection(), [=](int) { GUI::Util::createComboBox(item->resolutionFunctionSelection(), [=](int) {
createResolutionWidgets(); createResolutionWidgets();
emit dataChanged(); emit dataChanged();
}, false); });
m_formLayout->addRow("Type:", typeCombo); m_formLayout->addRow("Type:", typeCombo);
GroupBoxCollapser::installIntoGroupBox(this); GroupBoxCollapser::installIntoGroupBox(this);
......
...@@ -22,7 +22,7 @@ SphericalAxisForm::SphericalAxisForm(QFormLayout* form, QWidget* parent) ...@@ -22,7 +22,7 @@ SphericalAxisForm::SphericalAxisForm(QFormLayout* form, QWidget* parent)
: QObject(parent) : QObject(parent)
, m_item(nullptr) , m_item(nullptr)
{ {
m_nbinsSpinBox = new SafeSpinBox(false); m_nbinsSpinBox = new SafeSpinBox;
m_nbinsSpinBox->setRange(1, 65536); m_nbinsSpinBox->setRange(1, 65536);
connect(m_nbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), this, connect(m_nbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), this,
&SphericalAxisForm::onNbinsValueChanged); &SphericalAxisForm::onNbinsValueChanged);
......
...@@ -222,7 +222,7 @@ void MaskEditorPropertyPanel::createMaskEditorUI() ...@@ -222,7 +222,7 @@ void MaskEditorPropertyPanel::createMaskEditorUI()
void MaskEditorPropertyPanel::addMaskSpinBox(DoubleDescriptor d) void MaskEditorPropertyPanel::addMaskSpinBox(DoubleDescriptor d)
{ {
auto* spinBox = new DoubleSpinBox(m_maskPropertiesLayout->parentWidget(), d); auto* spinBox = new DoubleSpinBox(d);
spinBox->setBaseValue(d.get()); spinBox->setBaseValue(d.get());
QObject::connect(spinBox, &DoubleSpinBox::baseValueChanged, QObject::connect(spinBox, &DoubleSpinBox::baseValueChanged,
[=](double newValue) { d.set(newValue); }); [=](double newValue) { d.set(newValue); });
......
...@@ -73,11 +73,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items) ...@@ -73,11 +73,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
if (!first_item) if (!first_item)
return; return;
m_mainLayout->addRow("Axes units:", GUI::Util::createComboBox( m_mainLayout->addRow("Axes units:", GUI::Util::createComboBoxUpdScroll(
first_item->axesUnits(), &m_updaters, first_item->axesUnits(), &m_updaters,
[=](int newIndex) { FOR_OTHER_ITEMS item->axesUnits().setCurrentIndex(newIndex); })); [=](int newIndex) { FOR_OTHER_ITEMS item->axesUnits().setCurrentIndex(newIndex); }));
m_mainLayout->addRow("Color scheme:", GUI::Util::createComboBox( m_mainLayout->addRow("Color scheme:", GUI::Util::createComboBoxUpdScroll(
first_item->gradient(), &m_updaters, first_item->gradient(), &m_updaters,
[=](int newIndex) { FOR_OTHER_ITEMS item->gradient().setCurrentIndex(newIndex); })); [=](int newIndex) { FOR_OTHER_ITEMS item->gradient().setCurrentIndex(newIndex); }));
...@@ -92,11 +92,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items) ...@@ -92,11 +92,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
xFormLayout->setContentsMargins(0, 0, 0, 0); xFormLayout->setContentsMargins(0, 0, 0, 0);
xFormLayout->setSpacing(5); xFormLayout->setSpacing(5);
xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox( xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
first_item->xAxisItem()->min(), &m_updaters, first_item->xAxisItem()->min(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->min().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->min().set(newValue); }));
xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox( xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
first_item->xAxisItem()->max(), &m_updaters, first_item->xAxisItem()->max(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->max().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->max().set(newValue); }));
...@@ -113,11 +113,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items) ...@@ -113,11 +113,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
yFormLayout->setContentsMargins(0, 0, 0, 0); yFormLayout->setContentsMargins(0, 0, 0, 0);
yFormLayout->setSpacing(5); yFormLayout->setSpacing(5);
yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox( yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
first_item->yAxisItem()->min(), &m_updaters, first_item->yAxisItem()->min(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->min().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->min().set(newValue); }));
yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox( yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
first_item->yAxisItem()->max(), &m_updaters, first_item->yAxisItem()->max(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->max().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->max().set(newValue); }));
...@@ -134,11 +134,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items) ...@@ -134,11 +134,11 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> items)
zFormLayout->setContentsMargins(0, 0, 0, 0); zFormLayout->setContentsMargins(0, 0, 0, 0);
zFormLayout->setSpacing(5); zFormLayout->setSpacing(5);
zFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox( zFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
first_item->zAxisItem()->min(), &m_updaters, first_item->zAxisItem()->min(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->zAxisItem()->min().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->zAxisItem()->min().set(newValue); }));
zFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox( zFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
first_item->zAxisItem()->max(), &m_updaters, first_item->zAxisItem()->max(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->zAxisItem()->max().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->zAxisItem()->max().set(newValue); }));
......
...@@ -77,7 +77,7 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items) ...@@ -77,7 +77,7 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items)
if (!first_item) if (!first_item)
return; return;
m_mainLayout->addRow("Axes units:", GUI::Util::createComboBox( m_mainLayout->addRow("Axes units:", GUI::Util::createComboBoxUpdScroll(
first_item->axesUnits(), &m_updaters, first_item->axesUnits(), &m_updaters,
[=](int newIndex) { FOR_OTHER_ITEMS item->axesUnits().setCurrentIndex(newIndex); })); [=](int newIndex) { FOR_OTHER_ITEMS item->axesUnits().setCurrentIndex(newIndex); }));
...@@ -87,11 +87,11 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items) ...@@ -87,11 +87,11 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items)
xFormLayout->setContentsMargins(0, 0, 0, 0); xFormLayout->setContentsMargins(0, 0, 0, 0);
xFormLayout->setSpacing(5); xFormLayout->setSpacing(5);
xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox( xFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
first_item->xAxisItem()->min(), &m_updaters, first_item->xAxisItem()->min(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->min().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->min().set(newValue); }));
xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox( xFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
first_item->xAxisItem()->max(), &m_updaters, first_item->xAxisItem()->max(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->max().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->xAxisItem()->max().set(newValue); }));
...@@ -108,11 +108,11 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items) ...@@ -108,11 +108,11 @@ void SpecularDataPropertyWidget::setItem(QVector<SpecularDataItem*> items)
yFormLayout->setContentsMargins(0, 0, 0, 0); yFormLayout->setContentsMargins(0, 0, 0, 0);
yFormLayout->setSpacing(5); yFormLayout->setSpacing(5);
yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinbox( yFormLayout->addRow("Min:", GUI::Util::createDoubleSpinboxScroll(
first_item->yAxisItem()->min(), &m_updaters, first_item->yAxisItem()->min(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->min().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->min().set(newValue); }));
yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinbox( yFormLayout->addRow("Max:", GUI::Util::createDoubleSpinboxScroll(
first_item->yAxisItem()->max(), &m_updaters, first_item->yAxisItem()->max(), &m_updaters,
[=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->max().set(newValue); })); [=](double newValue) { FOR_OTHER_ITEMS item->yAxisItem()->max().set(newValue); }));
......
...@@ -183,7 +183,7 @@ void FormLayouter::insertValue(int row, const DoubleDescriptor& d, ...@@ -183,7 +183,7 @@ void FormLayouter::insertValue(int row, const DoubleDescriptor& d,
label->setAlignment(Qt::AlignLeft | Qt::AlignBottom); label->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
auto* editor = new DoubleSpinBox(m_formLayout->parentWidget(), d); auto* editor = new DoubleSpinBox(d);
QObject::connect(editor, &DoubleSpinBox::baseValueChanged, onValueChange); QObject::connect(editor, &DoubleSpinBox::baseValueChanged, onValueChange);
label->setBuddy(editor); label->setBuddy(editor);
......
...@@ -83,7 +83,7 @@ void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int fir ...@@ -83,7 +83,7 @@ void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int fir
{ {
int col = firstCol; int col = firstCol;
for (const auto& valueDescriptor : valueDescriptors) { for (const auto& valueDescriptor : valueDescriptors) {
auto* editor = new DoubleSpinBox(m_gridLayout->parentWidget(), valueDescriptor); auto* editor = new DoubleSpinBox(valueDescriptor);
QObject::connect(editor, &DoubleSpinBox::baseValueChanged, QObject::connect(editor, &DoubleSpinBox::baseValueChanged,
[=](double newValue) { setNewValue(newValue, valueDescriptor); }); [=](double newValue) { setNewValue(newValue, valueDescriptor); });
......
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