Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/src/gui/dialog/settings/application.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/gui/dialog/settings/application.cc Thu Dec 07 11:14:01 2023 -0500 @@ -91,49 +91,6 @@ { /* 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); - } - } - - { - /* Application theme */ - { QLabel* rating_combo_box_label = new QLabel(tr("Rating system:"), appearance_group_box); appearance_layout->addWidget(rating_combo_box_label); } @@ -214,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; @@ -233,5 +257,6 @@ 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")); }