annotate src/gui/dialog/settings/application.cpp @ 9:5c0397762b53

INCOMPLETE: megacommit :)
author Paper <mrpapersonic@gmail.com>
date Sun, 10 Sep 2023 03:59:16 -0400
parents src/dialog/settings/application.cpp@07a9095eaeed
children 4b198a111713
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
1 #include "core/session.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
2 #include "gui/dialog/settings.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
3 #include <QCheckBox>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
4 #include <QComboBox>
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <QGroupBox>
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QPushButton>
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QSizePolicy>
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
9 QWidget* SettingsPageApplication::CreateAnimeListWidget() {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 QWidget* result = new QWidget(this);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 QGroupBox* actions_group_box = new QGroupBox(tr("Actions"), result);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 actions_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 /* Actions/Double click */
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 QWidget* double_click_widget = new QWidget(actions_group_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 QLabel* dc_combo_box_label = new QLabel(tr("Double click:"), double_click_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 QComboBox* dc_combo_box = new QComboBox(double_click_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 dc_combo_box->addItem(tr("View anime info"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 QVBoxLayout* double_click_layout = new QVBoxLayout;
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 double_click_layout->addWidget(dc_combo_box_label);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 double_click_layout->addWidget(dc_combo_box);
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
25 double_click_layout->setMargin(0);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 double_click_widget->setLayout(double_click_layout);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 /* Actions/Middle click */
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 QWidget* middle_click_widget = new QWidget(actions_group_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 QLabel* mc_combo_box_label = new QLabel(tr("Middle click:"), middle_click_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 QComboBox* mc_combo_box = new QComboBox(middle_click_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 mc_combo_box->addItem(tr("Play next episode"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 QVBoxLayout* middle_click_layout = new QVBoxLayout;
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 middle_click_layout->addWidget(mc_combo_box_label);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 middle_click_layout->addWidget(mc_combo_box);
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
37 middle_click_layout->setMargin(0);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 middle_click_widget->setLayout(middle_click_layout);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 /* Actions */
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 QHBoxLayout* actions_layout = new QHBoxLayout;
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 actions_layout->addWidget(double_click_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 actions_layout->addWidget(middle_click_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 actions_group_box->setLayout(actions_layout);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 QLabel* lang_combo_box_label = new QLabel(tr("Title language preference:"), appearance_group_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 QComboBox* lang_combo_box = new QComboBox(appearance_group_box);
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
51 lang_combo_box->addItem(tr("Romaji"));
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
52 lang_combo_box->addItem(tr("Native"));
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 lang_combo_box->addItem(tr("English"));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
54 connect(lang_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
55 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); });
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
56 lang_combo_box->setCurrentIndex(static_cast<int>(language));
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
57
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
58 QCheckBox* hl_anime_box =
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
59 new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
61 connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) {
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
62 highlight_anime_if_available = (state == Qt::Unchecked) ? false : true;
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 hl_above_anime_box->setEnabled(state);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 });
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
65 connect(hl_above_anime_box, &QCheckBox::stateChanged, this,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
66 [this](int state) { highlight_anime_if_available = (state == Qt::Unchecked) ? false : true; });
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
67 hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
68 hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
69 hl_above_anime_box->setEnabled(hl_anime_box->checkState() != Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
70 hl_above_anime_box->setStyleSheet("margin-left: 10px;");
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72 /* Appearance */
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 QVBoxLayout* appearance_layout = new QVBoxLayout;
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74 appearance_layout->addWidget(lang_combo_box_label);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 appearance_layout->addWidget(lang_combo_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 appearance_layout->addWidget(hl_anime_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 appearance_layout->addWidget(hl_above_anime_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 appearance_group_box->setLayout(appearance_layout);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
83 QCheckBox* progress_display_aired_episodes =
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
84 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
85 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
86 [this](int state) { display_aired_episodes = (state == Qt::Unchecked) ? false : true; });
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
87 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked);
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
88
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
89 QCheckBox* progress_display_available_episodes =
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
90 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
91 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
92 [this](int state) { display_available_episodes = (state == Qt::Unchecked) ? false : true; });
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
93 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 QVBoxLayout* progress_layout = new QVBoxLayout;
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
96 progress_layout->addWidget(progress_display_aired_episodes);
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
97 progress_layout->addWidget(progress_display_available_episodes);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 progress_group_box->setLayout(progress_layout);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 QVBoxLayout* full_layout = new QVBoxLayout;
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 full_layout->addWidget(actions_group_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102 full_layout->addWidget(appearance_group_box);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 full_layout->addWidget(progress_group_box);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
104 full_layout->setSpacing(10);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 full_layout->addStretch();
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 result->setLayout(full_layout);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 return result;
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 }
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110 void SettingsPageApplication::SaveInfo() {
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
111 session.config.anime_list.language = language;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
112 session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
113 session.config.anime_list.highlight_anime_if_available = highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
114 session.config.anime_list.display_aired_episodes = display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
115 session.config.anime_list.display_available_episodes = display_available_episodes;
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 }
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
118 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) {
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
119 language = session.config.anime_list.language;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
120 highlighted_anime_above_others = session.config.anime_list.highlighted_anime_above_others;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
121 highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
122 display_aired_episodes = session.config.anime_list.display_aired_episodes;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
123 display_available_episodes = session.config.anime_list.display_available_episodes;
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
124 AddTab(CreateAnimeListWidget(), tr("Anime list"));
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
125 }