Mercurial > minori
annotate src/gui/dialog/information.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/information.cpp@6f7385bd334c |
| children | d02fdf1d6708 |
| rev | line source |
|---|---|
| 9 | 1 #include "gui/dialog/information.h" |
| 2 #include "core/anime.h" | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
3 #include "core/anime_db.h" |
| 46 | 4 #include "core/array.h" |
| 9 | 5 #include "core/strings.h" |
| 6 #include "gui/pages/anime_list.h" | |
| 7 #include "gui/translate/anime.h" | |
| 64 | 8 #include "gui/widgets/anime_info.h" |
| 76 | 9 #include "gui/widgets/optional_date.h" |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
10 #include "gui/widgets/poster.h" |
| 46 | 11 #include "gui/widgets/text.h" |
| 9 | 12 #include "gui/window.h" |
| 46 | 13 #include <QCheckBox> |
| 14 #include <QComboBox> | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
15 #include <QDateEdit> |
| 9 | 16 #include <QDebug> |
| 17 #include <QDialogButtonBox> | |
| 76 | 18 #include <QLabel> |
| 46 | 19 #include <QLineEdit> |
| 9 | 20 #include <QPlainTextEdit> |
| 46 | 21 #include <QSpinBox> |
| 22 #include <QStringList> | |
| 9 | 23 #include <QTextStream> |
| 24 #include <QVBoxLayout> | |
| 25 #include <functional> | |
| 26 | |
| 46 | 27 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list, |
| 28 which sucks. Think of a better way to implement this later. */ | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
29 void InformationDialog::SaveData() { |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
30 Anime::Anime& anime = Anime::db.items[id]; |
| 51 | 31 anime.SetUserProgress(progress); |
| 32 anime.SetUserScore(score); | |
| 33 anime.SetUserIsRewatching(rewatching); | |
| 34 anime.SetUserStatus(status); | |
| 35 anime.SetUserNotes(notes); | |
| 36 anime.SetUserDateStarted(started); | |
| 37 anime.SetUserDateCompleted(completed); | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
38 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
39 |
| 46 | 40 InformationDialog::InformationDialog(const Anime::Anime& anime, std::function<void()> accept, QWidget* parent) |
| 15 | 41 : QDialog(parent) { |
| 9 | 42 setFixedSize(842, 613); |
| 43 setWindowTitle(tr("Anime Information")); | |
| 44 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
| 36 | 45 |
| 46 { | |
| 69 | 47 QPalette pal(palette()); |
| 48 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); | |
| 36 | 49 setPalette(pal); |
| 50 } | |
| 9 | 51 |
| 52 QWidget* widget = new QWidget(this); | |
| 53 | |
| 54 /* "sidebar", includes... just the anime image :) */ | |
| 55 QWidget* sidebar = new QWidget(widget); | |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
56 QVBoxLayout* sidebar_layout = new QVBoxLayout(sidebar); |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
57 Poster* poster = new Poster(anime.GetId(), sidebar); |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
58 sidebar_layout->addWidget(poster); |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
59 sidebar_layout->setContentsMargins(0, 0, 0, 0); |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
60 sidebar_layout->addStretch(); |
| 9 | 61 |
| 62 /* main widget */ | |
| 63 QWidget* main_widget = new QWidget(widget); | |
| 36 | 64 |
| 9 | 65 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 66 | |
| 51 | 67 id = anime.GetId(); |
| 9 | 68 /* anime title header text */ |
| 64 | 69 TextWidgets::Title* anime_title = |
|
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
70 new TextWidgets::Title(Strings::ToQString(anime.GetUserPreferredTitle()), main_widget); |
| 9 | 71 |
| 72 /* tabbed widget */ | |
| 73 QTabWidget* tabbed_widget = new QTabWidget(main_widget); | |
| 74 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); | |
| 75 | |
| 76 /* main info tab */ | |
| 64 | 77 AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(anime, tabbed_widget); |
| 9 | 78 |
| 69 | 79 { |
| 80 QPalette pal(main_information_widget->palette()); | |
| 81 pal.setColor(QPalette::Base, pal.color(QPalette::Window)); | |
| 82 main_information_widget->setPalette(pal); | |
| 83 } | |
| 84 | |
| 9 | 85 QWidget* settings_widget = new QWidget(tabbed_widget); |
| 46 | 86 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); |
| 87 | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
88 QVBoxLayout* settings_layout = new QVBoxLayout(settings_widget); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
89 settings_layout->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget)); |
| 46 | 90 |
| 91 QWidget* sg_anime_list_content = new QWidget(settings_widget); | |
| 92 | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
93 QVBoxLayout* al_layout = new QVBoxLayout(sg_anime_list_content); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
94 al_layout->setSpacing(5); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
95 al_layout->setContentsMargins(12, 0, 0, 0); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
96 |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
97 #define LAYOUT_HORIZ_SPACING 25 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
98 #define LAYOUT_VERT_SPACING 5 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
99 #define LAYOUT_ITEM_WIDTH 175 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
100 /* Creates a subsection that takes up whatever space is necessary */ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
101 #define CREATE_FULL_WIDTH_SUBSECTION(x) \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
102 { \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
103 QWidget* subsection = new QWidget(section); \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
104 subsection->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); \ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
105 QVBoxLayout* subsection_layout = new QVBoxLayout(subsection); \ |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
106 subsection_layout->setSpacing(LAYOUT_VERT_SPACING); \ |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
107 subsection_layout->setContentsMargins(0, 0, 0, 0); \ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
108 x; \ |
| 69 | 109 layout->addWidget(subsection, 0, Qt::AlignBottom); \ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
110 } |
| 64 | 111 |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
112 /* Creates a section in the parent `a` */ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
113 #define CREATE_FULL_WIDTH_SECTION(a, x) \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
114 { \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
115 QWidget* section = new QWidget(a); \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
116 QHBoxLayout* layout = new QHBoxLayout(section); \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
117 layout->setSpacing(LAYOUT_HORIZ_SPACING); \ |
| 62 | 118 layout->setContentsMargins(0, 0, 0, 0); \ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
119 x; \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
120 a->layout()->addWidget(section); \ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
121 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
122 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
123 /* Creates a subsection with a width of 175 */ |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
124 #define CREATE_SUBSECTION(x) CREATE_FULL_WIDTH_SUBSECTION(x subsection->setFixedWidth(LAYOUT_ITEM_WIDTH);) |
| 64 | 125 /* Creates a section in the parent `a` */ |
| 126 #define CREATE_SECTION(a, x) CREATE_FULL_WIDTH_SECTION(a, x layout->addStretch();) | |
| 127 | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
128 CREATE_SECTION(sg_anime_list_content, { |
| 46 | 129 /* Episodes watched section */ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
130 CREATE_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
131 subsection_layout->addWidget(new QLabel(tr("Episodes watched:"), subsection)); |
| 46 | 132 |
| 133 QSpinBox* spin_box = new QSpinBox(subsection); | |
| 63 | 134 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { progress = i; }); |
| 46 | 135 spin_box->setRange(0, anime.GetEpisodes()); |
| 136 spin_box->setSingleStep(1); | |
| 51 | 137 spin_box->setValue(progress = anime.GetUserProgress()); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
138 subsection_layout->addWidget(spin_box); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
139 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
140 CREATE_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
141 subsection_layout->addWidget(new QLabel(tr(" "), subsection)); |
| 46 | 142 |
| 51 | 143 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); |
| 63 | 144 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, |
| 145 [this](int state) { rewatching = (state == Qt::Checked); }); | |
| 51 | 146 checkbox->setCheckState(anime.GetUserIsRewatching() ? Qt::Checked : Qt::Unchecked); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
147 subsection_layout->addWidget(checkbox); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
148 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
149 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
150 CREATE_SECTION(sg_anime_list_content, { |
| 46 | 151 /* Status & score section */ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
152 CREATE_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
153 subsection_layout->addWidget(new QLabel(tr("Status:"), subsection)); |
| 46 | 154 |
| 155 QStringList string_list; | |
| 156 for (unsigned int i = 0; i < ARRAYSIZE(Anime::ListStatuses); i++) | |
|
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
157 string_list.append(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i]))); |
| 46 | 158 |
| 159 QComboBox* combo_box = new QComboBox(subsection); | |
| 160 combo_box->addItems(string_list); | |
| 63 | 161 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, |
| 162 [this](int i) { status = Anime::ListStatuses[i]; }); | |
| 163 combo_box->setCurrentIndex(static_cast<int>(status = anime.GetUserStatus()) - 1); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
164 subsection_layout->addWidget(combo_box); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
165 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
166 CREATE_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
167 subsection_layout->addWidget(new QLabel(tr("Score:"), subsection)); |
| 46 | 168 |
| 169 QSpinBox* spin_box = new QSpinBox(subsection); | |
| 63 | 170 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { score = i; }); |
| 46 | 171 spin_box->setRange(0, 100); |
| 172 spin_box->setSingleStep(5); | |
| 51 | 173 spin_box->setValue(score = anime.GetUserScore()); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
174 subsection_layout->addWidget(spin_box); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
175 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
176 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
177 CREATE_FULL_WIDTH_SECTION(sg_anime_list_content, { |
| 46 | 178 /* Notes section */ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
179 CREATE_FULL_WIDTH_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
180 subsection_layout->addWidget(new QLabel(tr("Notes:"), subsection)); |
| 46 | 181 |
| 51 | 182 QLineEdit* line_edit = new QLineEdit(subsection); |
| 183 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) { | |
| 184 /* this sucks but I don't really want to implement anything smarter :) */ | |
|
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
185 notes = Strings::ToUtf8String(text); |
| 51 | 186 }); |
|
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
187 line_edit->setText(Strings::ToQString(notes = anime.GetUserNotes())); |
| 46 | 188 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
189 subsection_layout->addWidget(line_edit); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
190 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
191 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
192 CREATE_SECTION(sg_anime_list_content, { |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
193 /* Dates section */ |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
194 CREATE_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
195 subsection_layout->addWidget(new QLabel(tr("Date started:"), subsection)); |
| 46 | 196 |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
197 OptionalDate* date = new OptionalDate(true, subsection); |
| 63 | 198 connect(date, &OptionalDate::DataChanged, this, |
| 199 [this](bool enabled, Date date) { started = (enabled) ? date : Date(); }); | |
| 51 | 200 started = anime.GetUserDateStarted(); |
| 201 if (!started.IsValid()) { | |
| 202 date->SetEnabled(false); | |
| 203 started = anime.GetAirDate(); | |
| 204 } | |
| 205 date->SetDate(started); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
206 subsection_layout->addWidget(date); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
207 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
208 CREATE_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
209 subsection_layout->addWidget(new QLabel(tr("Date completed:"), subsection)); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
210 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
211 OptionalDate* date = new OptionalDate(true, subsection); |
| 63 | 212 connect(date, &OptionalDate::DataChanged, this, |
| 213 [this](bool enabled, Date date) { completed = (enabled) ? date : Date(); }); | |
| 51 | 214 completed = anime.GetUserDateCompleted(); |
| 215 if (!completed.IsValid()) { | |
| 216 date->SetEnabled(false); | |
| 217 completed = anime.GetAirDate(); | |
| 218 } | |
| 219 date->SetDate(completed); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
220 subsection_layout->addWidget(date); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
221 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
222 }); |
| 46 | 223 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
224 settings_layout->addWidget(sg_anime_list_content); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
225 |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
226 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); |
| 46 | 227 |
| 228 QWidget* sg_local_content = new QWidget(settings_widget); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
229 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
230 sg_local_layout->setSpacing(5); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
231 sg_local_layout->setContentsMargins(12, 0, 0, 0); |
| 46 | 232 |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
233 CREATE_FULL_WIDTH_SECTION(sg_local_content, { |
| 46 | 234 /* Alternative titles */ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
235 CREATE_FULL_WIDTH_SUBSECTION({ |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
236 subsection_layout->addWidget(new QLabel(tr("Alternative titles:"), subsection)); |
| 46 | 237 |
| 77 | 238 QLineEdit* line_edit = new QLineEdit("", subsection); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
239 line_edit->setPlaceholderText( |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
240 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
241 subsection_layout->addWidget(line_edit); |
| 46 | 242 |
| 51 | 243 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
244 subsection_layout->addWidget(checkbox); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
245 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
246 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
247 #undef CREATE_SECTION |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
248 #undef CREATE_SUBSECTION |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
249 #undef CREATE_FULL_WIDTH_SECTION |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
250 #undef CREATE_FULL_WIDTH_SUBSECTION |
| 46 | 251 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
252 settings_layout->addWidget(sg_local_content); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
253 settings_layout->addStretch(); |
| 9 | 254 |
| 51 | 255 tabbed_widget->addTab(main_information_widget, tr("Main information")); |
| 256 tabbed_widget->addTab(settings_widget, tr("My list and settings")); | |
| 9 | 257 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
258 QVBoxLayout* main_layout = new QVBoxLayout(main_widget); |
| 9 | 259 main_layout->addWidget(anime_title); |
| 260 main_layout->addWidget(tabbed_widget); | |
| 62 | 261 main_layout->setContentsMargins(0, 0, 0, 0); |
| 9 | 262 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
263 QHBoxLayout* layout = new QHBoxLayout(widget); |
| 9 | 264 layout->addWidget(sidebar); |
| 265 layout->addWidget(main_widget); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
266 layout->setSpacing(12); |
| 9 | 267 |
| 268 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | |
| 269 connect(button_box, &QDialogButtonBox::accepted, this, [this, accept] { | |
| 51 | 270 SaveData(); |
| 9 | 271 accept(); |
| 272 QDialog::accept(); | |
| 273 }); | |
| 274 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); | |
| 275 | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
276 QVBoxLayout* buttons_layout = new QVBoxLayout(this); |
| 9 | 277 buttons_layout->addWidget(widget); |
| 278 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom); | |
| 279 } | |
| 280 | |
| 281 #include "gui/dialog/moc_information.cpp" |
