modernize: Require member function pointers for Settings::notify()
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 19 Sep 2018 22:54:21 +0000 (00:54 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 10:06:43 +0000 (11:06 +0100)
Require member function pointers for Settings::notify() and
Settings::initAndNotify(). This brings us one step closer to being
SLOT-free.

26 files changed:
src/client/clientsettings.cpp
src/client/clientsettings.h
src/client/clientuserinputhandler.cpp
src/client/coreconnection.cpp
src/client/messagefilter.cpp
src/client/networkmodel.cpp
src/common/settings.cpp
src/common/settings.h
src/qtui/bufferwidget.cpp
src/qtui/chatmonitorfilter.cpp
src/qtui/chatscene.cpp
src/qtui/dockmanagernotificationbackend.cpp
src/qtui/inputwidget.cpp
src/qtui/osxnotificationbackend.mm
src/qtui/qtmultimedianotificationbackend.cpp
src/qtui/qtui.cpp
src/qtui/qtuimessageprocessor.cpp
src/qtui/qtuistyle.cpp
src/qtui/snorenotificationbackend.cpp
src/qtui/systemtray.cpp
src/qtui/systrayanimationnotificationbackend.cpp
src/qtui/systraynotificationbackend.cpp
src/qtui/taskbarnotificationbackend.cpp
src/qtui/topicwidget.cpp
src/uisupport/bufferviewfilter.cpp
src/uisupport/uistyle.cpp

index 87c0fc5..3586093 100644 (file)
@@ -46,9 +46,9 @@ CoreAccountSettings::CoreAccountSettings(QString subgroup)
 }
 
 
-void CoreAccountSettings::notify(const QString &key, QObject *receiver, const char *slot) const
+QString CoreAccountSettings::keyForNotify(const QString &key) const
 {
-    ClientSettings::notify(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), receiver, slot);
+    return QString{"%1/%2/%3"}.arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key);
 }
 
 
index 6c984ed..de5633a 100644 (file)
@@ -54,8 +54,6 @@ public:
     // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
     CoreAccountSettings(QString subgroup = "General");
 
-    void notify(const QString &key, QObject *receiver, const char *slot) const;  // shadows Settings::notify()
-
     QList<AccountId> knownAccounts() const;
     AccountId lastAccount() const;
     void setLastAccount(AccountId);
@@ -81,6 +79,9 @@ public:
     void setAccountValue(const QString &key, const QVariant &data);
     QVariant accountValue(const QString &key, const QVariant &def = QVariant()) const;
 
+protected:
+    QString keyForNotify(const QString &key) const override;
+
 private:
     QString _subgroup;
 };
index 7179515..9315a5e 100644 (file)
@@ -41,7 +41,7 @@ ClientUserInputHandler::ClientUserInputHandler(QObject *parent)
     : BasicHandler(parent)
 {
     TabCompletionSettings s;
-    s.notify("CompletionSuffix", this, SLOT(completionSuffixChanged(QVariant)));
+    s.notify("CompletionSuffix", this, &ClientUserInputHandler::completionSuffixChanged);
     completionSuffixChanged(s.completionSuffix());
 }
 
index e41ccdc..3c62fca 100644 (file)
@@ -54,9 +54,9 @@ void CoreConnection::init()
     connect(_qNetworkConfigurationManager.data(), &QNetworkConfigurationManager::onlineStateChanged, this, &CoreConnection::onlineStateChanged);
 
     CoreConnectionSettings s;
-    s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60);
-    s.initAndNotify("ReconnectInterval", this, SLOT(reconnectIntervalChanged(QVariant)), 60);
-    s.notify("NetworkDetectionMode", this, SLOT(networkDetectionModeChanged(QVariant)));
+    s.initAndNotify("PingTimeoutInterval", this, &CoreConnection::pingTimeoutIntervalChanged, 60);
+    s.initAndNotify("ReconnectInterval", this, &CoreConnection::reconnectIntervalChanged, 60);
+    s.notify("NetworkDetectionMode", this, &CoreConnection::networkDetectionModeChanged);
     networkDetectionModeChanged(s.networkDetectionMode());
 }
 
index fd6e78b..18aedd2 100644 (file)
@@ -55,19 +55,19 @@ void MessageFilter::init()
     _userNoticesTarget = _serverNoticesTarget = _errorMsgsTarget = -1;
 
     BufferSettings defaultSettings;
-    defaultSettings.notify("UserNoticesTarget", this, SLOT(messageRedirectionChanged()));
-    defaultSettings.notify("ServerNoticesTarget", this, SLOT(messageRedirectionChanged()));
-    defaultSettings.notify("ErrorMsgsTarget", this, SLOT(messageRedirectionChanged()));
+    defaultSettings.notify("UserNoticesTarget", this, &MessageFilter::messageRedirectionChanged);
+    defaultSettings.notify("ServerNoticesTarget", this, &MessageFilter::messageRedirectionChanged);
+    defaultSettings.notify("ErrorMsgsTarget", this, &MessageFilter::messageRedirectionChanged);
     messageRedirectionChanged();
 
     _messageTypeFilter = defaultSettings.messageFilter();
-    defaultSettings.notify("MessageTypeFilter", this, SLOT(messageTypeFilterChanged()));
+    defaultSettings.notify("MessageTypeFilter", this, &MessageFilter::messageTypeFilterChanged);
 
     BufferSettings mySettings(MessageFilter::idString());
     if (mySettings.hasFilter())
         _messageTypeFilter = mySettings.messageFilter();
-    mySettings.notify("MessageTypeFilter", this, SLOT(messageTypeFilterChanged()));
-    mySettings.notify("hasMessageTypeFilter", this, SLOT(messageTypeFilterChanged()));
+    mySettings.notify("MessageTypeFilter", this, &MessageFilter::messageTypeFilterChanged);
+    mySettings.notify("hasMessageTypeFilter", this, &MessageFilter::messageTypeFilterChanged);
 }
 
 
index 223e09c..1241020 100644 (file)
@@ -1284,9 +1284,9 @@ NetworkModel::NetworkModel(QObject *parent)
     connect(this, &NetworkModel::rowsAboutToBeRemoved, this, &NetworkModel::checkForRemovedBuffers);
 
     BufferSettings defaultSettings;
-    defaultSettings.notify("UserNoticesTarget", this, SLOT(messageRedirectionSettingsChanged()));
-    defaultSettings.notify("ServerNoticesTarget", this, SLOT(messageRedirectionSettingsChanged()));
-    defaultSettings.notify("ErrorMsgsTarget", this, SLOT(messageRedirectionSettingsChanged()));
+    defaultSettings.notify("UserNoticesTarget", this, &NetworkModel::messageRedirectionSettingsChanged);
+    defaultSettings.notify("ServerNoticesTarget", this, &NetworkModel::messageRedirectionSettingsChanged);
+    defaultSettings.notify("ErrorMsgsTarget", this, &NetworkModel::messageRedirectionSettingsChanged);
     messageRedirectionSettingsChanged();
 }
 
index 868628a..f157d35 100644 (file)
@@ -49,17 +49,9 @@ void Settings::setGroup(QString group) {
 }
 
 
-void Settings::notify(const QString &key, QObject *receiver, const char *slot) const
+QString Settings::keyForNotify(const QString &key) const
 {
-    QObject::connect(notifier(normalizedKey(_group, key)), SIGNAL(valueChanged(const QVariant &)),
-        receiver, slot);
-}
-
-
-void Settings::initAndNotify(const QString &key, QObject *receiver, const char *slot, const QVariant &defaultValue) const
-{
-    notify(key, receiver, slot);
-    emit notifier(normalizedKey(_group, key))->valueChanged(localValue(key, defaultValue));
+    return key;
 }
 
 
index 48dfafd..64bc462 100644 (file)
@@ -23,6 +23,7 @@
 #include "common-export.h"
 
 #include <memory>
+#include <type_traits>
 
 #include <QCoreApplication>
 #include <QHash>
@@ -51,11 +52,22 @@ public:
     enum Mode { Default, Custom };
 
 public:
-    //! Call the given slot on change of the given key
-    void notify(const QString &key, QObject *receiver, const char *slot) const;
+    //! Calls the given slot on change of the given key
+    template<typename Receiver, typename Slot>
+    void notify(const QString &key, const Receiver *receiver, Slot slot) const
+    {
+        static_assert(!std::is_same<Slot, const char*>::value, "Old-style slots not supported");
+        QObject::connect(notifier(normalizedKey(_group, keyForNotify(key))), &SettingsChangeNotifier::valueChanged, receiver, slot);
+    }
 
     //! Sets up notification and calls the given slot to set the initial value
-    void initAndNotify(const QString &key, QObject *receiver, const char *slot, const QVariant &defaultValue = QVariant()) const;
+    template<typename Receiver, typename Slot>
+    void initAndNotify(const QString &key, const Receiver *receiver, Slot slot, const QVariant &defaultValue = {}) const
+    {
+        notify(key, receiver, std::move(slot));
+        auto notifyKey = keyForNotify(key);
+        emit notifier(normalizedKey(_group, notifyKey))->valueChanged(localValue(notifyKey, defaultValue));
+    }
 
     /**
      * Get the major configuration version
@@ -107,6 +119,16 @@ protected:
 
     void setGroup(QString group);
 
+    /**
+     * Allows subclasses to transform the key given to notify().
+     *
+     * Default implementation just returns the given key.
+     *
+     * @param key Key given to notify()
+     * @returns Key that should be used for notfication
+     */
+    virtual QString keyForNotify(const QString &key) const;
+
     virtual QStringList allLocalKeys() const;
     virtual QStringList localChildKeys(const QString &rootkey = QString()) const;
     virtual QStringList localChildGroups(const QString &rootkey = QString()) const;
index 41e98a5..3da66ca 100644 (file)
@@ -84,8 +84,8 @@ BufferWidget::BufferWidget(QWidget *parent)
     coll->addAction("JumpToMarkerLine", new Action{tr("Go to Marker Line"), coll, this, [this]() { jumpToMarkerLine(); }, QKeySequence(Qt::CTRL + Qt::Key_K)});
 
     ChatViewSettings s;
-    s.initAndNotify("AutoMarkerLine", this, SLOT(setAutoMarkerLine(QVariant)), true);
-    s.initAndNotify("AutoMarkerLineOnLostFocus", this, SLOT(setAutoMarkerLineOnLostFocus(QVariant)), true);
+    s.initAndNotify("AutoMarkerLine", this, &BufferWidget::setAutoMarkerLine, true);
+    s.initAndNotify("AutoMarkerLineOnLostFocus", this, &BufferWidget::setAutoMarkerLineOnLostFocus, true);
 }
 
 
