From 3b8519fda347d99e8ae79df9d54715960955f2a4 Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Thu, 1 Apr 2021 15:06:19 -0700 Subject: [PATCH] internet: Move page creation to internet category class This consolidates most of the knowledge of internet settings pages in the internet subdirectory. The exception is the master page enumeration in the settings dialog. --- .../core/internetsettingscategory.cpp | 83 ++++++++++++++++++- src/internet/core/internetsettingscategory.h | 3 + src/ui/settingsdialog.cpp | 79 +----------------- 3 files changed, 87 insertions(+), 78 deletions(-) diff --git a/src/internet/core/internetsettingscategory.cpp b/src/internet/core/internetsettingscategory.cpp index 5738b3066..98335f7ea 100644 --- a/src/internet/core/internetsettingscategory.cpp +++ b/src/internet/core/internetsettingscategory.cpp @@ -17,8 +17,89 @@ #include "internetsettingscategory.h" +#include "internet/digitally/digitallyimportedsettingspage.h" +#include "internet/magnatune/magnatunesettingspage.h" +#include "internet/podcasts/podcastsettingspage.h" +#include "internet/radiobrowser/radiobrowsersettingspage.h" +#include "internet/subsonic/subsonicsettingspage.h" #include "internetshowsettingspage.h" +#ifdef HAVE_LIBLASTFM +#include "internet/lastfm/lastfmsettingspage.h" +#endif + +#ifdef HAVE_GOOGLE_DRIVE +#include "internet/googledrive/googledrivesettingspage.h" +#endif + +#ifdef HAVE_DROPBOX +#include "internet/dropbox/dropboxsettingspage.h" +#endif + +#ifdef HAVE_BOX +#include "internet/box/boxsettingspage.h" +#endif + +#ifdef HAVE_SKYDRIVE +#include "internet/skydrive/skydrivesettingspage.h" +#endif + +#ifdef HAVE_SEAFILE +#include "internet/seafile/seafilesettingspage.h" +#endif + +#ifdef HAVE_SPOTIFY +#include "internet/spotify/spotifysettingspage.h" +#endif + InternetSettingsCategory::InternetSettingsCategory(SettingsDialog* dialog) : SettingsCategory(SettingsDialog::Page_InternetShow, - new InternetShowSettingsPage(dialog), dialog) {} + new InternetShowSettingsPage(dialog), dialog) { + AddChildren(); +} + +void InternetSettingsCategory::AddChildren() { +#ifdef HAVE_LIBLASTFM + AddPage(SettingsDialog::Page_Lastfm, new LastFMSettingsPage(dialog_)); +#endif + +#ifdef HAVE_GOOGLE_DRIVE + AddPage(SettingsDialog::Page_GoogleDrive, + new GoogleDriveSettingsPage(dialog_)); +#endif + +#ifdef HAVE_DROPBOX + AddPage(SettingsDialog::Page_Dropbox, new DropboxSettingsPage(dialog_)); +#endif + +#ifdef HAVE_BOX + AddPage(SettingsDialog::Page_Box, new BoxSettingsPage(dialog_)); +#endif + +#ifdef HAVE_SKYDRIVE + AddPage(SettingsDialog::Page_Skydrive, new SkydriveSettingsPage(dialog_)); +#endif + +#ifdef HAVE_SPOTIFY + AddPage(SettingsDialog::Page_Spotify, new SpotifySettingsPage(dialog_)); +#endif + +#ifdef HAVE_SEAFILE + AddPage(SettingsDialog::Page_Seafile, new SeafileSettingsPage(dialog_)); +#endif + +#ifdef HAVE_AMAZON_CLOUD_DRIVE + AddPage(SettingsDialog::Page_AmazonCloudDrive, + new AmazonSettingsPage(dialog_)); +#endif + + AddPage(SettingsDialog::Page_Magnatune, new MagnatuneSettingsPage(dialog_)); + AddPage(SettingsDialog::Page_DigitallyImported, + new DigitallyImportedSettingsPage(dialog_)); + AddPage(SettingsDialog::Page_Subsonic, new SubsonicSettingsPage(dialog_)); + AddPage(SettingsDialog::Page_Podcasts, new PodcastSettingsPage(dialog_)); + AddPage(SettingsDialog::Page_RadioBrowser, + new RadioBrowserSettingsPage(dialog_)); + + sortChildren(0, Qt::AscendingOrder); +} diff --git a/src/internet/core/internetsettingscategory.h b/src/internet/core/internetsettingscategory.h index c5b116f06..4aadf923e 100644 --- a/src/internet/core/internetsettingscategory.h +++ b/src/internet/core/internetsettingscategory.h @@ -23,6 +23,9 @@ class InternetSettingsCategory : public SettingsCategory { public: InternetSettingsCategory(SettingsDialog* dialog); + + private: + void AddChildren(); }; #endif // INTERNETSETTINGSCATEGORY_H diff --git a/src/ui/settingsdialog.cpp b/src/ui/settingsdialog.cpp index ff98643b4..1b716fe21 100644 --- a/src/ui/settingsdialog.cpp +++ b/src/ui/settingsdialog.cpp @@ -32,11 +32,6 @@ #include "globalshortcutssettingspage.h" #include "iconloader.h" #include "internet/core/internetsettingscategory.h" -#include "internet/digitally/digitallyimportedsettingspage.h" -#include "internet/magnatune/magnatunesettingspage.h" -#include "internet/podcasts/podcastsettingspage.h" -#include "internet/radiobrowser/radiobrowsersettingspage.h" -#include "internet/subsonic/subsonicsettingspage.h" #include "library/librarysettingspage.h" #include "mainwindow.h" #include "networkproxysettingspage.h" @@ -51,38 +46,10 @@ #include "widgets/groupediconview.h" #include "widgets/osdpretty.h" -#ifdef HAVE_LIBLASTFM -#include "internet/lastfm/lastfmsettingspage.h" -#endif - #ifdef HAVE_WIIMOTEDEV #include "wiimotedev/wiimotesettingspage.h" #endif -#ifdef HAVE_GOOGLE_DRIVE -#include "internet/googledrive/googledrivesettingspage.h" -#endif - -#ifdef HAVE_DROPBOX -#include "internet/dropbox/dropboxsettingspage.h" -#endif - -#ifdef HAVE_BOX -#include "internet/box/boxsettingspage.h" -#endif - -#ifdef HAVE_SKYDRIVE -#include "internet/skydrive/skydrivesettingspage.h" -#endif - -#ifdef HAVE_SEAFILE -#include "internet/seafile/seafilesettingspage.h" -#endif - -#ifdef HAVE_SPOTIFY -#include "internet/spotify/spotifysettingspage.h" -#endif - #include #include #include @@ -169,50 +136,8 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams, SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)), SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString))); - // Internet providers - SettingsCategory* providers = new InternetSettingsCategory(this); - AddCategory(providers); - -#ifdef HAVE_LIBLASTFM - providers->AddPage(Page_Lastfm, new LastFMSettingsPage(this)); -#endif - -#ifdef HAVE_GOOGLE_DRIVE - providers->AddPage(Page_GoogleDrive, new GoogleDriveSettingsPage(this)); -#endif - -#ifdef HAVE_DROPBOX - providers->AddPage(Page_Dropbox, new DropboxSettingsPage(this)); -#endif - -#ifdef HAVE_BOX - providers->AddPage(Page_Box, new BoxSettingsPage(this)); -#endif - -#ifdef HAVE_SKYDRIVE - providers->AddPage(Page_Skydrive, new SkydriveSettingsPage(this)); -#endif - -#ifdef HAVE_SPOTIFY - providers->AddPage(Page_Spotify, new SpotifySettingsPage(this)); -#endif - -#ifdef HAVE_SEAFILE - providers->AddPage(Page_Seafile, new SeafileSettingsPage(this)); -#endif - -#ifdef HAVE_AMAZON_CLOUD_DRIVE - providers->AddPage(Page_AmazonCloudDrive, new AmazonSettingsPage(this)); -#endif - - providers->AddPage(Page_Magnatune, new MagnatuneSettingsPage(this)); - providers->AddPage(Page_DigitallyImported, - new DigitallyImportedSettingsPage(this)); - providers->AddPage(Page_Subsonic, new SubsonicSettingsPage(this)); - providers->AddPage(Page_Podcasts, new PodcastSettingsPage(this)); - providers->AddPage(Page_RadioBrowser, new RadioBrowserSettingsPage(this)); - - providers->sortChildren(0, Qt::AscendingOrder); + // Internet services category + AddCategory(new InternetSettingsCategory(this)); // List box connect(ui_->list,