annotate src/gui/dialog/settings/application.cc @ 105:6d8da6e64d61

theme: add dark stylesheet, make it actually usable win32: make the titlebar black where available
author Paper <mrpapersonic@gmail.com>
date Sun, 05 Nov 2023 03:54:26 -0500
parents b315f3759c56
children 2004b41d4a59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
1 #include "core/session.h"
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
2 #include "gui/dialog/settings.h"
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
3 #include "gui/theme.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
4 #include <QCheckBox>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
5 #include <QComboBox>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
6 #include <QGroupBox>
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
7 #include <QHBoxLayout>
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
8 #include <QLabel>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
9 #include <QPushButton>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
10 #include <QSizePolicy>
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
11 #include <QVBoxLayout>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
12
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
13 QWidget* SettingsPageApplication::CreateAnimeListWidget() {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
14 QWidget* result = new QWidget(this);
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
15 result->setAutoFillBackground(true);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
16 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
17
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
18 QGroupBox* actions_group_box = new QGroupBox(tr("Actions"), result);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
19 actions_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
20
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
21 /* Actions/Double click */
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
22 QWidget* double_click_widget = new QWidget(actions_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
23 QLabel* dc_combo_box_label = new QLabel(tr("Double click:"), double_click_widget);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
24 QComboBox* dc_combo_box = new QComboBox(double_click_widget);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
25 dc_combo_box->addItem(tr("View anime info"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
26
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
27 QVBoxLayout* double_click_layout = new QVBoxLayout(double_click_widget);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
28 double_click_layout->addWidget(dc_combo_box_label);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
29 double_click_layout->addWidget(dc_combo_box);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
30 double_click_layout->setContentsMargins(0, 0, 0, 0);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
31
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
32 /* Actions/Middle click */
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
33 QWidget* middle_click_widget = new QWidget(actions_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
34 QLabel* mc_combo_box_label = new QLabel(tr("Middle click:"), middle_click_widget);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
35 QComboBox* mc_combo_box = new QComboBox(middle_click_widget);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
36 mc_combo_box->addItem(tr("Play next episode"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
37
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
38 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
39 middle_click_layout->addWidget(mc_combo_box_label);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
40 middle_click_layout->addWidget(mc_combo_box);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
41 middle_click_layout->setContentsMargins(0, 0, 0, 0);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
42
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
43 /* Actions */
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
44 QHBoxLayout* actions_layout = new QHBoxLayout(actions_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
45 actions_layout->addWidget(double_click_widget);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
46 actions_layout->addWidget(middle_click_widget);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
47
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
48 QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
49 appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
50
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
51 QLabel* lang_combo_box_label = new QLabel(tr("Title language preference:"), appearance_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
52 QComboBox* lang_combo_box = new QComboBox(appearance_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
53 lang_combo_box->addItem(tr("Romaji"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
54 lang_combo_box->addItem(tr("Native"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
55 lang_combo_box->addItem(tr("English"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
56 connect(lang_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
57 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); });
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
58 lang_combo_box->setCurrentIndex(static_cast<int>(language));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
59
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
60 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box);
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
61 QComboBox* theme_combo_box = new QComboBox(appearance_group_box);
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
62 theme_combo_box->addItem(tr("Default"));
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
63 theme_combo_box->addItem(tr("Light"));
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
64 theme_combo_box->addItem(tr("Dark"));
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
65 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
66 [this](int index) { theme = static_cast<Themes>(index); });
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
67 theme_combo_box->setCurrentIndex(static_cast<int>(theme));
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
68
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
69 QCheckBox* hl_anime_box =
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
70 new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
71 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
72 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) {
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
73 highlight_anime_if_available = !(state == Qt::Unchecked);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
74 hl_above_anime_box->setEnabled(state);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
75 });
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
76 connect(hl_above_anime_box, &QCheckBox::stateChanged, this,
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
77 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); });
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
78 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
79 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
80 hl_above_anime_box->setEnabled(hl_anime_box->checkState() != Qt::Unchecked);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
81 hl_above_anime_box->setContentsMargins(10, 0, 0, 0);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
82
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
83 /* Appearance */
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
84 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
85 appearance_layout->addWidget(lang_combo_box_label);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
86 appearance_layout->addWidget(lang_combo_box);
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
87 appearance_layout->addWidget(theme_combo_box_label);
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
88 appearance_layout->addWidget(theme_combo_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
89 appearance_layout->addWidget(hl_anime_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
90 appearance_layout->addWidget(hl_above_anime_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
91
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
92 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
93 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
94
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
95 QCheckBox* progress_display_aired_episodes =
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
96 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
97 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this,
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
98 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); });
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
99 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
100
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
101 QCheckBox* progress_display_available_episodes =
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
102 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
103 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this,
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
104 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); });
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
105 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
106
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
107 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
108 progress_layout->addWidget(progress_display_aired_episodes);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
109 progress_layout->addWidget(progress_display_available_episodes);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
110
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
111 QVBoxLayout* full_layout = new QVBoxLayout(result);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
112 full_layout->addWidget(actions_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
113 full_layout->addWidget(appearance_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
114 full_layout->addWidget(progress_group_box);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
115 full_layout->setSpacing(10);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
116 full_layout->addStretch();
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
117
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
118 return result;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
119 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
120
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
121 void SettingsPageApplication::SaveInfo() {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
122 session.config.anime_list.language = language;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
123 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
124 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
125 session.config.anime_list.display_aired_episodes = display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
126 session.config.anime_list.display_available_episodes = display_available_episodes;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
127 session.config.theme.SetTheme(theme);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
128 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
129
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
130 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
131 language = session.config.anime_list.language;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
132 theme = session.config.theme.GetTheme();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
133 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
134 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
135 display_aired_episodes = session.config.anime_list.display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
136 display_available_episodes = session.config.anime_list.display_available_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
137 AddTab(CreateAnimeListWidget(), tr("Anime list"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
138 }