index c1dcf13..1229fd4 100644 (file)
@@ -31,8 +31,7 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
 {
     // Global configuration
     ChatViewSettings defaultSettings;
-    _showSenderBrackets = defaultSettings.showSenderBrackets();
-    defaultSettings.notify("ShowSenderBrackets", this, SLOT(showSenderBracketsSettingChanged(const QVariant &)));
+    defaultSettings.initAndNotify("ShowSenderBrackets", this, &ChatMonitorFilter::showSenderBracketsSettingChanged);
 
     // NOTE: Whenever changing defaults here, also update ChatMonitorSettingsPage::loadSettings()
     // and ChatMonitorSettingsPage::defaults() to match
@@ -41,8 +40,8 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
     ChatViewSettings viewSettings(ChatMonitorFilter::idString());
     _showFields = viewSettings.value("ShowFields", AllFields).toInt();
     _showOwnMessages = viewSettings.value("ShowOwnMsgs", true).toBool();
-    viewSettings.notify("ShowFields", this, SLOT(showFieldsSettingChanged(const QVariant &)));
-    viewSettings.notify("ShowOwnMsgs", this, SLOT(showOwnMessagesSettingChanged(const QVariant &)));
+    viewSettings.notify("ShowFields", this, &ChatMonitorFilter::showFieldsSettingChanged);
+    viewSettings.notify("ShowOwnMsgs", this, &ChatMonitorFilter::showOwnMessagesSettingChanged);
 
     // ChatMonitorSettingsPage
     QString showHighlightsSettingsId = "ShowHighlights";
@@ -53,21 +52,20 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
     QString alwaysOwnSettingsId = "AlwaysOwn";
 
     _showHighlights = viewSettings.value(showHighlightsSettingsId, false).toBool();
-    _operationMode =
-            viewSettings.value(operationModeSettingsId, ChatViewSettings::InvalidMode).toInt();
+    _operationMode = viewSettings.value(operationModeSettingsId, ChatViewSettings::InvalidMode).toInt();
     // read configured list of buffers to monitor/ignore
     foreach(QVariant v, viewSettings.value(buffersSettingsId, QVariant()).toList())
-    _bufferIds << v.value<BufferId>();
+        _bufferIds << v.value<BufferId>();
     _showBacklog = viewSettings.value(showBacklogSettingsId, true).toBool();
     _includeRead = viewSettings.value(includeReadSettingsId, false).toBool();
     _alwaysOwn = viewSettings.value(alwaysOwnSettingsId, false).toBool();
 
-    viewSettings.notify(showHighlightsSettingsId, this, SLOT(showHighlightsSettingChanged(const QVariant &)));
-    viewSettings.notify(operationModeSettingsId, this, SLOT(operationModeSettingChanged(const QVariant &)));
-    viewSettings.notify(buffersSettingsId, this, SLOT(buffersSettingChanged(const QVariant &)));
-    viewSettings.notify(showBacklogSettingsId, this, SLOT(showBacklogSettingChanged(const QVariant &)));
-    viewSettings.notify(includeReadSettingsId, this, SLOT(includeReadSettingChanged(const QVariant &)));
-    viewSettings.notify(alwaysOwnSettingsId, this, SLOT(alwaysOwnSettingChanged(const QVariant &)));
+    viewSettings.notify(showHighlightsSettingsId, this, &ChatMonitorFilter::showHighlightsSettingChanged);
+    viewSettings.notify(operationModeSettingsId, this, &ChatMonitorFilter::operationModeSettingChanged);
+    viewSettings.notify(buffersSettingsId, this, &ChatMonitorFilter::buffersSettingChanged);
+    viewSettings.notify(showBacklogSettingsId, this, &ChatMonitorFilter::showBacklogSettingChanged);
+    viewSettings.notify(includeReadSettingsId, this, &ChatMonitorFilter::includeReadSettingChanged);
+    viewSettings.notify(alwaysOwnSettingsId, this, &ChatMonitorFilter::alwaysOwnSettingChanged);
 }
 
 
