comparison src/gui/dialog/settings/application.cc @ 189:649786bae914

*: etc. code cleanup I've removed most macros and stuff dep/animia: [UNTESTED] use raw C++ instead of Objective-C++
author Paper <mrpapersonic@gmail.com>
date Wed, 06 Dec 2023 19:42:33 -0500
parents 9613d72b097e
children 975a3f0965e2
comparison
equal deleted inserted replaced
188:168382a89b21 189:649786bae914
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/theme.h" 4 #include "gui/theme.h"
5 #include "gui/locale.h" 5 #include "gui/locale.h"
6 #include "gui/translate/anime.h"
7
6 #include <QCheckBox> 8 #include <QCheckBox>
7 #include <QComboBox> 9 #include <QComboBox>
8 #include <QGroupBox> 10 #include <QGroupBox>
9 #include <QHBoxLayout> 11 #include <QHBoxLayout>
10 #include <QLabel> 12 #include <QLabel>
11 #include <QPushButton> 13 #include <QPushButton>
12 #include <QSizePolicy> 14 #include <QSizePolicy>
13 #include <QVBoxLayout> 15 #include <QVBoxLayout>
16
14 #include <algorithm> 17 #include <algorithm>
15 18
16 QWidget* SettingsPageApplication::CreateAnimeListWidget() { 19 QWidget* SettingsPageApplication::CreateAnimeListWidget() {
17 QWidget* result = new QWidget(this); 20 QWidget* result = new QWidget(this);
18 result->setAutoFillBackground(true); 21 result->setAutoFillBackground(true);
105 } 108 }
106 109
107 { 110 {
108 /* Application locale */ 111 /* Application locale */
109 { 112 {
110 QLabel* locale_combo_box_label = new QLabel(tr("Set application locale:"), appearance_group_box); 113 QLabel* locale_combo_box_label = new QLabel(tr("Application locale:"), appearance_group_box);
111 appearance_layout->addWidget(locale_combo_box_label); 114 appearance_layout->addWidget(locale_combo_box_label);
112 } 115 }
113 116
114 { 117 {
115 QComboBox* locale_combo_box = new QComboBox(appearance_group_box); 118 QComboBox* locale_combo_box = new QComboBox(appearance_group_box);
121 [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); }); 124 [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); });
122 125
123 for (size_t i = 0; i < available_locales.size(); i++) 126 for (size_t i = 0; i < available_locales.size(); i++)
124 if (available_locales[i] == locale) 127 if (available_locales[i] == locale)
125 locale_combo_box->setCurrentIndex(i); 128 locale_combo_box->setCurrentIndex(i);
129
126 appearance_layout->addWidget(locale_combo_box); 130 appearance_layout->addWidget(locale_combo_box);
127 } 131 }
128 } 132 }
129 133
130 { 134 {
131 /* Application theme */ 135 /* Application theme */
132 { 136 {
133 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); 137 QLabel* rating_combo_box_label = new QLabel(tr("Rating system:"), appearance_group_box);
134 appearance_layout->addWidget(theme_combo_box_label); 138 appearance_layout->addWidget(rating_combo_box_label);
135 } 139 }
136 140
137 { 141 {
138 QComboBox* theme_combo_box = new QComboBox(appearance_group_box); 142 QComboBox* rating_combo_box = new QComboBox(appearance_group_box);
139 theme_combo_box->addItem(tr("Default")); 143
140 theme_combo_box->addItem(tr("Light")); 144 for (const auto& score_format : Anime::ScoreFormats)
141 theme_combo_box->addItem(tr("Dark")); 145 rating_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(score_format)), static_cast<int>(score_format));
142 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, 146
143 [this](int index) { theme = static_cast<Themes>(index); }); 147 connect(rating_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
144 theme_combo_box->setCurrentIndex(static_cast<int>(theme)); 148 [this, rating_combo_box](int index) { format = static_cast<Anime::ScoreFormat>(rating_combo_box->itemData(index).toInt()); });
145 appearance_layout->addWidget(theme_combo_box); 149
150 rating_combo_box->setCurrentIndex(static_cast<int>(format));
151 appearance_layout->addWidget(rating_combo_box);
146 } 152 }
147 } 153 }
148 154
149 { 155 {
150 /* Hopefully I made this easy to parse... */ 156 /* Hopefully I made this easy to parse... */
218 session.config.locale.SetActiveLocale(locale); 224 session.config.locale.SetActiveLocale(locale);
219 } 225 }
220 226
221 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) { 227 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) {
222 language = session.config.anime_list.language; 228 language = session.config.anime_list.language;
229 format = session.config.anime_list.score_format;
223 theme = session.config.theme.GetTheme(); 230 theme = session.config.theme.GetTheme();
224 locale = session.config.locale.GetLocale(); 231 locale = session.config.locale.GetLocale();
225 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others; 232 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others;
226 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available; 233 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available;
227 display_aired_episodes = session.config.anime_list.display_aired_episodes; 234 display_aired_episodes = session.config.anime_list.display_aired_episodes;