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