settings: Add SettingsCategory class
Add a new category class for settings. This will eventually allow category classes to maintain their own lists of subpages.
This commit is contained in:
parent
fdb3f7ac37
commit
6b34d0435f
|
@ -363,6 +363,7 @@ set(SOURCES
|
||||||
ui/playbacksettingspage.cpp
|
ui/playbacksettingspage.cpp
|
||||||
ui/qtsystemtrayicon.cpp
|
ui/qtsystemtrayicon.cpp
|
||||||
ui/screensaver.cpp
|
ui/screensaver.cpp
|
||||||
|
ui/settingscategory.cpp
|
||||||
ui/settingsdialog.cpp
|
ui/settingsdialog.cpp
|
||||||
ui/settingspage.cpp
|
ui/settingspage.cpp
|
||||||
ui/splash.cpp
|
ui/splash.cpp
|
||||||
|
@ -659,6 +660,7 @@ set(HEADERS
|
||||||
ui/organiseerrordialog.h
|
ui/organiseerrordialog.h
|
||||||
ui/playbacksettingspage.h
|
ui/playbacksettingspage.h
|
||||||
ui/qtsystemtrayicon.h
|
ui/qtsystemtrayicon.h
|
||||||
|
ui/settingscategory.h
|
||||||
ui/settingsdialog.h
|
ui/settingsdialog.h
|
||||||
ui/settingspage.h
|
ui/settingspage.h
|
||||||
ui/standarditemiconloader.h
|
ui/standarditemiconloader.h
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2021, Jim Broadus <jbroadus@gmail.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "settingscategory.h"
|
||||||
|
|
||||||
|
SettingsCategory::SettingsCategory(const QString& name, SettingsDialog* dialog)
|
||||||
|
: dialog_(dialog) {
|
||||||
|
setText(0, name);
|
||||||
|
setData(0, SettingsDialog::Role_IsSeparator, true);
|
||||||
|
setFlags(Qt::ItemIsEnabled);
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2021, Jim Broadus <jbroadus@gmail.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SETTINGSCATEGORY_H
|
||||||
|
#define SETTINGSCATEGORY_H
|
||||||
|
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
|
class SettingsCategory : public QTreeWidgetItem {
|
||||||
|
public:
|
||||||
|
SettingsCategory(const QString& name, SettingsDialog* dialog);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SettingsDialog* dialog_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SETTINGSCATEGORY_H
|
|
@ -44,6 +44,7 @@
|
||||||
#include "notificationssettingspage.h"
|
#include "notificationssettingspage.h"
|
||||||
#include "playbacksettingspage.h"
|
#include "playbacksettingspage.h"
|
||||||
#include "playlist/playlistview.h"
|
#include "playlist/playlistview.h"
|
||||||
|
#include "settingscategory.h"
|
||||||
#include "songinfo/songinfosettingspage.h"
|
#include "songinfo/songinfosettingspage.h"
|
||||||
#include "transcoder/transcodersettingspage.h"
|
#include "transcoder/transcodersettingspage.h"
|
||||||
#include "ui_settingsdialog.h"
|
#include "ui_settingsdialog.h"
|
||||||
|
@ -134,8 +135,8 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
ui_->list->setItemDelegate(new SettingsItemDelegate(this));
|
ui_->list->setItemDelegate(new SettingsItemDelegate(this));
|
||||||
|
|
||||||
QTreeWidgetItem* general = AddCategory(tr("General"));
|
SettingsCategory* general = new SettingsCategory(tr("General"), this);
|
||||||
|
AddCategory(general);
|
||||||
AddPage(Page_Playback, new PlaybackSettingsPage(this), general);
|
AddPage(Page_Playback, new PlaybackSettingsPage(this), general);
|
||||||
AddPage(Page_Behaviour, new BehaviourSettingsPage(this), general);
|
AddPage(Page_Behaviour, new BehaviourSettingsPage(this), general);
|
||||||
AddPage(Page_Library, new LibrarySettingsPage(this), general);
|
AddPage(Page_Library, new LibrarySettingsPage(this), general);
|
||||||
|
@ -153,7 +154,8 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// User interface
|
// User interface
|
||||||
QTreeWidgetItem* iface = AddCategory(tr("User interface"));
|
SettingsCategory* iface = new SettingsCategory(tr("User interface"), this);
|
||||||
|
AddCategory(iface);
|
||||||
AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this), iface);
|
AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this), iface);
|
||||||
AddPage(Page_GlobalSearch, new GlobalSearchSettingsPage(this), iface);
|
AddPage(Page_GlobalSearch, new GlobalSearchSettingsPage(this), iface);
|
||||||
AddPage(Page_Appearance, new AppearanceSettingsPage(this), iface);
|
AddPage(Page_Appearance, new AppearanceSettingsPage(this), iface);
|
||||||
|
@ -169,7 +171,9 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||||
AddPage(Page_InternetShow, new InternetShowSettingsPage(this), iface);
|
AddPage(Page_InternetShow, new InternetShowSettingsPage(this), iface);
|
||||||
|
|
||||||
// Internet providers
|
// Internet providers
|
||||||
QTreeWidgetItem* providers = AddCategory(tr("Internet providers"));
|
SettingsCategory* providers =
|
||||||
|
new SettingsCategory(tr("Internet providers"), this);
|
||||||
|
AddCategory(providers);
|
||||||
|
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
AddPage(Page_Lastfm, new LastFMSettingsPage(this), providers);
|
AddPage(Page_Lastfm, new LastFMSettingsPage(this), providers);
|
||||||
|
@ -228,16 +232,10 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog() { delete ui_; }
|
SettingsDialog::~SettingsDialog() { delete ui_; }
|
||||||
|
|
||||||
QTreeWidgetItem* SettingsDialog::AddCategory(const QString& name) {
|
void SettingsDialog::AddCategory(SettingsCategory* category) {
|
||||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
ui_->list->invisibleRootItem()->addChild(category);
|
||||||
item->setText(0, name);
|
// This must not be called before it's added to the parent.
|
||||||
item->setData(0, Role_IsSeparator, true);
|
category->setExpanded(true);
|
||||||
item->setFlags(Qt::ItemIsEnabled);
|
|
||||||
|
|
||||||
ui_->list->invisibleRootItem()->addChild(item);
|
|
||||||
item->setExpanded(true);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::AddPage(Page id, SettingsPage* page,
|
void SettingsDialog::AddPage(Page id, SettingsPage* page,
|
||||||
|
|
|
@ -49,6 +49,8 @@ class SettingsItemDelegate : public QStyledItemDelegate {
|
||||||
const QModelIndex& index) const;
|
const QModelIndex& index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SettingsCategory;
|
||||||
|
|
||||||
class SettingsDialog : public QDialog {
|
class SettingsDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -131,7 +133,7 @@ class SettingsDialog : public QDialog {
|
||||||
SettingsPage* page_;
|
SettingsPage* page_;
|
||||||
};
|
};
|
||||||
|
|
||||||
QTreeWidgetItem* AddCategory(const QString& name);
|
void AddCategory(SettingsCategory* category);
|
||||||
void AddPage(Page id, SettingsPage* page, QTreeWidgetItem* parent = nullptr);
|
void AddPage(Page id, SettingsPage* page, QTreeWidgetItem* parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue