Mercurial > minori
annotate include/gui/dialog/settings.h @ 316:180714442770
settings: clean up code
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Tue, 11 Jun 2024 15:11:09 -0400 |
parents | 657fda1b9cac |
children | b1f4d1867ab1 |
rev | line source |
---|---|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
1 #ifndef MINORI_GUI_DIALOG_SETTINGS_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
2 #define MINORI_GUI_DIALOG_SETTINGS_H_ |
85 | 3 |
9 | 4 #include "core/anime.h" |
101
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
95
diff
changeset
|
5 #include "core/config.h" |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
6 #include "core/session.h" |
316 | 7 #include "gui/widgets/sidebar.h" |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
8 #include <QDialog> |
316 | 9 #include <QDialogButtonBox> |
10 #include <QLabel> | |
258 | 11 #include <QListWidget> |
108 | 12 #include <QLocale> |
316 | 13 #include <QStackedWidget> |
14 #include <QTabWidget> | |
15 #include <QVBoxLayout> | |
258 | 16 #include <QWidget> |
9 | 17 |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
18 /* !!! MOVE THIS ELSEWHERE! */ |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
19 class DroppableListWidget : public QListWidget { |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
20 Q_OBJECT |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
21 |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
22 public: |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
23 explicit DroppableListWidget(QWidget* parent); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
24 |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
25 signals: |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
26 void FilesDropped(QStringList list); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
27 |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
28 protected: |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
29 void dragEnterEvent(QDragEnterEvent* event) override; |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
30 void dragMoveEvent(QDragMoveEvent* event) override; |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
31 void dropEvent(QDropEvent* event) override; |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
32 }; |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
33 |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
34 class SettingsPage : public QWidget { |
258 | 35 Q_OBJECT |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
36 |
258 | 37 public: |
38 SettingsPage(QWidget* parent = nullptr, QString title = ""); | |
39 void SetTitle(QString title); | |
40 virtual void SaveInfo() = 0; | |
41 void AddTab(QWidget* tab, QString title = ""); | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
42 |
258 | 43 private: |
316 | 44 QLabel page_title_; |
45 QTabWidget tab_widget_; | |
46 QVBoxLayout layout_; | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
47 }; |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
48 |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
49 class SettingsPageServices final : public SettingsPage { |
258 | 50 Q_OBJECT |
108 | 51 |
258 | 52 public: |
53 SettingsPageServices(QWidget* parent = nullptr); | |
54 void SaveInfo() override; | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
55 |
258 | 56 private: |
57 QWidget* CreateMainPage(); | |
58 QWidget* CreateAniListPage(); | |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
59 |
258 | 60 decltype(session.config.service) service; |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
61 }; |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
62 |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
63 class SettingsPageApplication final : public SettingsPage { |
258 | 64 Q_OBJECT |
108 | 65 |
258 | 66 public: |
67 SettingsPageApplication(QWidget* parent = nullptr); | |
68 void SaveInfo() override; | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
69 |
258 | 70 private: |
71 QWidget* CreateAnimeListWidget(); | |
72 QWidget* CreateGeneralWidget(); | |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
73 |
279 | 74 Theme::Theme theme; |
258 | 75 QLocale locale; |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
76 |
258 | 77 decltype(session.config.anime_list.score_format) format; |
78 decltype(session.config.anime_list.language) language; | |
79 decltype(session.config.anime_list.display_aired_episodes) display_aired_episodes; | |
80 decltype(session.config.anime_list.display_available_episodes) display_available_episodes; | |
81 decltype(session.config.anime_list.highlight_anime_if_available) highlight_anime_if_available; | |
82 decltype(session.config.anime_list.highlighted_anime_above_others) highlighted_anime_above_others; | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
83 }; |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
84 |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
85 class SettingsPageTorrents final : public SettingsPage { |
258 | 86 Q_OBJECT |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
87 |
258 | 88 public: |
89 SettingsPageTorrents(QWidget* parent = nullptr); | |
90 void SaveInfo() override; | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
91 |
258 | 92 private: |
93 QWidget* CreateGeneralWidget(); | |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
94 |
258 | 95 decltype(session.config.torrents.feed_link) feed_link; |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
96 }; |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
97 |
119
4eae379cb1ff
settings: add a very early recognition tab for configuring players and extensions
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
98 class SettingsPageRecognition final : public SettingsPage { |
258 | 99 Q_OBJECT |
119
4eae379cb1ff
settings: add a very early recognition tab for configuring players and extensions
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
100 |
258 | 101 public: |
102 SettingsPageRecognition(QWidget* parent = nullptr); | |
103 void SaveInfo() override; | |
119
4eae379cb1ff
settings: add a very early recognition tab for configuring players and extensions
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
104 |
258 | 105 private: |
106 QWidget* CreatePlayersWidget(); | |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
107 |
258 | 108 decltype(session.config.recognition.detect_media_players) detect_media_players; |
109 decltype(session.config.recognition.players) players; | |
119
4eae379cb1ff
settings: add a very early recognition tab for configuring players and extensions
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
110 }; |
4eae379cb1ff
settings: add a very early recognition tab for configuring players and extensions
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
111 |
226 | 112 class SettingsPageLibrary final : public SettingsPage { |
258 | 113 Q_OBJECT |
226 | 114 |
258 | 115 public: |
116 SettingsPageLibrary(QWidget* parent = nullptr); | |
117 void SaveInfo() override; | |
226 | 118 |
258 | 119 private: |
120 QWidget* CreateFoldersWidget(); | |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
121 |
258 | 122 decltype(session.config.library.paths) paths; |
123 decltype(session.config.library.real_time_monitor) real_time_monitor; | |
226 | 124 }; |
125 | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
126 class SettingsDialog final : public QDialog { |
258 | 127 Q_OBJECT |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
128 |
258 | 129 public: |
130 SettingsDialog(QWidget* parent = nullptr); | |
131 QWidget* CreateServicesMainPage(QWidget* parent); | |
132 void OnOK(); | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
133 |
258 | 134 protected: |
135 void showEvent(QShowEvent* event) override; | |
108 | 136 |
258 | 137 private: |
316 | 138 QVBoxLayout layout_; |
139 | |
140 QWidget widget_; | |
141 QHBoxLayout widget_layout_; | |
142 | |
143 SideBar sidebar_; | |
144 QStackedWidget stacked_; | |
145 | |
146 SettingsPageServices services_page_; | |
147 SettingsPageApplication application_page_; | |
148 SettingsPageTorrents torrents_page_; | |
149 SettingsPageRecognition recognition_page_; | |
150 SettingsPageLibrary library_page_; | |
151 | |
152 QDialogButtonBox button_box_; | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
153 }; |
85 | 154 |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
155 #endif // MINORI_GUI_DIALOG_SETTINGS_H_ |