Mercurial > minori
comparison src/gui/dialog/settings/application.cc @ 195:975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
also the general application stuff and anime list is separated in settings
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 07 Dec 2023 11:14:01 -0500 |
parents | 649786bae914 |
children | ff0061e75f0f |
comparison
equal
deleted
inserted
replaced
194:8548dc425697 | 195:975a3f0965e2 |
---|---|
89 } | 89 } |
90 | 90 |
91 { | 91 { |
92 /* Application theme */ | 92 /* Application theme */ |
93 { | 93 { |
94 QLabel* rating_combo_box_label = new QLabel(tr("Rating system:"), appearance_group_box); | |
95 appearance_layout->addWidget(rating_combo_box_label); | |
96 } | |
97 | |
98 { | |
99 QComboBox* rating_combo_box = new QComboBox(appearance_group_box); | |
100 | |
101 for (const auto& score_format : Anime::ScoreFormats) | |
102 rating_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(score_format)), static_cast<int>(score_format)); | |
103 | |
104 connect(rating_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | |
105 [this, rating_combo_box](int index) { format = static_cast<Anime::ScoreFormat>(rating_combo_box->itemData(index).toInt()); }); | |
106 | |
107 rating_combo_box->setCurrentIndex(static_cast<int>(format)); | |
108 appearance_layout->addWidget(rating_combo_box); | |
109 } | |
110 } | |
111 | |
112 { | |
113 /* Hopefully I made this easy to parse... */ | |
114 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box); | |
115 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked); | |
116 hl_above_anime_box->setEnabled(highlight_anime_if_available); | |
117 hl_above_anime_box->setContentsMargins(10, 0, 0, 0); | |
118 | |
119 connect(hl_above_anime_box, &QCheckBox::stateChanged, this, | |
120 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); }); | |
121 | |
122 { | |
123 /* This is here because the above checkbox actually depends on it to be checked. */ | |
124 QCheckBox* hl_anime_box = new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box); | |
125 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked); | |
126 | |
127 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) { | |
128 highlight_anime_if_available = !(state == Qt::Unchecked); | |
129 hl_above_anime_box->setEnabled(state); | |
130 }); | |
131 | |
132 appearance_layout->addWidget(hl_anime_box); | |
133 } | |
134 | |
135 appearance_layout->addWidget(hl_above_anime_box); | |
136 } | |
137 | |
138 full_layout->addWidget(appearance_group_box); | |
139 } | |
140 | |
141 { | |
142 /* Progress */ | |
143 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result); | |
144 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
145 | |
146 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box); | |
147 | |
148 { | |
149 QCheckBox* progress_display_aired_episodes = | |
150 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box); | |
151 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this, | |
152 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); }); | |
153 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked); | |
154 progress_layout->addWidget(progress_display_aired_episodes); | |
155 } | |
156 { | |
157 QCheckBox* progress_display_available_episodes = | |
158 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box); | |
159 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this, | |
160 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); }); | |
161 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked); | |
162 progress_layout->addWidget(progress_display_available_episodes); | |
163 } | |
164 | |
165 full_layout->addWidget(progress_group_box); | |
166 } | |
167 | |
168 full_layout->setSpacing(10); | |
169 full_layout->addStretch(); | |
170 | |
171 return result; | |
172 } | |
173 | |
174 QWidget* SettingsPageApplication::CreateGeneralWidget() { | |
175 QWidget* result = new QWidget(this); | |
176 result->setAutoFillBackground(true); | |
177 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
178 | |
179 QVBoxLayout* full_layout = new QVBoxLayout(result); | |
180 | |
181 { | |
182 /* Appearance */ | |
183 QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result); | |
184 appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
185 | |
186 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box); | |
187 | |
188 { | |
189 /* Application theme */ | |
190 { | |
94 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); | 191 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); |
95 appearance_layout->addWidget(theme_combo_box_label); | 192 appearance_layout->addWidget(theme_combo_box_label); |
96 } | 193 } |
97 | 194 |
98 { | 195 { |
129 | 226 |
130 appearance_layout->addWidget(locale_combo_box); | 227 appearance_layout->addWidget(locale_combo_box); |
131 } | 228 } |
132 } | 229 } |
133 | 230 |
134 { | |
135 /* Application theme */ | |
136 { | |
137 QLabel* rating_combo_box_label = new QLabel(tr("Rating system:"), appearance_group_box); | |
138 appearance_layout->addWidget(rating_combo_box_label); | |
139 } | |
140 | |
141 { | |
142 QComboBox* rating_combo_box = new QComboBox(appearance_group_box); | |
143 | |
144 for (const auto& score_format : Anime::ScoreFormats) | |
145 rating_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(score_format)), static_cast<int>(score_format)); | |
146 | |
147 connect(rating_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | |
148 [this, rating_combo_box](int index) { format = static_cast<Anime::ScoreFormat>(rating_combo_box->itemData(index).toInt()); }); | |
149 | |
150 rating_combo_box->setCurrentIndex(static_cast<int>(format)); | |
151 appearance_layout->addWidget(rating_combo_box); | |
152 } | |
153 } | |
154 | |
155 { | |
156 /* Hopefully I made this easy to parse... */ | |
157 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box); | |
158 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked); | |
159 hl_above_anime_box->setEnabled(highlight_anime_if_available); | |
160 hl_above_anime_box->setContentsMargins(10, 0, 0, 0); | |
161 | |
162 connect(hl_above_anime_box, &QCheckBox::stateChanged, this, | |
163 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); }); | |
164 | |
165 { | |
166 /* This is here because the above checkbox actually depends on it to be checked. */ | |
167 QCheckBox* hl_anime_box = new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box); | |
168 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked); | |
169 | |
170 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) { | |
171 highlight_anime_if_available = !(state == Qt::Unchecked); | |
172 hl_above_anime_box->setEnabled(state); | |
173 }); | |
174 | |
175 appearance_layout->addWidget(hl_anime_box); | |
176 } | |
177 | |
178 appearance_layout->addWidget(hl_above_anime_box); | |
179 } | |
180 | |
181 full_layout->addWidget(appearance_group_box); | 231 full_layout->addWidget(appearance_group_box); |
182 } | |
183 | |
184 { | |
185 /* Progress */ | |
186 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result); | |
187 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
188 | |
189 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box); | |
190 | |
191 { | |
192 QCheckBox* progress_display_aired_episodes = | |
193 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box); | |
194 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this, | |
195 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); }); | |
196 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked); | |
197 progress_layout->addWidget(progress_display_aired_episodes); | |
198 } | |
199 { | |
200 QCheckBox* progress_display_available_episodes = | |
201 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box); | |
202 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this, | |
203 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); }); | |
204 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked); | |
205 progress_layout->addWidget(progress_display_available_episodes); | |
206 } | |
207 | |
208 full_layout->addWidget(progress_group_box); | |
209 } | 232 } |
210 | 233 |
211 full_layout->setSpacing(10); | 234 full_layout->setSpacing(10); |
212 full_layout->addStretch(); | 235 full_layout->addStretch(); |
213 | 236 |
214 return result; | 237 return result; |
215 } | 238 } |
239 | |
216 | 240 |
217 void SettingsPageApplication::SaveInfo() { | 241 void SettingsPageApplication::SaveInfo() { |
218 session.config.anime_list.language = language; | 242 session.config.anime_list.language = language; |
219 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others; | 243 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others; |
220 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available; | 244 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available; |
231 locale = session.config.locale.GetLocale(); | 255 locale = session.config.locale.GetLocale(); |
232 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others; | 256 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others; |
233 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available; | 257 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available; |
234 display_aired_episodes = session.config.anime_list.display_aired_episodes; | 258 display_aired_episodes = session.config.anime_list.display_aired_episodes; |
235 display_available_episodes = session.config.anime_list.display_available_episodes; | 259 display_available_episodes = session.config.anime_list.display_available_episodes; |
260 AddTab(CreateGeneralWidget(), tr("General")); | |
236 AddTab(CreateAnimeListWidget(), tr("Anime list")); | 261 AddTab(CreateAnimeListWidget(), tr("Anime list")); |
237 } | 262 } |