annotate src/gui/dialog/settings/application.cc @ 332:92f63cf29faa

dialog/about: fix displaying of my email address
author Paper <paper@paper.us.eu.org>
date Mon, 17 Jun 2024 20:03:35 -0400
parents b1f4d1867ab1
children
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"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
4 #include "gui/locale.h"
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
5 #include "gui/theme.h"
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
6 #include "gui/translate/anime.h"
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
7 #include "gui/translate/config.h"
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
8
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
9 #include <QCheckBox>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
10 #include <QComboBox>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
11 #include <QGroupBox>
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
12 #include <QHBoxLayout>
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
13 #include <QLabel>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
14 #include <QPushButton>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
15 #include <QSizePolicy>
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
16 #include <QVBoxLayout>
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
17
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
18 QWidget* SettingsPageApplication::CreateAnimeListWidget() {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
19 QWidget* result = new QWidget(this);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
20 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
21
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
22 QVBoxLayout* full_layout = new QVBoxLayout(result);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
23
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
24 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
25 /* Actions */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
26 QGroupBox* actions_group_box = new QGroupBox(tr("Actions"), result);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
27 actions_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
28
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
29 QHBoxLayout* actions_layout = new QHBoxLayout(actions_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
30
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
31 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
32 /* Actions/Double click */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
33 QWidget* double_click_widget = new QWidget(actions_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
34 QLabel* dc_combo_box_label = new QLabel(tr("Double click:"), double_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
35 QComboBox* dc_combo_box = new QComboBox(double_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
36 dc_combo_box->addItem(tr("View anime info"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
37
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
38 QVBoxLayout* double_click_layout = new QVBoxLayout(double_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
39 double_click_layout->addWidget(dc_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
40 double_click_layout->addWidget(dc_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
41 double_click_layout->setContentsMargins(0, 0, 0, 0);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
42
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
43 actions_layout->addWidget(double_click_widget);
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 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
47 /* Actions/Middle click */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
48 QWidget* middle_click_widget = new QWidget(actions_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
49 QLabel* mc_combo_box_label = new QLabel(tr("Middle click:"), middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
50 QComboBox* mc_combo_box = new QComboBox(middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
51 mc_combo_box->addItem(tr("Play next episode"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
52
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
53 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
54 middle_click_layout->addWidget(mc_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
55 middle_click_layout->addWidget(mc_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
56 middle_click_layout->setContentsMargins(0, 0, 0, 0);
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
57
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
58 actions_layout->addWidget(middle_click_widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
59 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
60
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
61 full_layout->addWidget(actions_group_box);
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 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
65 /* Appearance */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
66 QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
67 appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
68
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
69 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
70
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
71 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
72 /* Title language */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
73 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
74 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
75 appearance_layout->addWidget(lang_combo_box_label);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
76 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
77 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
78 QComboBox* lang_combo_box = new QComboBox(appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
79 lang_combo_box->addItem(tr("Romaji"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
80 lang_combo_box->addItem(tr("Native"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
81 lang_combo_box->addItem(tr("English"));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
82 connect(lang_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
83 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
84 lang_combo_box->setCurrentIndex(static_cast<int>(language));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
85 appearance_layout->addWidget(lang_combo_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
86 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
87 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
88
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
89 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
90 /* Application theme */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
91 {
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
92 QLabel* rating_combo_box_label = new QLabel(tr("Rating system:"), appearance_group_box);
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
93 appearance_layout->addWidget(rating_combo_box_label);
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
94 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
95
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
96 {
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
97 QComboBox* rating_combo_box = new QComboBox(appearance_group_box);
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
98
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
99 for (const auto& score_format : Anime::ScoreFormats)
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
100 rating_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(score_format)),
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
101 static_cast<int>(score_format));
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
102
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
103 connect(rating_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
104 [this, rating_combo_box](int index) {
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
105 format = static_cast<Anime::ScoreFormat>(rating_combo_box->itemData(index).toInt());
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
106 });
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
107
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
108 rating_combo_box->setCurrentIndex(static_cast<int>(format));
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
109 appearance_layout->addWidget(rating_combo_box);
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
110 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
111 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
112
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
113 {
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
114 /* Hopefully I made this easy to read... */
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
115 QCheckBox* hl_above_anime_box =
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
116 new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
117 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
118 hl_above_anime_box->setEnabled(highlight_anime_if_available);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
119 hl_above_anime_box->setContentsMargins(10, 0, 0, 0);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
120
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
121 connect(hl_above_anime_box, &QCheckBox::stateChanged, this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
122 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); });
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
123
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
124 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
125 /* This is here because the above checkbox actually depends on it to be checked. */
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
126 QCheckBox* hl_anime_box = new QCheckBox(
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
127 tr("Highlight anime if next episode is available in library folders"), appearance_group_box);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
128 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
129
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
130 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
131 highlight_anime_if_available = !(state == Qt::Unchecked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
132 hl_above_anime_box->setEnabled(state);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
133 });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
134
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
135 appearance_layout->addWidget(hl_anime_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
136 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
137
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
138 appearance_layout->addWidget(hl_above_anime_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
139 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
140
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
141 full_layout->addWidget(appearance_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
142 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
143
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
144 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
145 /* Progress */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
146 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
147 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
148
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
149 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
150
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
151 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
152 QCheckBox* progress_display_aired_episodes =
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
153 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
154 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
155 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); });
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
156 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
157 progress_layout->addWidget(progress_display_aired_episodes);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
158 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
159 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
160 QCheckBox* progress_display_available_episodes =
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
161 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
162 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
163 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); });
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
164 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
165 : Qt::Unchecked);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
166 progress_layout->addWidget(progress_display_available_episodes);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
167 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
168
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
169 full_layout->addWidget(progress_group_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
170 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
171
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
172 full_layout->setSpacing(10);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
173 full_layout->addStretch();
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
174
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
175 return result;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
176 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
177
195
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
178 QWidget* SettingsPageApplication::CreateGeneralWidget() {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
179 QWidget* result = new QWidget(this);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
180 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
181
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
182 QVBoxLayout* full_layout = new QVBoxLayout(result);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
183
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
184 {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
185 /* Appearance */
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
186 QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
187 appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
188
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
189 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
190
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
191 {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
192 /* Application theme */
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
193 {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
194 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
195 appearance_layout->addWidget(theme_combo_box_label);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
196 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
197
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
198 {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
199 /* FIXME: don't hardcode these values */
195
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
200 QComboBox* theme_combo_box = new QComboBox(appearance_group_box);
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
201 for (const auto& theme : Theme::Themes)
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
202 theme_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(theme)));
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
203
195
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
204 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
205 [this](int index) { theme = static_cast<Theme::Theme>(index); });
195
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
206 theme_combo_box->setCurrentIndex(static_cast<int>(theme));
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
207 appearance_layout->addWidget(theme_combo_box);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
208 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
209 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
210
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
211 {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
212 /* Application locale */
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
213 {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
214 QLabel* locale_combo_box_label = new QLabel(tr("Application locale:"), appearance_group_box);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
215 appearance_layout->addWidget(locale_combo_box_label);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
216 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
217
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
218 {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
219 QComboBox* locale_combo_box = new QComboBox(appearance_group_box);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
220 const auto& available_locales = session.config.locale.GetAvailableLocales();
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
221 for (const auto& l : available_locales)
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
222 locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
223
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
224 connect(locale_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 232
diff changeset
225 [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); });
195
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
226
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
227 for (size_t i = 0; i < available_locales.size(); i++)
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
228 if (available_locales[i] == locale)
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
229 locale_combo_box->setCurrentIndex(i);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
230
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
231 appearance_layout->addWidget(locale_combo_box);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
232 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
233 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
234
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
235 full_layout->addWidget(appearance_group_box);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
236 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
237
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
238 full_layout->setSpacing(10);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
239 full_layout->addStretch();
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
240
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
241 return result;
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
242 }
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
243
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
244 void SettingsPageApplication::SaveInfo() {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
245 session.config.anime_list.language = language;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
246 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
247 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
248 session.config.anime_list.display_aired_episodes = display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
249 session.config.anime_list.display_available_episodes = display_available_episodes;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
250 session.config.theme.SetTheme(theme);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
251 session.config.locale.SetActiveLocale(locale);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
252 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
253
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
254 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
255 language = session.config.anime_list.language;
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
256 format = session.config.anime_list.score_format;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
257 theme = session.config.theme.GetTheme();
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
258 locale = session.config.locale.GetLocale();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
259 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
260 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
261 display_aired_episodes = session.config.anime_list.display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
262 display_available_episodes = session.config.anime_list.display_available_episodes;
195
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 189
diff changeset
263 AddTab(CreateGeneralWidget(), tr("General"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
264 AddTab(CreateAnimeListWidget(), tr("Anime list"));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
265 }