settings: Move AddPage to SettingsCategory
This will allow future subclasses of SettingsCategory to populate their own pages.
This commit is contained in:
parent
d13410c91d
commit
ae8a420690
|
@ -34,3 +34,19 @@ SettingsCategory::SettingsCategory(SettingsDialog::Page id, SettingsPage* page,
|
||||||
setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
dialog->AddPageToStack(id, page, this);
|
dialog->AddPageToStack(id, page, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCategory::AddPage(SettingsDialog::Page id, SettingsPage* page) {
|
||||||
|
// Create the list item
|
||||||
|
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||||
|
item->setText(0, page->windowTitle());
|
||||||
|
item->setIcon(0, page->windowIcon());
|
||||||
|
item->setData(0, SettingsDialog::Role_IsSeparator, false);
|
||||||
|
|
||||||
|
if (!page->IsEnabled()) {
|
||||||
|
item->setFlags(Qt::NoItemFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
addChild(item);
|
||||||
|
|
||||||
|
dialog_->AddPageToStack(id, page, item);
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ class SettingsCategory : public QTreeWidgetItem {
|
||||||
SettingsCategory(SettingsDialog::Page id, SettingsPage* page,
|
SettingsCategory(SettingsDialog::Page id, SettingsPage* page,
|
||||||
SettingsDialog* dialog);
|
SettingsDialog* dialog);
|
||||||
|
|
||||||
|
void AddPage(SettingsDialog::Page id, SettingsPage* page);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SettingsDialog* dialog_;
|
SettingsDialog* dialog_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -138,18 +138,18 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||||
|
|
||||||
SettingsCategory* general = new SettingsCategory(tr("General"), this);
|
SettingsCategory* general = new SettingsCategory(tr("General"), this);
|
||||||
AddCategory(general);
|
AddCategory(general);
|
||||||
AddPage(Page_Playback, new PlaybackSettingsPage(this), general);
|
general->AddPage(Page_Playback, new PlaybackSettingsPage(this));
|
||||||
AddPage(Page_Behaviour, new BehaviourSettingsPage(this), general);
|
general->AddPage(Page_Behaviour, new BehaviourSettingsPage(this));
|
||||||
AddPage(Page_Library, new LibrarySettingsPage(this), general);
|
general->AddPage(Page_Library, new LibrarySettingsPage(this));
|
||||||
AddPage(Page_BackgroundStreams, new BackgroundStreamsSettingsPage(this),
|
general->AddPage(Page_BackgroundStreams,
|
||||||
general);
|
new BackgroundStreamsSettingsPage(this));
|
||||||
AddPage(Page_Proxy, new NetworkProxySettingsPage(this), general);
|
general->AddPage(Page_Proxy, new NetworkProxySettingsPage(this));
|
||||||
AddPage(Page_Transcoding, new TranscoderSettingsPage(this), general);
|
general->AddPage(Page_Transcoding, new TranscoderSettingsPage(this));
|
||||||
AddPage(Page_NetworkRemote, new NetworkRemoteSettingsPage(this), general);
|
general->AddPage(Page_NetworkRemote, new NetworkRemoteSettingsPage(this));
|
||||||
|
|
||||||
#ifdef HAVE_WIIMOTEDEV
|
#ifdef HAVE_WIIMOTEDEV
|
||||||
WiimoteSettingsPage* wii_page = new WiimoteSettingsPage(this);
|
WiimoteSettingsPage* wii_page = new WiimoteSettingsPage(this);
|
||||||
AddPage(Page_Wiimotedev, wii_page, general);
|
general->AddPage(Page_Wiimotedev, wii_page);
|
||||||
connect(wii_page, SIGNAL(SetWiimotedevInterfaceActived(bool)),
|
connect(wii_page, SIGNAL(SetWiimotedevInterfaceActived(bool)),
|
||||||
SIGNAL(SetWiimotedevInterfaceActived(bool)));
|
SIGNAL(SetWiimotedevInterfaceActived(bool)));
|
||||||
#endif
|
#endif
|
||||||
|
@ -157,14 +157,14 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||||
// User interface
|
// User interface
|
||||||
SettingsCategory* iface = new SettingsCategory(tr("User interface"), this);
|
SettingsCategory* iface = new SettingsCategory(tr("User interface"), this);
|
||||||
AddCategory(iface);
|
AddCategory(iface);
|
||||||
AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this), iface);
|
iface->AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this));
|
||||||
AddPage(Page_GlobalSearch, new GlobalSearchSettingsPage(this), iface);
|
iface->AddPage(Page_GlobalSearch, new GlobalSearchSettingsPage(this));
|
||||||
AddPage(Page_Appearance, new AppearanceSettingsPage(this), iface);
|
iface->AddPage(Page_Appearance, new AppearanceSettingsPage(this));
|
||||||
AddPage(Page_SongInformation, new SongInfoSettingsPage(this), iface);
|
iface->AddPage(Page_SongInformation, new SongInfoSettingsPage(this));
|
||||||
|
|
||||||
NotificationsSettingsPage* notification_page =
|
NotificationsSettingsPage* notification_page =
|
||||||
new NotificationsSettingsPage(this);
|
new NotificationsSettingsPage(this);
|
||||||
AddPage(Page_Notifications, notification_page, iface);
|
iface->AddPage(Page_Notifications, notification_page);
|
||||||
connect(notification_page,
|
connect(notification_page,
|
||||||
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)),
|
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)),
|
||||||
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)));
|
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)));
|
||||||
|
@ -176,43 +176,43 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||||
AddCategory(providers);
|
AddCategory(providers);
|
||||||
|
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
AddPage(Page_Lastfm, new LastFMSettingsPage(this), providers);
|
providers->AddPage(Page_Lastfm, new LastFMSettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_GOOGLE_DRIVE
|
#ifdef HAVE_GOOGLE_DRIVE
|
||||||
AddPage(Page_GoogleDrive, new GoogleDriveSettingsPage(this), providers);
|
providers->AddPage(Page_GoogleDrive, new GoogleDriveSettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DROPBOX
|
#ifdef HAVE_DROPBOX
|
||||||
AddPage(Page_Dropbox, new DropboxSettingsPage(this), providers);
|
providers->AddPage(Page_Dropbox, new DropboxSettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_BOX
|
#ifdef HAVE_BOX
|
||||||
AddPage(Page_Box, new BoxSettingsPage(this), providers);
|
providers->AddPage(Page_Box, new BoxSettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SKYDRIVE
|
#ifdef HAVE_SKYDRIVE
|
||||||
AddPage(Page_Skydrive, new SkydriveSettingsPage(this), providers);
|
providers->AddPage(Page_Skydrive, new SkydriveSettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SPOTIFY
|
#ifdef HAVE_SPOTIFY
|
||||||
AddPage(Page_Spotify, new SpotifySettingsPage(this), providers);
|
providers->AddPage(Page_Spotify, new SpotifySettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SEAFILE
|
#ifdef HAVE_SEAFILE
|
||||||
AddPage(Page_Seafile, new SeafileSettingsPage(this), providers);
|
providers->AddPage(Page_Seafile, new SeafileSettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AMAZON_CLOUD_DRIVE
|
#ifdef HAVE_AMAZON_CLOUD_DRIVE
|
||||||
AddPage(Page_AmazonCloudDrive, new AmazonSettingsPage(this), providers);
|
providers->AddPage(Page_AmazonCloudDrive, new AmazonSettingsPage(this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AddPage(Page_Magnatune, new MagnatuneSettingsPage(this), providers);
|
providers->AddPage(Page_Magnatune, new MagnatuneSettingsPage(this));
|
||||||
AddPage(Page_DigitallyImported, new DigitallyImportedSettingsPage(this),
|
providers->AddPage(Page_DigitallyImported,
|
||||||
providers);
|
new DigitallyImportedSettingsPage(this));
|
||||||
AddPage(Page_Subsonic, new SubsonicSettingsPage(this), providers);
|
providers->AddPage(Page_Subsonic, new SubsonicSettingsPage(this));
|
||||||
AddPage(Page_Podcasts, new PodcastSettingsPage(this), providers);
|
providers->AddPage(Page_Podcasts, new PodcastSettingsPage(this));
|
||||||
AddPage(Page_RadioBrowser, new RadioBrowserSettingsPage(this), providers);
|
providers->AddPage(Page_RadioBrowser, new RadioBrowserSettingsPage(this));
|
||||||
|
|
||||||
providers->sortChildren(0, Qt::AscendingOrder);
|
providers->sortChildren(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
|
@ -238,25 +238,6 @@ void SettingsDialog::AddCategory(SettingsCategory* category) {
|
||||||
category->setExpanded(true);
|
category->setExpanded(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::AddPage(Page id, SettingsPage* page,
|
|
||||||
QTreeWidgetItem* parent) {
|
|
||||||
if (!parent) parent = ui_->list->invisibleRootItem();
|
|
||||||
|
|
||||||
// Create the list item
|
|
||||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
|
||||||
item->setText(0, page->windowTitle());
|
|
||||||
item->setIcon(0, page->windowIcon());
|
|
||||||
item->setData(0, Role_IsSeparator, false);
|
|
||||||
|
|
||||||
if (!page->IsEnabled()) {
|
|
||||||
item->setFlags(Qt::NoItemFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
parent->addChild(item);
|
|
||||||
|
|
||||||
AddPageToStack(id, page, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsDialog::AddPageToStack(Page id, SettingsPage* page,
|
void SettingsDialog::AddPageToStack(Page id, SettingsPage* page,
|
||||||
QTreeWidgetItem* item) {
|
QTreeWidgetItem* item) {
|
||||||
// Create a scroll area containing the page
|
// Create a scroll area containing the page
|
||||||
|
|
|
@ -134,7 +134,6 @@ class SettingsDialog : public QDialog {
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddCategory(SettingsCategory* category);
|
void AddCategory(SettingsCategory* category);
|
||||||
void AddPage(Page id, SettingsPage* page, QTreeWidgetItem* parent = nullptr);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SettingsCategory;
|
friend class SettingsCategory;
|
||||||
|
|
Loading…
Reference in New Issue