From: Manuel Nickschas Date: Wed, 19 Sep 2018 22:54:21 +0000 (+0200) Subject: modernize: Require member function pointers for Settings::notify() X-Git-Tag: test-travis-01~123 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=2c8434f74c68194d56f2084f637419123e61d18b modernize: Require member function pointers for Settings::notify() Require member function pointers for Settings::notify() and Settings::initAndNotify(). This brings us one step closer to being SLOT-free. --- diff --git a/src/client/clientsettings.cpp b/src/client/clientsettings.cpp index 87c0fc55..35860939 100644 --- a/src/client/clientsettings.cpp +++ b/src/client/clientsettings.cpp @@ -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); } diff --git a/src/client/clientsettings.h b/src/client/clientsettings.h index 6c984ed9..de5633a0 100644 --- a/src/client/clientsettings.h +++ b/src/client/clientsettings.h @@ -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 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; }; diff --git a/src/client/clientuserinputhandler.cpp b/src/client/clientuserinputhandler.cpp index 7179515a..9315a5ee 100644 --- a/src/client/clientuserinputhandler.cpp +++ b/src/client/clientuserinputhandler.cpp @@ -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()); } diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index e41ccdc6..3c62fca6 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -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()); } diff --git a/src/client/messagefilter.cpp b/src/client/messagefilter.cpp index fd6e78b7..18aedd21 100644 --- a/src/client/messagefilter.cpp +++ b/src/client/messagefilter.cpp @@ -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); } diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 223e09ca..12410201 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -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(); } diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 868628a3..f157d357 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -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; } diff --git a/src/common/settings.h b/src/common/settings.h index 48dfafdd..64bc4620 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -23,6 +23,7 @@ #include "common-export.h" #include +#include #include #include @@ -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 + void notify(const QString &key, const Receiver *receiver, Slot slot) const + { + static_assert(!std::is_same::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 + 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; diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index 41e98a51..3da66caf 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -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); } diff --git a/src/qtui/chatmonitorfilter.cpp b/src/qtui/chatmonitorfilter.cpp index c1dcf138..1229fd4e 100644 --- a/src/qtui/chatmonitorfilter.cpp +++ b/src/qtui/chatmonitorfilter.cpp @@ -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(); + _bufferIds << v.value(); _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); } diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 67d14253..17275144 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -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()); diff --git a/src/qtui/dockmanagernotificationbackend.cpp b/src/qtui/dockmanagernotificationbackend.cpp index 2a6ea9bf..08a9baef 100644 --- a/src/qtui/dockmanagernotificationbackend.cpp +++ b/src/qtui/dockmanagernotificationbackend.cpp @@ -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()) { diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index 3c566737..b444cfa9 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -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)}); diff --git a/src/qtui/osxnotificationbackend.mm b/src/qtui/osxnotificationbackend.mm index 5294431a..ba4cd202 100644 --- a/src/qtui/osxnotificationbackend.mm +++ b/src/qtui/osxnotificationbackend.mm @@ -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) diff --git a/src/qtui/qtmultimedianotificationbackend.cpp b/src/qtui/qtmultimedianotificationbackend.cpp index 2557a923..a9369710 100644 --- a/src/qtui/qtmultimedianotificationbackend.cpp +++ b/src/qtui/qtmultimedianotificationbackend.cpp @@ -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()); diff --git a/src/qtui/qtui.cpp b/src/qtui/qtui.cpp index 3bdb6e1c..c69bf5ea 100644 --- a/src/qtui/qtui.cpp +++ b/src/qtui/qtui.cpp @@ -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 } diff --git a/src/qtui/qtuimessageprocessor.cpp b/src/qtui/qtuimessageprocessor.cpp index cb9cd8fd..db038f8c 100644 --- a/src/qtui/qtuimessageprocessor.cpp +++ b/src/qtui/qtuimessageprocessor.cpp @@ -38,9 +38,9 @@ QtUiMessageProcessor::QtUiMessageProcessor(QObject *parent) _nickMatcher.setHighlightMode( static_cast(_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); diff --git a/src/qtui/qtuistyle.cpp b/src/qtui/qtuistyle.cpp index 0fd43c1e..2920f709 100644 --- a/src/qtui/qtuistyle.cpp +++ b/src/qtui/qtuistyle.cpp @@ -28,14 +28,10 @@ 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(); diff --git a/src/qtui/snorenotificationbackend.cpp b/src/qtui/snorenotificationbackend.cpp index bdabcf13..6e539a94 100644 --- a/src/qtui/snorenotificationbackend.cpp +++ b/src/qtui/snorenotificationbackend.cpp @@ -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() diff --git a/src/qtui/systemtray.cpp b/src/qtui/systemtray.cpp index c85e7bf2..b7cac741 100644 --- a/src/qtui/systemtray.cpp +++ b/src/qtui/systemtray.cpp @@ -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); diff --git a/src/qtui/systrayanimationnotificationbackend.cpp b/src/qtui/systrayanimationnotificationbackend.cpp index b565180d..f542a44b 100644 --- a/src/qtui/systrayanimationnotificationbackend.cpp +++ b/src/qtui/systrayanimationnotificationbackend.cpp @@ -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); } diff --git a/src/qtui/systraynotificationbackend.cpp b/src/qtui/systraynotificationbackend.cpp index db92a9e3..4e024daf 100644 --- a/src/qtui/systraynotificationbackend.cpp +++ b/src/qtui/systraynotificationbackend.cpp @@ -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(&SystrayNotificationBackend::onNotificationActivated)); diff --git a/src/qtui/taskbarnotificationbackend.cpp b/src/qtui/taskbarnotificationbackend.cpp index c86c9333..456d1672 100644 --- a/src/qtui/taskbarnotificationbackend.cpp +++ b/src/qtui/taskbarnotificationbackend.cpp @@ -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); } diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index e18625cd..007072c7 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -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(&TopicWidget::setCustomFont)); if (fs.value("UseCustomTopicWidgetFont", false).toBool()) setCustomFont(fs.value("TopicWidget", QFont())); diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 059e47e5..3e133135 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -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(); } diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 8b7a4f0f..8a1655b0 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -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(); }