Mercurial > minori
annotate src/gui/dialog/settings/application.cc @ 105:6d8da6e64d61
theme: add dark stylesheet, make it actually usable
win32: make the titlebar black where available
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 05 Nov 2023 03:54:26 -0500 |
parents | b315f3759c56 |
children | 2004b41d4a59 |
rev | line source |
---|---|
10 | 1 #include "core/session.h" |
2 #include "gui/dialog/settings.h" | |
102 | 3 #include "gui/theme.h" |
10 | 4 #include <QCheckBox> |
5 #include <QComboBox> | |
6 #include <QGroupBox> | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
7 #include <QHBoxLayout> |
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
8 #include <QLabel> |
10 | 9 #include <QPushButton> |
10 #include <QSizePolicy> | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
11 #include <QVBoxLayout> |
10 | 12 |
13 QWidget* SettingsPageApplication::CreateAnimeListWidget() { | |
14 QWidget* result = new QWidget(this); | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
102
diff
changeset
|
15 result->setAutoFillBackground(true); |
10 | 16 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); |
17 | |
18 QGroupBox* actions_group_box = new QGroupBox(tr("Actions"), result); | |
19 actions_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
20 | |
21 /* Actions/Double click */ | |
22 QWidget* double_click_widget = new QWidget(actions_group_box); | |
23 QLabel* dc_combo_box_label = new QLabel(tr("Double click:"), double_click_widget); | |
24 QComboBox* dc_combo_box = new QComboBox(double_click_widget); | |
25 dc_combo_box->addItem(tr("View anime info")); | |
26 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
27 QVBoxLayout* double_click_layout = new QVBoxLayout(double_click_widget); |
10 | 28 double_click_layout->addWidget(dc_combo_box_label); |
29 double_click_layout->addWidget(dc_combo_box); | |
62 | 30 double_click_layout->setContentsMargins(0, 0, 0, 0); |
10 | 31 |
32 /* Actions/Middle click */ | |
33 QWidget* middle_click_widget = new QWidget(actions_group_box); | |
34 QLabel* mc_combo_box_label = new QLabel(tr("Middle click:"), middle_click_widget); | |
35 QComboBox* mc_combo_box = new QComboBox(middle_click_widget); | |
36 mc_combo_box->addItem(tr("Play next episode")); | |
37 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
38 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget); |
10 | 39 middle_click_layout->addWidget(mc_combo_box_label); |
40 middle_click_layout->addWidget(mc_combo_box); | |
62 | 41 middle_click_layout->setContentsMargins(0, 0, 0, 0); |
10 | 42 |
43 /* Actions */ | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
44 QHBoxLayout* actions_layout = new QHBoxLayout(actions_group_box); |
10 | 45 actions_layout->addWidget(double_click_widget); |
46 actions_layout->addWidget(middle_click_widget); | |
47 | |
48 QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result); | |
49 appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
50 | |
51 QLabel* lang_combo_box_label = new QLabel(tr("Title language preference:"), appearance_group_box); | |
52 QComboBox* lang_combo_box = new QComboBox(appearance_group_box); | |
53 lang_combo_box->addItem(tr("Romaji")); | |
54 lang_combo_box->addItem(tr("Native")); | |
55 lang_combo_box->addItem(tr("English")); | |
56 connect(lang_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | |
15 | 57 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); }); |
10 | 58 lang_combo_box->setCurrentIndex(static_cast<int>(language)); |
59 | |
101
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
60 QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
61 QComboBox* theme_combo_box = new QComboBox(appearance_group_box); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
62 theme_combo_box->addItem(tr("Default")); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
63 theme_combo_box->addItem(tr("Light")); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
64 theme_combo_box->addItem(tr("Dark")); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
65 connect(theme_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
66 [this](int index) { theme = static_cast<Themes>(index); }); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
67 theme_combo_box->setCurrentIndex(static_cast<int>(theme)); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
68 |
10 | 69 QCheckBox* hl_anime_box = |
15 | 70 new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box); |
10 | 71 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box); |
72 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) { | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
73 highlight_anime_if_available = !(state == Qt::Unchecked); |
10 | 74 hl_above_anime_box->setEnabled(state); |
75 }); | |
76 connect(hl_above_anime_box, &QCheckBox::stateChanged, this, | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
77 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); }); |
10 | 78 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked); |
79 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked); | |
80 hl_above_anime_box->setEnabled(hl_anime_box->checkState() != Qt::Unchecked); | |
36 | 81 hl_above_anime_box->setContentsMargins(10, 0, 0, 0); |
10 | 82 |
83 /* Appearance */ | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
84 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box); |
10 | 85 appearance_layout->addWidget(lang_combo_box_label); |
86 appearance_layout->addWidget(lang_combo_box); | |
101
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
87 appearance_layout->addWidget(theme_combo_box_label); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
88 appearance_layout->addWidget(theme_combo_box); |
10 | 89 appearance_layout->addWidget(hl_anime_box); |
90 appearance_layout->addWidget(hl_above_anime_box); | |
91 | |
92 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result); | |
93 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
94 | |
95 QCheckBox* progress_display_aired_episodes = | |
15 | 96 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box); |
10 | 97 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this, |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
98 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); }); |
10 | 99 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked); |
100 | |
101 QCheckBox* progress_display_available_episodes = | |
15 | 102 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box); |
10 | 103 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this, |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
104 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); }); |
10 | 105 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked); |
106 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
107 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box); |
10 | 108 progress_layout->addWidget(progress_display_aired_episodes); |
109 progress_layout->addWidget(progress_display_available_episodes); | |
110 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
111 QVBoxLayout* full_layout = new QVBoxLayout(result); |
10 | 112 full_layout->addWidget(actions_group_box); |
113 full_layout->addWidget(appearance_group_box); | |
114 full_layout->addWidget(progress_group_box); | |
115 full_layout->setSpacing(10); | |
116 full_layout->addStretch(); | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
117 |
10 | 118 return result; |
119 } | |
120 | |
121 void SettingsPageApplication::SaveInfo() { | |
122 session.config.anime_list.language = language; | |
123 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others; | |
124 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available; | |
125 session.config.anime_list.display_aired_episodes = display_aired_episodes; | |
126 session.config.anime_list.display_available_episodes = display_available_episodes; | |
102 | 127 session.config.theme.SetTheme(theme); |
10 | 128 } |
129 | |
130 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) { | |
131 language = session.config.anime_list.language; | |
102 | 132 theme = session.config.theme.GetTheme(); |
10 | 133 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others; |
134 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available; | |
135 display_aired_episodes = session.config.anime_list.display_aired_episodes; | |
136 display_available_episodes = session.config.anime_list.display_available_episodes; | |
137 AddTab(CreateAnimeListWidget(), tr("Anime list")); | |
138 } |