From ed44806212c503d949bf9c8c2bb7588260b01744 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 21 Dec 2023 09:59:33 +0100 Subject: [PATCH] w/o QOverload --- GUI/View/Main/ActionManager.cpp | 2 +- GUI/View/Project/SimulationView.cpp | 5 ++-- GUI/View/Realspace/RealspacePanel.cpp | 2 +- GUI/View/Realspace/RealspaceWidget.cpp | 31 ++++++++++-------------- GUI/View/Realspace/RealspaceWidget.h | 2 -- GUI/View/Sample/CoreAndShellForm.cpp | 4 +-- GUI/View/Sample/InterferenceForm.cpp | 2 +- GUI/View/Sample/MesocrystalForm.cpp | 2 +- GUI/View/Sample/SelectionContainerForm.h | 9 +++---- 9 files changed, 25 insertions(+), 34 deletions(-) diff --git a/GUI/View/Main/ActionManager.cpp b/GUI/View/Main/ActionManager.cpp index d651b1891d3..c5945c3b7dd 100644 --- a/GUI/View/Main/ActionManager.cpp +++ b/GUI/View/Main/ActionManager.cpp @@ -237,7 +237,7 @@ void ActionManager::onAboutToShowSettingsMenu() auto* styleGroup = new QButtonGroup(this); styleGroup->setExclusive(true); const auto addStyleAction = [styleGroup, styleMenu](const QString& text, - ApplicationSettings::Style style) { + ApplicationSettings::Style style) { auto* action = new QWidgetAction(styleMenu); auto* radioButton = new QRadioButton(text, styleMenu); radioButton->setStyleSheet(""); diff --git a/GUI/View/Project/SimulationView.cpp b/GUI/View/Project/SimulationView.cpp index 6a8e377fe04..343406dcb19 100644 --- a/GUI/View/Project/SimulationView.cpp +++ b/GUI/View/Project/SimulationView.cpp @@ -156,11 +156,10 @@ SimulationView::SimulationView(QWidget* parent, ProjectDocument* document) connect(m_averageLayerRadio, &QRadioButton::toggled, [this] { updateStateFromUI(); }); - connect(m_numberOfThreadsCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + connect(m_numberOfThreadsCombo, &QComboBox::currentIndexChanged, [this] { updateStateFromUI(); }); - connect(m_numberOfMonteCarloPoints, QOverload<int>::of(&QSpinBox::valueChanged), - [this] { updateStateFromUI(); }); + connect(m_numberOfMonteCarloPoints, &QSpinBox::valueChanged, [this] { updateStateFromUI(); }); connect(m_includeSpecularCheck, &QCheckBox::toggled, [this] { updateStateFromUI(); }); } diff --git a/GUI/View/Realspace/RealspacePanel.cpp b/GUI/View/Realspace/RealspacePanel.cpp index 23c65f294a7..42a3bf6f1c7 100644 --- a/GUI/View/Realspace/RealspacePanel.cpp +++ b/GUI/View/Realspace/RealspacePanel.cpp @@ -35,7 +35,7 @@ RealspacePanel::RealspacePanel(QWidget* parent) }; auto* action = createAction("Save Picture", "Save 3D real space view as .png file"); - connect(action, &QAction::triggered, m_widget, QOverload<>::of(&RealspaceWidget::savePicture)); + connect(action, &QAction::triggered, m_widget, &RealspaceWidget::savePicture); action = createAction("Default View", "Reset view and zoom level to default"); connect(action, &QAction::triggered, m_widget, &RealspaceWidget::defaultView); diff --git a/GUI/View/Realspace/RealspaceWidget.cpp b/GUI/View/Realspace/RealspaceWidget.cpp index 6be4c06cbf6..1f9631cacd4 100644 --- a/GUI/View/Realspace/RealspaceWidget.cpp +++ b/GUI/View/Realspace/RealspaceWidget.cpp @@ -68,13 +68,6 @@ void RealspaceWidget::changeLayerSize(double layerSizeChangeScale) updateScene(); } -void RealspaceWidget::savePicture() -{ - QPixmap pixmap(this->size()); - render(&pixmap, QPoint(), childrenRegion()); - savePicture(pixmap); -} - void RealspaceWidget::showEvent(QShowEvent*) { updateScene(); @@ -83,7 +76,7 @@ void RealspaceWidget::showEvent(QShowEvent*) m_firstView = false; } -void RealspaceWidget::savePicture(const QPixmap& pixmap) +void RealspaceWidget::savePicture() { ASSERT(gProjectDocument.has_value()); QString dirname = gProjectDocument.value()->userExportDir(); @@ -95,17 +88,19 @@ void RealspaceWidget::savePicture(const QPixmap& pixmap) appSettings->useNativeFileDialog() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog); QString nameToSave = fname.endsWith(defaultExtension) ? fname : fname + defaultExtension; + if (nameToSave.isEmpty()) + return; - if (!nameToSave.isEmpty()) { - try { - pixmap.save(nameToSave); - } catch (const std::exception& ex) { - QString message = "Attempt to save file with the name '"; - message.append(nameToSave); - message.append("' has failed with following error message\n\n"); - message.append(QString::fromStdString(ex.what())); - QMessageBox::warning(nullptr, "Houston, we have a problem.", message); - } + QPixmap pixmap(this->size()); + render(&pixmap, QPoint(), childrenRegion()); + try { + pixmap.save(nameToSave); + } catch (const std::exception& ex) { + QString message = "Attempt to save file with the name '"; + message.append(nameToSave); + message.append("' has failed with following error message\n\n"); + message.append(QString::fromStdString(ex.what())); + QMessageBox::warning(nullptr, "Houston, we have a problem.", message); } } diff --git a/GUI/View/Realspace/RealspaceWidget.h b/GUI/View/Realspace/RealspaceWidget.h index 317103bc130..2fe879275b8 100644 --- a/GUI/View/Realspace/RealspaceWidget.h +++ b/GUI/View/Realspace/RealspaceWidget.h @@ -50,8 +50,6 @@ protected: void showEvent(QShowEvent*) override; private: - void savePicture(const QPixmap& pixmap); - Img3D::Canvas* m_canvas; std::unique_ptr<Img3D::Model> m_realspaceModel; SceneGeometry m_sceneGeometry; diff --git a/GUI/View/Sample/CoreAndShellForm.cpp b/GUI/View/Sample/CoreAndShellForm.cpp index 71efe3d2440..6af5147cbbc 100644 --- a/GUI/View/Sample/CoreAndShellForm.cpp +++ b/GUI/View/Sample/CoreAndShellForm.cpp @@ -70,7 +70,7 @@ CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* coreShellI coreParticleGroup, coreShellItem->coreItem() != nullptr ? coreShellItem->coreItem()->formFactorItem() : nullptr); - connect(core.formfactorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + connect(core.formfactorCombo, &QComboBox::currentIndexChanged, this, &CoreAndShellForm::onCoreComboChanged); core.layout->addBoldRow("Form factor:", core.formfactorCombo); @@ -98,7 +98,7 @@ CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* coreShellI shellParticleGroup, coreShellItem->shellItem() != nullptr ? coreShellItem->shellItem()->formFactorItem() : nullptr); - connect(shell.formfactorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + connect(shell.formfactorCombo, &QComboBox::currentIndexChanged, this, &CoreAndShellForm::onShellComboChanged); shell.layout->addBoldRow("Form factor:", shell.formfactorCombo); diff --git a/GUI/View/Sample/InterferenceForm.cpp b/GUI/View/Sample/InterferenceForm.cpp index c60f9c8d4c1..ce0e5dfa87a 100644 --- a/GUI/View/Sample/InterferenceForm.cpp +++ b/GUI/View/Sample/InterferenceForm.cpp @@ -43,7 +43,7 @@ InterferenceForm::InterferenceForm(QWidget* parent, ParticleLayoutItem* layoutIt createInterferenceWidgets(); updateTitle(); - connect(m_interferenceTypeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), + connect(m_interferenceTypeCombo, &QComboBox::currentIndexChanged, [this](int newIndex) { m_ec->selectInterference(this, newIndex); }); } void InterferenceForm::onInterferenceTypeChanged() diff --git a/GUI/View/Sample/MesocrystalForm.cpp b/GUI/View/Sample/MesocrystalForm.cpp index 596316c8843..e076fc1bee4 100644 --- a/GUI/View/Sample/MesocrystalForm.cpp +++ b/GUI/View/Sample/MesocrystalForm.cpp @@ -43,7 +43,7 @@ MesocrystalForm::MesocrystalForm(QWidget* parent, MesocrystalItem* mesocrystalIt m_layout->addSelection(mesocrystalItem->outerShapeSelection()); - connect(m_basisCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + connect(m_basisCombo, &QComboBox::currentIndexChanged, this, &MesocrystalForm::onBasisComboChanged); m_layout->addBoldRow("Basis type", m_basisCombo); diff --git a/GUI/View/Sample/SelectionContainerForm.h b/GUI/View/Sample/SelectionContainerForm.h index 7af5ede988f..c8d594302ed 100644 --- a/GUI/View/Sample/SelectionContainerForm.h +++ b/GUI/View/Sample/SelectionContainerForm.h @@ -46,11 +46,10 @@ protected: m_combo->setCurrentIndex(d.currentIndex()); m_combo->setMaxVisibleItems(m_combo->count()); - QObject::connect(m_combo, &QComboBox::currentIndexChanged, - [this, &d](int current) { - clear(); - m_ec->setCurrentIndex(this, current, d); - }); + QObject::connect(m_combo, &QComboBox::currentIndexChanged, [this, &d](int current) { + clear(); + m_ec->setCurrentIndex(this, current, d); + }); m_gridLayout->addWidget(m_combo, 1, 0); createContent(); -- GitLab