Mercurial > minori
annotate src/gui/dialog/settings/application.cc @ 86:c912128af0eb
*: various macos fixes
todo: push that bsd thing to upstream
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 31 Oct 2023 13:52:36 -0400 |
parents | 9b2b41f83a5e |
children | c537996cf67b |
rev | line source |
---|---|
10 | 1 #include "core/session.h" |
2 #include "gui/dialog/settings.h" | |
3 #include <QCheckBox> | |
4 #include <QComboBox> | |
5 #include <QGroupBox> | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
6 #include <QHBoxLayout> |
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
7 #include <QLabel> |
10 | 8 #include <QPushButton> |
9 #include <QSizePolicy> | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
10 #include <QVBoxLayout> |
10 | 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 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
25 QVBoxLayout* double_click_layout = new QVBoxLayout(double_click_widget); |
10 | 26 double_click_layout->addWidget(dc_combo_box_label); |
27 double_click_layout->addWidget(dc_combo_box); | |
62 | 28 double_click_layout->setContentsMargins(0, 0, 0, 0); |
10 | 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 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
36 QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget); |
10 | 37 middle_click_layout->addWidget(mc_combo_box_label); |
38 middle_click_layout->addWidget(mc_combo_box); | |
62 | 39 middle_click_layout->setContentsMargins(0, 0, 0, 0); |
10 | 40 |
41 /* Actions */ | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
42 QHBoxLayout* actions_layout = new QHBoxLayout(actions_group_box); |
10 | 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, | |
15 | 55 [this](int index) { language = static_cast<Anime::TitleLanguage>(index); }); |
10 | 56 lang_combo_box->setCurrentIndex(static_cast<int>(language)); |
57 | |
58 QCheckBox* hl_anime_box = | |
15 | 59 new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box); |
10 | 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) { | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
62 highlight_anime_if_available = !(state == Qt::Unchecked); |
10 | 63 hl_above_anime_box->setEnabled(state); |
64 }); | |
65 connect(hl_above_anime_box, &QCheckBox::stateChanged, this, | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
66 [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); }); |
10 | 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); | |
36 | 70 hl_above_anime_box->setContentsMargins(10, 0, 0, 0); |
10 | 71 |
72 /* Appearance */ | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
73 QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box); |
10 | 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 = | |
15 | 83 new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box); |
10 | 84 connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this, |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
85 [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); }); |
10 | 86 progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked); |
87 | |
88 QCheckBox* progress_display_available_episodes = | |
15 | 89 new QCheckBox(tr("Display available episodes in library folders"), progress_group_box); |
10 | 90 connect(progress_display_available_episodes, &QCheckBox::stateChanged, this, |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
91 [this](int state) { display_available_episodes = !(state == Qt::Unchecked); }); |
10 | 92 progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked); |
93 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
94 QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box); |
10 | 95 progress_layout->addWidget(progress_display_aired_episodes); |
96 progress_layout->addWidget(progress_display_available_episodes); | |
97 | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
98 QVBoxLayout* full_layout = new QVBoxLayout(result); |
10 | 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(); | |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
62
diff
changeset
|
104 |
10 | 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 } |