annotate src/gui/dialog/settings/application.cc @ 187:9613d72b097e

*: multiple performance improvements like marking `static const` when it makes sense... date: change old stupid heap-based method to a structure which should make copying the thing actually make a copy. also many performance-based changes, like removing the std::tie dependency and forward-declaring nlohmann json *: replace every instance of QString::fromUtf8 to Strings::ToQString. the main difference is that our function will always convert exactly what is in the string, while some other times it would only convert up to the nearest NUL byte
author Paper <mrpapersonic@gmail.com>
date Wed, 06 Dec 2023 13:43:54 -0500
parents 80f49f623d30
children 649786bae914
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"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
2 #include "core/strings.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
3 #include "gui/dialog/settings.h"
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
4 #include "gui/theme.h"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
5 #include "gui/locale.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
6 #include <QCheckBox>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
7 #include <QComboBox>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
8 #include <QGroupBox>
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
9 #include <QHBoxLayout>
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
10 #include <QLabel>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
11 #include <QPushButton>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
12 #include <QSizePolicy>
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
13 #include <QVBoxLayout>
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
14 #include <algorithm>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
15
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
16 QWidget* SettingsPageApplication::CreateAnimeListWidget() {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
17 QWidget* result = new QWidget(this);
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
18 result->setAutoFillBackground(true);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
19 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
20
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
21 QVBoxLayout* full_layout = new QVBoxLayout(result);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
22
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
23 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
24 /* Actions */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
25 QGroupBox* actions_group_box = new QGroupBox(tr("Actions"), result);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
26 actions_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
27
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
28 QHBoxLayout* actions_layout = new QHBoxLayout(actions_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
29
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
30 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
31 /* Actions/Double click */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
32 QWidget* double_click_widget = new QWidget(actions_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
33 QLabel* dc_combo_box_label = new QLabel(tr("Double click:"), double_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
34 QComboBox* dc_combo_box = new QComboBox(double_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
35 dc_combo_box->addItem(tr("View anime info"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
36
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
37 QVBoxLayout* double_click_layout = new QVBoxLayout(double_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
38 double_click_layout->addWidget(dc_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
39 double_click_layout->addWidget(dc_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
40 double_click_layout->setContentsMargins(0, 0, 0, 0);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
41
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
42 actions_layout->addWidget(double_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
43 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
44
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
45 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
46 /* Actions/Middle click */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
47 QWidget* middle_click_widget = new QWidget(actions_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
48 QLabel* mc_combo_box_label = new QLabel(tr("Middle click:"), middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
49 QComboBox* mc_combo_box = new QComboBox(middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
50 mc_combo_box->addItem(tr("Play next episode"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
51
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
52 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
53 middle_click_layout->addWidget(mc_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
54 middle_click_layout->addWidget(mc_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
55 middle_click_layout->setContentsMargins(0, 0, 0, 0);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
56
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
57 actions_layout->addWidget(middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
58 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
59
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
60 full_layout->addWidget(actions_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
61 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
62
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
63 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
64 /* Appearance */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
65 QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
66 appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
67
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
68 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
69
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
70 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
71 /* Title language */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
72 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
73 QLabel* lang_combo_box_label = new QLabel(tr("Title language preference:"), appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
74 appearance_layout->addWidget(lang_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
75 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
76 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
77 QComboBox* lang_combo_box = new QComboBox(appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
78 lang_combo_box->addItem(tr("Romaji"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
79 lang_combo_box->addItem(tr("Native"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
80 lang_combo_box->addItem(tr("English"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
81 connect(lang_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
82 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
83 lang_combo_box->setCurrentIndex(static_cast<int>(language));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
84 appearance_layout->addWidget(lang_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
85 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
86 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
87
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
88 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
89 /* Application theme */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
90 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
91 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
92 appearance_layout->addWidget(theme_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
93 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
94
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
95 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
96 QComboBox* theme_combo_box = new QComboBox(appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
97 theme_combo_box->addItem(tr("Default"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
98 theme_combo_box->addItem(tr("Light"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
99 theme_combo_box->addItem(tr("Dark"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
100 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
101 [this](int index) { theme = static_cast<Themes>(index); });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
102 theme_combo_box->setCurrentIndex(static_cast<int>(theme));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
103 appearance_layout->addWidget(theme_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
104 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
105 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
106
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
107 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
108 /* Application locale */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
109 {
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
110 QLabel* locale_combo_box_label = new QLabel(tr("Set application locale:"), appearance_group_box);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
111 appearance_layout->addWidget(locale_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
112 }
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
113
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
114 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
115 QComboBox* locale_combo_box = new QComboBox(appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
116 const auto& available_locales = session.config.locale.GetAvailableLocales();
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
117 for (const auto& l : available_locales)
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
118 locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
119
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
120 connect(locale_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
121 [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
122
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
123 for (size_t i = 0; i < available_locales.size(); i++)
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
124 if (available_locales[i] == locale)
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
125 locale_combo_box->setCurrentIndex(i);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
126 appearance_layout->addWidget(locale_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
127 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
128 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
129
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
130 {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
131 /* Application theme */
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
132 {
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
133 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box);
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
134 appearance_layout->addWidget(theme_combo_box_label);
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
135 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
136
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
137 {
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
138 QComboBox* theme_combo_box = new QComboBox(appearance_group_box);
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
139 theme_combo_box->addItem(tr("Default"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
140 theme_combo_box->addItem(tr("Light"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
141 theme_combo_box->addItem(tr("Dark"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
142 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
143 [this](int index) { theme = static_cast<Themes>(index); });
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
144 theme_combo_box->setCurrentIndex(static_cast<int>(theme));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
145 appearance_layout->addWidget(theme_combo_box);
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
146 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
147 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
148
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
149 {
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
150 /* Hopefully I made this easy to parse... */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
151 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
152 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
153 hl_above_anime_box->setEnabled(highlight_anime_if_available);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
154 hl_above_anime_box->setContentsMargins(10, 0, 0, 0);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
155
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
156 connect(hl_above_anime_box, &QCheckBox::stateChanged, this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
157 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); });
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
158
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
159 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
160 /* This is here because the above checkbox actually depends on it to be checked. */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
161 QCheckBox* hl_anime_box = new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
162 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
163
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
164 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
165 highlight_anime_if_available = !(state == Qt::Unchecked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
166 hl_above_anime_box->setEnabled(state);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
167 });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
168
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
169 appearance_layout->addWidget(hl_anime_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
170 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
171
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
172 appearance_layout->addWidget(hl_above_anime_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
173 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
174
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
175 full_layout->addWidget(appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
176 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
177
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
178 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
179 /* Progress */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
180 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
181 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
182
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
183 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
184
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
185 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
186 QCheckBox* progress_display_aired_episodes =
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
187 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
188 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
189 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
190 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
191 progress_layout->addWidget(progress_display_aired_episodes);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
192 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
193 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
194 QCheckBox* progress_display_available_episodes =
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
195 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
196 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
197 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
198 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
199 progress_layout->addWidget(progress_display_available_episodes);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
200 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
201
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
202 full_layout->addWidget(progress_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
203 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
204
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
205 full_layout->setSpacing(10);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
206 full_layout->addStretch();
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
207
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
208 return result;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
209 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
210
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
211 void SettingsPageApplication::SaveInfo() {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
212 session.config.anime_list.language = language;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
213 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
214 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
215 session.config.anime_list.display_aired_episodes = display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
216 session.config.anime_list.display_available_episodes = display_available_episodes;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
217 session.config.theme.SetTheme(theme);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
218 session.config.locale.SetActiveLocale(locale);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
219 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
220
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
221 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
222 language = session.config.anime_list.language;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
223 theme = session.config.theme.GetTheme();
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
224 locale = session.config.locale.GetLocale();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
225 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
226 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
227 display_aired_episodes = session.config.anime_list.display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
228 display_available_episodes = session.config.anime_list.display_available_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
229 AddTab(CreateAnimeListWidget(), tr("Anime list"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
230 }