comparison src/gui/dialog/settings/application.cc @ 101:c537996cf67b

*: multitude of config changes 1. theme is now configurable from the settings menu (but you have to restart for it to apply) 2. config is now stored in an INI file, with no method of conversion from json (this repo is private-ish anyway)
author Paper <mrpapersonic@gmail.com>
date Fri, 03 Nov 2023 14:06:02 -0400
parents 9b2b41f83a5e
children b315f3759c56
comparison
equal deleted inserted replaced
100:f5940a575d83 101:c537996cf67b
1 #include "core/session.h" 1 #include "core/session.h"
2 #include "gui/dialog/settings.h" 2 #include "gui/dialog/settings.h"
3 #include "gui/dark_theme.h"
3 #include <QCheckBox> 4 #include <QCheckBox>
4 #include <QComboBox> 5 #include <QComboBox>
5 #include <QGroupBox> 6 #include <QGroupBox>
6 #include <QHBoxLayout> 7 #include <QHBoxLayout>
7 #include <QLabel> 8 #include <QLabel>
53 lang_combo_box->addItem(tr("English")); 54 lang_combo_box->addItem(tr("English"));
54 connect(lang_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, 55 connect(lang_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
55 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); }); 56 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); });
56 lang_combo_box->setCurrentIndex(static_cast<int>(language)); 57 lang_combo_box->setCurrentIndex(static_cast<int>(language));
57 58
59 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box);
60 QComboBox* theme_combo_box = new QComboBox(appearance_group_box);
61 theme_combo_box->addItem(tr("Default"));
62 theme_combo_box->addItem(tr("Light"));
63 theme_combo_box->addItem(tr("Dark"));
64 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
65 [this](int index) { theme = static_cast<Themes>(index); });
66 theme_combo_box->setCurrentIndex(static_cast<int>(theme));
67
58 QCheckBox* hl_anime_box = 68 QCheckBox* hl_anime_box =
59 new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box); 69 new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box);
60 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box); 70 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box);
61 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) { 71 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) {
62 highlight_anime_if_available = !(state == Qt::Unchecked); 72 highlight_anime_if_available = !(state == Qt::Unchecked);
71 81
72 /* Appearance */ 82 /* Appearance */
73 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box); 83 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box);
74 appearance_layout->addWidget(lang_combo_box_label); 84 appearance_layout->addWidget(lang_combo_box_label);
75 appearance_layout->addWidget(lang_combo_box); 85 appearance_layout->addWidget(lang_combo_box);
86 appearance_layout->addWidget(theme_combo_box_label);
87 appearance_layout->addWidget(theme_combo_box);
76 appearance_layout->addWidget(hl_anime_box); 88 appearance_layout->addWidget(hl_anime_box);
77 appearance_layout->addWidget(hl_above_anime_box); 89 appearance_layout->addWidget(hl_above_anime_box);
78 90
79 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result); 91 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result);
80 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); 92 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
109 session.config.anime_list.language = language; 121 session.config.anime_list.language = language;
110 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others; 122 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others;
111 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available; 123 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available;
112 session.config.anime_list.display_aired_episodes = display_aired_episodes; 124 session.config.anime_list.display_aired_episodes = display_aired_episodes;
113 session.config.anime_list.display_available_episodes = display_available_episodes; 125 session.config.anime_list.display_available_episodes = display_available_episodes;
126 session.config.theme = theme;
127 DarkTheme::SetTheme(session.config.theme);
114 } 128 }
115 129
116 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) { 130 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) {
117 language = session.config.anime_list.language; 131 language = session.config.anime_list.language;
132 theme = session.config.theme;
118 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others; 133 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others;
119 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available; 134 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available;
120 display_aired_episodes = session.config.anime_list.display_aired_episodes; 135 display_aired_episodes = session.config.anime_list.display_aired_episodes;
121 display_available_episodes = session.config.anime_list.display_available_episodes; 136 display_available_episodes = session.config.anime_list.display_available_episodes;
122 AddTab(CreateAnimeListWidget(), tr("Anime list")); 137 AddTab(CreateAnimeListWidget(), tr("Anime list"));