From e6cf186c231d0dc7b7a2236483e6d90531b8a51c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 19 Dec 2020 16:03:54 +0800 Subject: [PATCH] Use function-pointer based signal-slot connection --- src/app/qtlocalpeer/qtlocalpeer.cpp | 2 +- src/gui/advancedsettings.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/qtlocalpeer/qtlocalpeer.cpp b/src/app/qtlocalpeer/qtlocalpeer.cpp index c7461b0aa..e8345bcd7 100644 --- a/src/app/qtlocalpeer/qtlocalpeer.cpp +++ b/src/app/qtlocalpeer/qtlocalpeer.cpp @@ -152,7 +152,7 @@ bool QtLocalPeer::isClient() #endif if (!res) qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); - QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); + connect(server, &QLocalServer::newConnection, this, &QtLocalPeer::receiveConnection); return false; } diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 7e7f82df0..dd9304157 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -715,12 +715,12 @@ void AdvancedSettings::addRow(const int row, const QString &text, T *widget) setCellWidget(row, PROPERTY, label); setCellWidget(row, VALUE, widget); - if (std::is_same_v) - connect(widget, SIGNAL(stateChanged(int)), this, SIGNAL(settingsChanged())); - else if (std::is_same_v) - connect(widget, SIGNAL(valueChanged(int)), this, SIGNAL(settingsChanged())); - else if (std::is_same_v) - connect(widget, SIGNAL(currentIndexChanged(int)), this, SIGNAL(settingsChanged())); - else if (std::is_same_v) - connect(widget, SIGNAL(textChanged(QString)), this, SIGNAL(settingsChanged())); + if constexpr (std::is_same_v) + connect(widget, &QCheckBox::stateChanged, this, &AdvancedSettings::settingsChanged); + else if constexpr (std::is_same_v) + connect(widget, qOverload(&QSpinBox::valueChanged), this, &AdvancedSettings::settingsChanged); + else if constexpr (std::is_same_v) + connect(widget, qOverload(&QComboBox::currentIndexChanged), this, &AdvancedSettings::settingsChanged); + else if constexpr (std::is_same_v) + connect(widget, &QLineEdit::textChanged, this, &AdvancedSettings::settingsChanged); }