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