index 67d1425..1727514 100644 (file)
@@ -127,16 +127,16 @@ ChatScene::ChatScene(QAbstractItemModel *model, QString idString, qreal width, C
     connect(&webPreview.timer, &QTimer::timeout, this, &ChatScene::webPreviewNextStep);
 #endif
     _showWebPreview = defaultSettings.showWebPreview();
-    defaultSettings.notify("ShowWebPreview", this, SLOT(showWebPreviewChanged()));
+    defaultSettings.notify("ShowWebPreview", this, &ChatScene::showWebPreviewChanged);
 
     _showSenderBrackets = defaultSettings.showSenderBrackets();
-    defaultSettings.notify("ShowSenderBrackets", this, SLOT(showSenderBracketsChanged()));
+    defaultSettings.notify("ShowSenderBrackets", this, &ChatScene::showSenderBracketsChanged);
 
     _useCustomTimestampFormat = defaultSettings.useCustomTimestampFormat();
-    defaultSettings.notify("UseCustomTimestampFormat", this, SLOT(useCustomTimestampFormatChanged()));
+    defaultSettings.notify("UseCustomTimestampFormat", this, &ChatScene::useCustomTimestampFormatChanged);
 
     _timestampFormatString = defaultSettings.timestampFormatString();
-    defaultSettings.notify("TimestampFormat", this, SLOT(timestampFormatStringChanged()));
+    defaultSettings.notify("TimestampFormat", this, &ChatScene::timestampFormatStringChanged);
     updateTimestampHasBrackets();
 
     _clickTimer.setInterval(QApplication::doubleClickInterval());
index 2a6ea9b..08a9bae 100644 (file)
@@ -36,7 +36,7 @@ DockManagerNotificationBackend::DockManagerNotificationBackend(QObject *parent)
     NotificationSettings notificationSettings;
     _enabled = notificationSettings.value("DockManager/Enabled", false).toBool();
 
-    notificationSettings.notify("DockManager/Enabled", this, SLOT(enabledChanged(const QVariant &)));
+    notificationSettings.notify("DockManager/Enabled", this, &DockManagerNotificationBackend::enabledChanged);
 
     _dock = new QDBusInterface("net.launchpad.DockManager", "/net/launchpad/DockManager", "net.launchpad.DockManager", _bus, this);
     if (_dock->isValid()) {
index 3c56673..b444cfa 100644 (file)
@@ -112,36 +112,20 @@ InputWidget::InputWidget(QWidget *parent)
     new TabCompleter(ui.inputEdit);
 
     UiStyleSettings fs("Fonts");
-    fs.notify("UseCustomInputWidgetFont", this, SLOT(setUseCustomFont(QVariant)));
-    fs.notify("InputWidget", this, SLOT(setCustomFont(QVariant)));
+    fs.notify("UseCustomInputWidgetFont", this, &InputWidget::setUseCustomFont);
+    fs.notify("InputWidget", this, &InputWidget::setCustomFont);
     if (fs.value("UseCustomInputWidgetFont", false).toBool())
         setCustomFont(fs.value("InputWidget", QFont()));
 
     UiSettings s("InputWidget");
-
-    s.notify("EnableEmacsMode", this, SLOT(setEnableEmacsMode(QVariant)));
-    setEnableEmacsMode(s.value("EnableEmacsMode", false));
-
-    s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant)));
-    setShowNickSelector(s.value("ShowNickSelector", true));
-
-    s.notify("ShowStyleButtons", this, SLOT(setShowStyleButtons(QVariant)));
-    setShowStyleButtons(s.value("ShowStyleButtons", true));
-
-    s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant)));
-    setEnablePerChatHistory(s.value("EnablePerChatHistory", true));
-
-    s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant)));
-    setMaxLines(s.value("MaxNumLines", 5));
-
-    s.notify("EnableScrollBars", this, SLOT(setScrollBarsEnabled(QVariant)));
-    setScrollBarsEnabled(s.value("EnableScrollBars", true));
-
-    s.notify("EnableLineWrap", this, SLOT(setLineWrapEnabled(QVariant)));
-    setLineWrapEnabled(s.value("EnableLineWrap", true));
-
-    s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant)));
-    setMultiLineEnabled(s.value("EnableMultiLine", true));
+    s.initAndNotify("EnableEmacsMode", this, &InputWidget::setEnableEmacsMode, false);
+    s.initAndNotify("ShowNickSelector", this, &InputWidget::setShowNickSelector, true);
+    s.initAndNotify("ShowStyleButtons", this, &InputWidget::setShowStyleButtons, true);
+    s.initAndNotify("EnablePerChatHistory", this, &InputWidget::setEnablePerChatHistory, true);
+    s.initAndNotify("MaxNumLines", this, &InputWidget::setMaxLines, 5);
+    s.initAndNotify("EnableScrollBars", this, &InputWidget::setScrollBarsEnabled, true);
+    s.initAndNotify("EnableLineWrap", this, &InputWidget::setLineWrapEnabled, true);
+    s.initAndNotify("EnableMultiLine", this, &InputWidget::setMultiLineEnabled, true);
 
     ActionCollection *coll = QtUi::actionCollection();
     coll->addAction("FocusInputLine", new Action{tr("Focus Input Line"), coll, this, selectOverload<>(&QWidget::setFocus), QKeySequence(Qt::CTRL + Qt::Key_L)});
