From 8a643bee16e67195193d74da16f30a0b02d76039 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 1 Jan 2023 12:40:07 +0100 Subject: [PATCH] Gui: switch to new-style connect in order to find build failures with Qt6 --- src/Gui/MainWindow.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 6bbc6098fb..7c53b25b0e 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -290,7 +290,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) setCentralWidget(d->mdiArea); statusBar()->setObjectName(QString::fromLatin1("statusBar")); - connect(statusBar(), SIGNAL(messageChanged(const QString &)), this, SLOT(statusMessageChanged())); + connect(statusBar(), &QStatusBar::messageChanged, this, &MainWindow::statusMessageChanged); // labels and progressbar d->status = new StatusBarObserver(); @@ -306,31 +306,38 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) // clears the action label d->actionTimer = new QTimer( this ); d->actionTimer->setObjectName(QString::fromLatin1("actionTimer")); - connect(d->actionTimer, SIGNAL(timeout()), d->actionLabel, SLOT(clear())); + connect(d->actionTimer, &QTimer::timeout, d->actionLabel, &QLabel::clear); // clear status type d->statusTimer = new QTimer( this ); d->statusTimer->setObjectName(QString::fromLatin1("statusTimer")); - connect(d->statusTimer, SIGNAL(timeout()), this, SLOT(clearStatus())); + connect(d->statusTimer, &QTimer::timeout, this, &MainWindow::clearStatus); // update gui timer d->activityTimer = new QTimer(this); d->activityTimer->setObjectName(QString::fromLatin1("activityTimer")); - connect(d->activityTimer, SIGNAL(timeout()),this, SLOT(_updateActions())); + connect(d->activityTimer, &QTimer::timeout, this, &MainWindow::_updateActions); d->activityTimer->setSingleShot(false); d->activityTimer->start(150); // update view-sensitive commands when clipboard has changed QClipboard *clipbd = QApplication::clipboard(); - connect(clipbd, SIGNAL(dataChanged()), this, SLOT(updateEditorActions())); + connect(clipbd, &QClipboard::dataChanged, this, &MainWindow::updateEditorActions); d->windowMapper = new QSignalMapper(this); // connection between workspace, window menu and tab bar - connect(d->windowMapper, SIGNAL(mapped(QWidget *)), - this, SLOT(onSetActiveSubWindow(QWidget*))); - connect(d->mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), - this, SLOT(onWindowActivated(QMdiSubWindow* ))); +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) + connect(d->windowMapper, qOverload(&QSignalMapper::mapped), + this, &MainWindow::onSetActiveSubWindow); +#else + connect(d->windowMapper, &QSignalMapper::mappedObject, + this, [=](QObject* object) { + onSetActiveSubWindow(qobject_cast(object)); + }); +#endif + connect(d->mdiArea, &QMdiArea::subWindowActivated, + this, &MainWindow::onWindowActivated); setupDockWindows(); @@ -944,7 +951,7 @@ void MainWindow::addWindow(MDIView* view) } QAction* action = menu->addAction(tr("Close All")); - connect(action, SIGNAL(triggered()), d->mdiArea, SLOT(closeAllSubWindows())); + connect(action, &QAction::triggered, d->mdiArea, &QMdiArea::closeAllSubWindows); d->mdiArea->addSubWindow(child); } @@ -1105,7 +1112,7 @@ void MainWindow::onWindowsMenuAboutToShow() for (const auto & action : actions) { if (action == last) break; // this is a separator - connect(action, SIGNAL(triggered()), d->windowMapper, SLOT(map())); + connect(action, &QAction::triggered, d->windowMapper, qOverload<>(&QSignalMapper::map)); } }