From c394d7d2ddc2b643ed9a1ba0d38050d2164ef9da Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Mon, 22 Mar 2021 16:16:48 -0700 Subject: [PATCH] settings: Don't connect service-specific signals to every page Wii and notifications signals are currently connected for every settings page. Move the signals from the base SettingsPage class into the derived classes and connect the signals for only those objects. --- src/internet/core/internetshowsettingspage.h | 1 + .../radiobrowser/radiobrowsersettingspage.h | 2 ++ src/internet/seafile/seafilesettingspage.h | 1 + src/ui/mainwindow.cpp | 1 + src/ui/notificationssettingspage.h | 4 ++++ src/ui/settingsdialog.cpp | 20 +++++++++++-------- src/ui/settingspage.h | 6 ------ src/wiimotedev/shortcuts.cpp | 3 +++ 8 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/internet/core/internetshowsettingspage.h b/src/internet/core/internetshowsettingspage.h index 7d2603d74..6ddf75220 100644 --- a/src/internet/core/internetshowsettingspage.h +++ b/src/internet/core/internetshowsettingspage.h @@ -20,6 +20,7 @@ #define INTERNET_CORE_INTERNETSHOWSETTINGSPAGE_H_ #include +#include #include "ui/settingspage.h" #include "ui_internetshowsettingspage.h" diff --git a/src/internet/radiobrowser/radiobrowsersettingspage.h b/src/internet/radiobrowser/radiobrowsersettingspage.h index 93d71de30..f6d4725c0 100644 --- a/src/internet/radiobrowser/radiobrowsersettingspage.h +++ b/src/internet/radiobrowser/radiobrowsersettingspage.h @@ -18,6 +18,8 @@ #ifndef INTERNET_RADIOBROWSER_RADIOBROWSERSETTINGSPAGE_H_ #define INTERNET_RADIOBROWSER_RADIOBROWSERSETTINGSPAGE_H_ +#include + #include "radiobrowserservice.h" #include "ui/settingspage.h" #include "ui_radiobrowsersettingspage.h" diff --git a/src/internet/seafile/seafilesettingspage.h b/src/internet/seafile/seafilesettingspage.h index 554d4ddaf..ae497e40c 100644 --- a/src/internet/seafile/seafilesettingspage.h +++ b/src/internet/seafile/seafilesettingspage.h @@ -21,6 +21,7 @@ #include #include +#include #include "ui/settingspage.h" diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index d4da9300d..13231f5ef 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -3061,6 +3061,7 @@ void MainWindow::ScrobbleError(int value) { void MainWindow::HandleNotificationPreview(OSD::Behaviour type, QString line1, QString line2) { + qLog(Debug) << "Handling notification preview"; if (!app_->playlist_manager()->current()->GetAllSongs().isEmpty()) { // Show a preview notification for the first song in the current playlist osd_->ShowPreview( diff --git a/src/ui/notificationssettingspage.h b/src/ui/notificationssettingspage.h index a088cf8e1..d272d2bf9 100644 --- a/src/ui/notificationssettingspage.h +++ b/src/ui/notificationssettingspage.h @@ -19,6 +19,7 @@ #define NOTIFICATIONSSETTINGSPAGE_H #include "settingspage.h" +#include "widgets/osd.h" class Ui_NotificationsSettingsPage; @@ -36,6 +37,9 @@ class NotificationsSettingsPage : public SettingsPage { void hideEvent(QHideEvent*); void showEvent(QShowEvent*); + signals: + void NotificationPreview(OSD::Behaviour, QString, QString); + private slots: void NotificationTypeChanged(); void NotificationCustomTextChanged(bool enabled); diff --git a/src/ui/settingsdialog.cpp b/src/ui/settingsdialog.cpp index 84c83e22d..6ebd93f9f 100644 --- a/src/ui/settingsdialog.cpp +++ b/src/ui/settingsdialog.cpp @@ -146,7 +146,10 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams, AddPage(Page_NetworkRemote, new NetworkRemoteSettingsPage(this), general); #ifdef HAVE_WIIMOTEDEV - AddPage(Page_Wiimotedev, new WiimoteSettingsPage(this), general); + WiimoteSettingsPage* wii_page = new WiimoteSettingsPage(this); + AddPage(Page_Wiimotedev, wii_page, general); + connect(wii_page, SIGNAL(SetWiimotedevInterfaceActived(bool)), + SIGNAL(SetWiimotedevInterfaceActived(bool))); #endif // User interface @@ -155,7 +158,14 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams, AddPage(Page_GlobalSearch, new GlobalSearchSettingsPage(this), iface); AddPage(Page_Appearance, new AppearanceSettingsPage(this), iface); AddPage(Page_SongInformation, new SongInfoSettingsPage(this), iface); - AddPage(Page_Notifications, new NotificationsSettingsPage(this), iface); + + NotificationsSettingsPage* notification_page = + new NotificationsSettingsPage(this); + AddPage(Page_Notifications, notification_page, iface); + connect(notification_page, + SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)), + SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString))); + AddPage(Page_InternetShow, new InternetShowSettingsPage(this), iface); // Internet providers @@ -234,12 +244,6 @@ void SettingsDialog::AddPage(Page id, SettingsPage* page, QTreeWidgetItem* parent) { if (!parent) parent = ui_->list->invisibleRootItem(); - // Connect page's signals to the settings dialog's signals - connect(page, SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)), - SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString))); - connect(page, SIGNAL(SetWiimotedevInterfaceActived(bool)), - SIGNAL(SetWiimotedevInterfaceActived(bool))); - // Create the list item QTreeWidgetItem* item = new QTreeWidgetItem; item->setText(0, page->windowTitle()); diff --git a/src/ui/settingspage.h b/src/ui/settingspage.h index 852e2d697..16cff1eb8 100644 --- a/src/ui/settingspage.h +++ b/src/ui/settingspage.h @@ -20,8 +20,6 @@ #include -#include "widgets/osd.h" - class SettingsDialog; class SettingsPage : public QWidget { @@ -45,10 +43,6 @@ class SettingsPage : public QWidget { // The dialog that this page belongs to. SettingsDialog* dialog() const { return dialog_; } - signals: - void NotificationPreview(OSD::Behaviour, QString, QString); - void SetWiimotedevInterfaceActived(bool); - protected: void showEvent(QShowEvent* event); diff --git a/src/wiimotedev/shortcuts.cpp b/src/wiimotedev/shortcuts.cpp index c52ab65f2..a85b5afa4 100644 --- a/src/wiimotedev/shortcuts.cpp +++ b/src/wiimotedev/shortcuts.cpp @@ -19,6 +19,7 @@ #include +#include "core/logging.h" #include "wiimotedev/consts.h" const char* WiimotedevShortcuts::kActionsGroup = "WiimotedevActions"; @@ -56,6 +57,8 @@ WiimotedevShortcuts::WiimotedevShortcuts(OSD* osd, QWidget* window, } void WiimotedevShortcuts::SetWiimotedevInterfaceActived(bool actived) { + qLog(Debug) << "Wiimote interface activated" << actived; + if (!QDBusConnection::systemBus().isConnected()) return; // http://code.google.com/p/clementine-player/issues/detail?id=670