comparison src/gui/dialog/settings/application.cc @ 258:862d0d8619f6

*: HUUUGE changes animia has been renamed to animone, so instead of thinking of a health condition, you think of a beautiful flower :) I've also edited some of the code for animone, but I have no idea if it even works or not because I don't have a mac or windows machine lying around. whoops! ... anyway, all of the changes divergent from Anisthesia are now licensed under BSD. it's possible that I could even rewrite most of the code to where I don't even have to keep the MIT license, but that's thinking too far into the future I've been slacking off on implementing the anime seasons page, mostly out of laziness. I think I'd have to create another db file specifically for the seasons anyway, this code is being pushed *primarily* because the hard drive it's on is failing! yay :)
author Paper <paper@paper.us.eu.org>
date Mon, 01 Apr 2024 02:43:44 -0400
parents ff0061e75f0f
children 657fda1b9cac
comparison
equal deleted inserted replaced
257:699a20c57dc8 258:862d0d8619f6
1 #include "core/session.h" 1 #include "core/session.h"
2 #include "core/strings.h" 2 #include "core/strings.h"
3 #include "gui/dialog/settings.h" 3 #include "gui/dialog/settings.h"
4 #include "gui/locale.h"
4 #include "gui/theme.h" 5 #include "gui/theme.h"
5 #include "gui/locale.h"
6 #include "gui/translate/anime.h" 6 #include "gui/translate/anime.h"
7 7
8 #include <QCheckBox> 8 #include <QCheckBox>
9 #include <QComboBox> 9 #include <QComboBox>
10 #include <QGroupBox> 10 #include <QGroupBox>
53 53
54 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget); 54 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget);
55 middle_click_layout->addWidget(mc_combo_box_label); 55 middle_click_layout->addWidget(mc_combo_box_label);
56 middle_click_layout->addWidget(mc_combo_box); 56 middle_click_layout->addWidget(mc_combo_box);
57 middle_click_layout->setContentsMargins(0, 0, 0, 0); 57 middle_click_layout->setContentsMargins(0, 0, 0, 0);
58 58
59 actions_layout->addWidget(middle_click_widget); 59 actions_layout->addWidget(middle_click_widget);
60 } 60 }
61 61
62 full_layout->addWidget(actions_group_box); 62 full_layout->addWidget(actions_group_box);
63 } 63 }
96 96
97 { 97 {
98 QComboBox* rating_combo_box = new QComboBox(appearance_group_box); 98 QComboBox* rating_combo_box = new QComboBox(appearance_group_box);
99 99
100 for (const auto& score_format : Anime::ScoreFormats) 100 for (const auto& score_format : Anime::ScoreFormats)
101 rating_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(score_format)), static_cast<int>(score_format)); 101 rating_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(score_format)),
102 static_cast<int>(score_format));
102 103
103 connect(rating_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, 104 connect(rating_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
104 [this, rating_combo_box](int index) { format = static_cast<Anime::ScoreFormat>(rating_combo_box->itemData(index).toInt()); }); 105 [this, rating_combo_box](int index) {
106 format = static_cast<Anime::ScoreFormat>(rating_combo_box->itemData(index).toInt());
107 });
105 108
106 rating_combo_box->setCurrentIndex(static_cast<int>(format)); 109 rating_combo_box->setCurrentIndex(static_cast<int>(format));
107 appearance_layout->addWidget(rating_combo_box); 110 appearance_layout->addWidget(rating_combo_box);
108 } 111 }
109 } 112 }
110 113
111 { 114 {
112 /* Hopefully I made this easy to parse... */ 115 /* Hopefully I made this easy to parse... */
113 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box); 116 QCheckBox* hl_above_anime_box =
117 new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box);
114 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked); 118 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked);
115 hl_above_anime_box->setEnabled(highlight_anime_if_available); 119 hl_above_anime_box->setEnabled(highlight_anime_if_available);
116 hl_above_anime_box->setContentsMargins(10, 0, 0, 0); 120 hl_above_anime_box->setContentsMargins(10, 0, 0, 0);
117 121
118 connect(hl_above_anime_box, &QCheckBox::stateChanged, this, 122 connect(hl_above_anime_box, &QCheckBox::stateChanged, this,
119 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); }); 123 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); });
120 124
121 { 125 {
122 /* This is here because the above checkbox actually depends on it to be checked. */ 126 /* This is here because the above checkbox actually depends on it to be checked. */
123 QCheckBox* hl_anime_box = new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box); 127 QCheckBox* hl_anime_box = new QCheckBox(
128 tr("Highlight anime if next episode is available in library folders"), appearance_group_box);
124 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked); 129 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked);
125 130
126 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) { 131 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) {
127 highlight_anime_if_available = !(state == Qt::Unchecked); 132 highlight_anime_if_available = !(state == Qt::Unchecked);
128 hl_above_anime_box->setEnabled(state); 133 hl_above_anime_box->setEnabled(state);
155 { 160 {
156 QCheckBox* progress_display_available_episodes = 161 QCheckBox* progress_display_available_episodes =
157 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box); 162 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box);
158 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this, 163 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this,
159 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); }); 164 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); });
160 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked); 165 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked
166 : Qt::Unchecked);
161 progress_layout->addWidget(progress_display_available_episodes); 167 progress_layout->addWidget(progress_display_available_episodes);
162 } 168 }
163 169
164 full_layout->addWidget(progress_group_box); 170 full_layout->addWidget(progress_group_box);
165 } 171 }
194 QComboBox* theme_combo_box = new QComboBox(appearance_group_box); 200 QComboBox* theme_combo_box = new QComboBox(appearance_group_box);
195 theme_combo_box->addItem(tr("Default")); 201 theme_combo_box->addItem(tr("Default"));
196 theme_combo_box->addItem(tr("Light")); 202 theme_combo_box->addItem(tr("Light"));
197 theme_combo_box->addItem(tr("Dark")); 203 theme_combo_box->addItem(tr("Dark"));
198 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, 204 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
199 [this](int index) { theme = static_cast<Themes>(index); }); 205 [this](int index) { theme = static_cast<Themes>(index); });
200 theme_combo_box->setCurrentIndex(static_cast<int>(theme)); 206 theme_combo_box->setCurrentIndex(static_cast<int>(theme));
201 appearance_layout->addWidget(theme_combo_box); 207 appearance_layout->addWidget(theme_combo_box);
202 } 208 }
203 } 209 }
204 210
214 const auto& available_locales = session.config.locale.GetAvailableLocales(); 220 const auto& available_locales = session.config.locale.GetAvailableLocales();
215 for (const auto& l : available_locales) 221 for (const auto& l : available_locales)
216 locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l); 222 locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l);
217 223
218 connect(locale_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, 224 connect(locale_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
219 [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); }); 225 [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); });
220 226
221 for (size_t i = 0; i < available_locales.size(); i++) 227 for (size_t i = 0; i < available_locales.size(); i++)
222 if (available_locales[i] == locale) 228 if (available_locales[i] == locale)
223 locale_combo_box->setCurrentIndex(i); 229 locale_combo_box->setCurrentIndex(i);
224 230
232 full_layout->setSpacing(10); 238 full_layout->setSpacing(10);
233 full_layout->addStretch(); 239 full_layout->addStretch();
234 240
235 return result; 241 return result;
236 } 242 }
237
238 243
239 void SettingsPageApplication::SaveInfo() { 244 void SettingsPageApplication::SaveInfo() {
240 session.config.anime_list.language = language; 245 session.config.anime_list.language = language;
241 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others; 246 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others;
242 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available; 247 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available;