comparison src/gui/dialog/settings/application.cc @ 81:9b2b41f83a5e

boring: mass rename to cc because this is a very unix-y project, it makes more sense to use the 'cc' extension
author Paper <mrpapersonic@gmail.com>
date Mon, 23 Oct 2023 12:07:27 -0400
parents src/gui/dialog/settings/application.cpp@2417121d894e
children c537996cf67b
comparison
equal deleted inserted replaced
80:825506f0e221 81:9b2b41f83a5e
1 #include "core/session.h"
2 #include "gui/dialog/settings.h"
3 #include <QCheckBox>
4 #include <QComboBox>
5 #include <QGroupBox>
6 #include <QHBoxLayout>
7 #include <QLabel>
8 #include <QPushButton>
9 #include <QSizePolicy>
10 #include <QVBoxLayout>
11
12 QWidget* SettingsPageApplication::CreateAnimeListWidget() {
13 QWidget* result = new QWidget(this);
14 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
15
16 QGroupBox* actions_group_box = new QGroupBox(tr("Actions"), result);
17 actions_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
18
19 /* Actions/Double click */
20 QWidget* double_click_widget = new QWidget(actions_group_box);
21 QLabel* dc_combo_box_label = new QLabel(tr("Double click:"), double_click_widget);
22 QComboBox* dc_combo_box = new QComboBox(double_click_widget);
23 dc_combo_box->addItem(tr("View anime info"));
24
25 QVBoxLayout* double_click_layout = new QVBoxLayout(double_click_widget);
26 double_click_layout->addWidget(dc_combo_box_label);
27 double_click_layout->addWidget(dc_combo_box);
28 double_click_layout->setContentsMargins(0, 0, 0, 0);
29
30 /* Actions/Middle click */
31 QWidget* middle_click_widget = new QWidget(actions_group_box);
32 QLabel* mc_combo_box_label = new QLabel(tr("Middle click:"), middle_click_widget);
33 QComboBox* mc_combo_box = new QComboBox(middle_click_widget);
34 mc_combo_box->addItem(tr("Play next episode"));
35
36 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget);
37 middle_click_layout->addWidget(mc_combo_box_label);
38 middle_click_layout->addWidget(mc_combo_box);
39 middle_click_layout->setContentsMargins(0, 0, 0, 0);
40
41 /* Actions */
42 QHBoxLayout* actions_layout = new QHBoxLayout(actions_group_box);
43 actions_layout->addWidget(double_click_widget);
44 actions_layout->addWidget(middle_click_widget);
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);
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); });
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->setContentsMargins(10, 0, 0, 0);
71
72 /* Appearance */
73 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box);
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
79 QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result);
80 progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
81
82 QCheckBox* progress_display_aired_episodes =
83 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box);
84 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this,
85 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); });
86 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked);
87
88 QCheckBox* progress_display_available_episodes =
89 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box);
90 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this,
91 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); });
92 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked);
93
94 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box);
95 progress_layout->addWidget(progress_display_aired_episodes);
96 progress_layout->addWidget(progress_display_available_episodes);
97
98 QVBoxLayout* full_layout = new QVBoxLayout(result);
99 full_layout->addWidget(actions_group_box);
100 full_layout->addWidget(appearance_group_box);
101 full_layout->addWidget(progress_group_box);
102 full_layout->setSpacing(10);
103 full_layout->addStretch();
104
105 return result;
106 }
107
108 void SettingsPageApplication::SaveInfo() {
109 session.config.anime_list.language = language;
110 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;
112 session.config.anime_list.display_aired_episodes = display_aired_episodes;
113 session.config.anime_list.display_available_episodes = display_available_episodes;
114 }
115
116 SettingsPageApplication::SettingsPageApplication(QWidget* parent) : SettingsPage(parent, tr("Application")) {
117 language = session.config.anime_list.language;
118 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;
120 display_aired_episodes = session.config.anime_list.display_aired_episodes;
121 display_available_episodes = session.config.anime_list.display_available_episodes;
122 AddTab(CreateAnimeListWidget(), tr("Anime list"));
123 }