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

w/o QOverload

parent 2614fedb
No related branches found
No related tags found
1 merge request!2260simplifications discovered while reviewing signals
Pipeline #124497 passed
......@@ -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("");
......
......@@ -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(); });
}
......
......@@ -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);
......
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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()
......
......@@ -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);
......
......@@ -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();
......
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