Mercurial > minori
diff src/gui/dialog/settings/application.cc @ 202:71832ffe425a
animia: re-add kvm fd source
this is all being merged from my wildly out-of-date laptop. SORRY!
in other news, I edited the CI file to install the wayland client
as well, so the linux CI build might finally get wayland stuff.
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 02 Jan 2024 06:05:06 -0500 |
| parents | 975a3f0965e2 |
| children | ff0061e75f0f |
line wrap: on
line diff
--- a/src/gui/dialog/settings/application.cc Sun Nov 19 19:13:28 2023 -0500 +++ b/src/gui/dialog/settings/application.cc Tue Jan 02 06:05:06 2024 -0500 @@ -3,6 +3,8 @@ #include "gui/dialog/settings.h" #include "gui/theme.h" #include "gui/locale.h" +#include "gui/translate/anime.h" + #include <QCheckBox> #include <QComboBox> #include <QGroupBox> @@ -11,6 +13,7 @@ #include <QPushButton> #include <QSizePolicy> #include <QVBoxLayout> + #include <algorithm> QWidget* SettingsPageApplication::CreateAnimeListWidget() { @@ -88,42 +91,21 @@ { /* Application theme */ { - QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); - appearance_layout->addWidget(theme_combo_box_label); + QLabel* rating_combo_box_label = new QLabel(tr("Rating system:"), appearance_group_box); + appearance_layout->addWidget(rating_combo_box_label); } { - QComboBox* theme_combo_box = new QComboBox(appearance_group_box); - theme_combo_box->addItem(tr("Default")); - theme_combo_box->addItem(tr("Light")); - theme_combo_box->addItem(tr("Dark")); - connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, - [this](int index) { theme = static_cast<Themes>(index); }); - theme_combo_box->setCurrentIndex(static_cast<int>(theme)); - appearance_layout->addWidget(theme_combo_box); - } - } + QComboBox* rating_combo_box = new QComboBox(appearance_group_box); + + for (const auto& score_format : Anime::ScoreFormats) + rating_combo_box->addItem(Strings::ToQString(Translate::ToLocalString(score_format)), static_cast<int>(score_format)); - { - /* Application locale */ - { - QLabel* locale_combo_box_label = new QLabel(tr("Set application locale:"), appearance_group_box); - appearance_layout->addWidget(locale_combo_box_label); - } + connect(rating_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + [this, rating_combo_box](int index) { format = static_cast<Anime::ScoreFormat>(rating_combo_box->itemData(index).toInt()); }); - { - QComboBox* locale_combo_box = new QComboBox(appearance_group_box); - const auto& available_locales = session.config.locale.GetAvailableLocales(); - for (const auto& l : available_locales) - locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l); - - connect(locale_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, - [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); }); - - for (size_t i = 0; i < available_locales.size(); i++) - if (available_locales[i] == locale) - locale_combo_box->setCurrentIndex(i); - appearance_layout->addWidget(locale_combo_box); + rating_combo_box->setCurrentIndex(static_cast<int>(format)); + appearance_layout->addWidget(rating_combo_box); } } @@ -189,6 +171,73 @@ return result; } +QWidget* SettingsPageApplication::CreateGeneralWidget() { + QWidget* result = new QWidget(this); + result->setAutoFillBackground(true); + result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* full_layout = new QVBoxLayout(result); + + { + /* Appearance */ + QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result); + appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box); + + { + /* Application theme */ + { + QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); + appearance_layout->addWidget(theme_combo_box_label); + } + + { + QComboBox* theme_combo_box = new QComboBox(appearance_group_box); + theme_combo_box->addItem(tr("Default")); + theme_combo_box->addItem(tr("Light")); + theme_combo_box->addItem(tr("Dark")); + connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + [this](int index) { theme = static_cast<Themes>(index); }); + theme_combo_box->setCurrentIndex(static_cast<int>(theme)); + appearance_layout->addWidget(theme_combo_box); + } + } + + { + /* Application locale */ + { + QLabel* locale_combo_box_label = new QLabel(tr("Application locale:"), appearance_group_box); + appearance_layout->addWidget(locale_combo_box_label); + } + + { + QComboBox* locale_combo_box = new QComboBox(appearance_group_box); + const auto& available_locales = session.config.locale.GetAvailableLocales(); + for (const auto& l : available_locales) + locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l); + + connect(locale_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); }); + + for (size_t i = 0; i < available_locales.size(); i++) + if (available_locales[i] == locale) + locale_combo_box->setCurrentIndex(i); + + appearance_layout->addWidget(locale_combo_box); + } + } + + full_layout->addWidget(appearance_group_box); + } + + full_layout->setSpacing(10); + full_layout->addStretch(); + + return result; +} + + void SettingsPageApplication::SaveInfo() { session.config.anime_list.language = language; session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others; @@ -201,11 +250,13 @@ SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) { language = session.config.anime_list.language; + format = session.config.anime_list.score_format; theme = session.config.theme.GetTheme(); locale = session.config.locale.GetLocale(); highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others; highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available; display_aired_episodes = session.config.anime_list.display_aired_episodes; display_available_episodes = session.config.anime_list.display_available_episodes; + AddTab(CreateGeneralWidget(), tr("General")); AddTab(CreateAnimeListWidget(), tr("Anime list")); }