index 5294431..ba4cd20 100644 (file)
@@ -49,7 +49,7 @@ OSXNotificationBackend::OSXNotificationBackend(QObject *parent)
       _enabled(true)
 {
     NotificationSettings notificationSettings;
-    notificationSettings.initAndNotify("OSXNotification/Enabled", this, SLOT(enabledChanged(QVariant)), true);
+    notificationSettings.initAndNotify("OSXNotification/Enabled", this, &OSXNotificationBackend::enabledChanged, true);
 }
 
 void OSXNotificationBackend::enabledChanged(const QVariant &value)
index 2557a92..a936971 100644 (file)
@@ -33,8 +33,8 @@ QtMultimediaNotificationBackend::QtMultimediaNotificationBackend(QObject *parent
     : AbstractNotificationBackend(parent)
 {
     NotificationSettings notificationSettings;
-    notificationSettings.notify("QtMultimedia/Enabled", this, SLOT(enabledChanged(const QVariant &)));
-    notificationSettings.notify("QtMultimedia/AudioFile", this, SLOT(audioFileChanged(const QVariant &)));
+    notificationSettings.notify("QtMultimedia/Enabled", this, &QtMultimediaNotificationBackend::enabledChanged);
+    notificationSettings.notify("QtMultimedia/AudioFile", this, &QtMultimediaNotificationBackend::audioFileChanged);
 
     createMediaObject(notificationSettings.value("QtMultimedia/AudioFile", QString()).toString());
 
index 3bdb6e1..c69bf5e 100644 (file)
@@ -90,7 +90,7 @@ void QtUi::init()
     _mainWin->init();
 
     QtUiSettings uiSettings;
-    uiSettings.initAndNotify("UseSystemTrayIcon", this, SLOT(useSystemTrayChanged(QVariant)), true);
+    uiSettings.initAndNotify("UseSystemTrayIcon", this, &QtUi::useSystemTrayChanged, true);
 
     GraphicalUi::init(); // needs to be called after the mainWin is initialized
 }
index cb9cd8f..db038f8 100644 (file)
@@ -38,9 +38,9 @@ QtUiMessageProcessor::QtUiMessageProcessor(QObject *parent)
     _nickMatcher.setHighlightMode(
                 static_cast<NickHighlightMatcher::HighlightNickType>(_highlightNick));
     highlightListChanged(notificationSettings.highlightList());
-    notificationSettings.notify("Highlights/NicksCaseSensitive", this, SLOT(nicksCaseSensitiveChanged(const QVariant &)));
-    notificationSettings.notify("Highlights/CustomList", this, SLOT(highlightListChanged(const QVariant &)));
-    notificationSettings.notify("Highlights/HighlightNick", this, SLOT(highlightNickChanged(const QVariant &)));
+    notificationSettings.notify("Highlights/NicksCaseSensitive", this, &QtUiMessageProcessor::nicksCaseSensitiveChanged);
+    notificationSettings.notify("Highlights/CustomList", this, &QtUiMessageProcessor::highlightListChanged);
+    notificationSettings.notify("Highlights/HighlightNick", this, &QtUiMessageProcessor::highlightNickChanged);
 
     _processTimer.setInterval(0);
     connect(&_processTimer, &QTimer::timeout, this, &QtUiMessageProcessor::processNextMessage);
index 0fd43c1..2920f70 100644 (file)
 QtUiStyle::QtUiStyle(QObject *parent) : UiStyle(parent)
 {
     ChatViewSettings s;
-    s.notify("UseCustomTimestampFormat", this, SLOT(updateUseCustomTimestampFormat()));
-    updateUseCustomTimestampFormat();
-    s.notify("TimestampFormat", this, SLOT(updateTimestampFormatString()));
-    updateTimestampFormatString();
-    s.notify("SenderPrefixMode", this, SLOT(updateSenderPrefixDisplay()));
-    updateSenderPrefixDisplay();
-    s.notify("ShowSenderBrackets", this, SLOT(updateShowSenderBrackets()));
-    updateShowSenderBrackets();
+    s.initAndNotify("UseCustomTimestampFormat", this, &QtUiStyle::updateUseCustomTimestampFormat);
+    s.initAndNotify("TimestampFormat", this, &QtUiStyle::updateTimestampFormatString);
+    s.initAndNotify("SenderPrefixMode", this, &QtUiStyle::updateSenderPrefixDisplay);
+    s.initAndNotify("ShowSenderBrackets", this, &QtUiStyle::updateShowSenderBrackets);
 
     // If no style sheet exists, generate it on first run.
     initializeSettingsQss();
index bdabcf1..6e539a9 100644 (file)
@@ -60,7 +60,7 @@ SnoreNotificationBackend::SnoreNotificationBackend (QObject *parent)
     NotificationSettings notificationSettings;
     bool enabled = notificationSettings.value("Snore/Enabled", false).toBool();
     setTraybackend(enabled);
-    notificationSettings.notify("Snore/Enabled", this, SLOT(setTraybackend(const QVariant &)));
+    notificationSettings.notify("Snore/Enabled", this, &SnoreNotificationBackend::setTraybackend);
 }
 
 SnoreNotificationBackend::~SnoreNotificationBackend()
index c85e7bf..b7cac74 100644 (file)
@@ -35,9 +35,9 @@ SystemTray::SystemTray(QWidget *parent)
 {
     Q_ASSERT(parent);
 
-    NotificationSettings{}.initAndNotify("Systray/ChangeColor", this, SLOT(enableChangeColorChanged(QVariant)), true);
-    NotificationSettings{}.initAndNotify("Systray/Animate", this, SLOT(enableBlinkChanged(QVariant)), false);
-    UiStyleSettings{}.initAndNotify("Icons/InvertTray", this, SLOT(invertTrayIconChanged(QVariant)), false);
+    NotificationSettings{}.initAndNotify("Systray/ChangeColor", this, &SystemTray::enableChangeColorChanged, true);
+    NotificationSettings{}.initAndNotify("Systray/Animate", this, &SystemTray::enableBlinkChanged, false);
+    UiStyleSettings{}.initAndNotify("Icons/InvertTray", this, &SystemTray::invertTrayIconChanged, false);
 
     ActionCollection *coll = QtUi::actionCollection("General");
     _minimizeRestoreAction = new Action(tr("&Minimize"), this, this, &SystemTray::minimizeRestore);
index b565180..f542a44 100644 (file)
@@ -30,7 +30,7 @@ SystrayAnimationNotificationBackend::SystrayAnimationNotificationBackend(QObject
     : AbstractNotificationBackend(parent)
 {
     NotificationSettings notificationSettings;
-    notificationSettings.initAndNotify("Systray/Alert", this, SLOT(alertChanged(QVariant)), true);
+    notificationSettings.initAndNotify("Systray/Alert", this, &SystrayAnimationNotificationBackend::alertChanged, true);
 }
 
 
index db92a9e..4e024da 100644 (file)
@@ -37,7 +37,7 @@ SystrayNotificationBackend::SystrayNotificationBackend(QObject *parent)
     : AbstractNotificationBackend(parent)
 {
     NotificationSettings notificationSettings;
-    notificationSettings.initAndNotify("Systray/ShowBubble", this, SLOT(showBubbleChanged(QVariant)), true);
+    notificationSettings.initAndNotify("Systray/ShowBubble", this, &SystrayNotificationBackend::showBubbleChanged, true);
 
     connect(QtUi::mainWindow()->systemTray(), &SystemTray::messageClicked,
             this, selectOverload<uint>(&SystrayNotificationBackend::onNotificationActivated));
index c86c933..456d167 100644 (file)
@@ -37,8 +37,8 @@ TaskbarNotificationBackend::TaskbarNotificationBackend(QObject *parent)
     _enabled = notificationSettings.value("Taskbar/Enabled", true).toBool();
     _timeout = notificationSettings.value("Taskbar/Timeout", 0).toInt();
 
-    notificationSettings.notify("Taskbar/Enabled", this, SLOT(enabledChanged(const QVariant &)));
-    notificationSettings.notify("Taskbar/Timeout", this, SLOT(timeoutChanged(const QVariant &)));
+    notificationSettings.notify("Taskbar/Enabled", this, &TaskbarNotificationBackend::enabledChanged);
+    notificationSettings.notify("Taskbar/Timeout", this, &TaskbarNotificationBackend::timeoutChanged);
 }
 
 
index e18625c..007072c 100644 (file)
@@ -26,6 +26,7 @@
 #include "uisettings.h"
 #include "graphicalui.h"
 #include "uistyle.h"
+#include "util.h"
 
 TopicWidget::TopicWidget(QWidget *parent)
     : AbstractItemView(parent)
@@ -39,13 +40,13 @@ TopicWidget::TopicWidget(QWidget *parent)
     connect(ui.topicLineEdit, &MultiLineEdit::noTextEntered, this, &TopicWidget::on_topicLineEdit_textEntered);
 
     UiSettings s("TopicWidget");
-    s.notify("DynamicResize", this, SLOT(updateResizeMode()));
-    s.notify("ResizeOnHover", this, SLOT(updateResizeMode()));
+    s.notify("DynamicResize", this, &TopicWidget::updateResizeMode);
+    s.notify("ResizeOnHover", this, &TopicWidget::updateResizeMode);
     updateResizeMode();
 
     UiStyleSettings fs("Fonts");
-    fs.notify("UseCustomTopicWidgetFont", this, SLOT(setUseCustomFont(QVariant)));
-    fs.notify("TopicWidget", this, SLOT(setCustomFont(QVariant)));
+    fs.notify("UseCustomTopicWidgetFont", this, &TopicWidget::setUseCustomFont);
+    fs.notify("TopicWidget", this, selectOverload<const QVariant&>(&TopicWidget::setCustomFont));
     if (fs.value("UseCustomTopicWidgetFont", false).toBool())
         setCustomFont(fs.value("TopicWidget", QFont()));
 
index 059e47e..3e13313 100644 (file)
@@ -57,7 +57,7 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig *
     connect(&_enableEditMode, &QAction::toggled, this, &BufferViewFilter::enableEditMode);
 
     BufferSettings defaultSettings;
-    defaultSettings.notify("ServerNoticesTarget", this, SLOT(showServerQueriesChanged()));
+    defaultSettings.notify("ServerNoticesTarget", this, &BufferViewFilter::showServerQueriesChanged);
     showServerQueriesChanged();
 }
 
index 8b7a4f0..8a1655b 100644 (file)
@@ -105,11 +105,8 @@ UiStyle::UiStyle(QObject *parent)
 
     // BufferView / NickView settings
     UiStyleSettings s;
-    _showBufferViewIcons = _showNickViewIcons = s.value("ShowItemViewIcons", true).toBool();
-    s.notify("ShowItemViewIcons", this, SLOT(showItemViewIconsChanged(QVariant)));
-
-    _allowMircColors = s.value("AllowMircColors", true).toBool();
-    s.notify("AllowMircColors", this, SLOT(allowMircColorsChanged(QVariant)));
+    s.initAndNotify("ShowItemViewIcons", this, &UiStyle::showItemViewIconsChanged, true);
+    s.initAndNotify("AllowMircColors", this, &UiStyle::allowMircColorsChanged, true);
 
     loadStyleSheet();
 }