Mercurial > minori
annotate src/gui/dialog/information.cpp @ 62:4c6dd5999b39
*: update
1. updated animia
2. use widestrings for filesystem on Windows
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 01 Oct 2023 06:16:06 -0400 |
parents | 75c804f713b2 |
children | 3d2decf093bb |
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" | |
46 | 8 #include "gui/widgets/text.h" |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
9 #include "gui/widgets/optional_date.h" |
9 | 10 #include "gui/window.h" |
46 | 11 #include <QCheckBox> |
12 #include <QComboBox> | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
13 #include <QDateEdit> |
9 | 14 #include <QDebug> |
15 #include <QDialogButtonBox> | |
46 | 16 #include <QLineEdit> |
9 | 17 #include <QPlainTextEdit> |
46 | 18 #include <QSpinBox> |
19 #include <QStringList> | |
9 | 20 #include <QTextStream> |
21 #include <QVBoxLayout> | |
22 #include <functional> | |
23 | |
46 | 24 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list, |
25 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
|
26 void InformationDialog::SaveData() { |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
27 Anime::Anime& anime = Anime::db.items[id]; |
51 | 28 anime.SetUserProgress(progress); |
29 anime.SetUserScore(score); | |
30 anime.SetUserIsRewatching(rewatching); | |
31 anime.SetUserStatus(status); | |
32 anime.SetUserNotes(notes); | |
33 anime.SetUserDateStarted(started); | |
34 anime.SetUserDateCompleted(completed); | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
35 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
36 |
46 | 37 InformationDialog::InformationDialog(const Anime::Anime& anime, std::function<void()> accept, QWidget* parent) |
15 | 38 : QDialog(parent) { |
9 | 39 setFixedSize(842, 613); |
40 setWindowTitle(tr("Anime Information")); | |
41 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
36 | 42 |
43 { | |
44 QPalette pal; | |
45 pal.setColor(QPalette::Window, Qt::white); | |
46 setPalette(pal); | |
47 } | |
9 | 48 |
49 QWidget* widget = new QWidget(this); | |
50 | |
51 /* "sidebar", includes... just the anime image :) */ | |
52 QWidget* sidebar = new QWidget(widget); | |
53 sidebar->setFixedWidth(175); | |
54 | |
55 /* main widget */ | |
56 QWidget* main_widget = new QWidget(widget); | |
36 | 57 |
58 { | |
59 QPalette pal; | |
60 pal.setColor(QPalette::Window, Qt::white); | |
61 main_widget->setPalette(pal); | |
62 } | |
63 | |
9 | 64 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
65 | |
51 | 66 id = anime.GetId(); |
9 | 67 /* anime title header text */ |
46 | 68 TextWidgets::Paragraph* anime_title = |
69 new TextWidgets::Paragraph(QString::fromUtf8(anime.GetUserPreferredTitle().c_str()), main_widget); | |
9 | 70 anime_title->setReadOnly(true); |
71 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
72 anime_title->setWordWrapMode(QTextOption::NoWrap); | |
73 anime_title->setFrameShape(QFrame::NoFrame); | |
74 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
75 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
76 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
36 | 77 |
78 { | |
79 QFont font(anime_title->font()); | |
80 font.setPointSize(12); | |
81 anime_title->setFont(font); | |
82 } | |
83 | |
84 { | |
85 QPalette pal; | |
46 | 86 pal.setColor(QPalette::Window, Qt::transparent); |
36 | 87 pal.setColor(QPalette::WindowText, Qt::blue); |
88 } | |
9 | 89 |
90 /* tabbed widget */ | |
91 QTabWidget* tabbed_widget = new QTabWidget(main_widget); | |
92 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); | |
93 | |
94 /* main info tab */ | |
95 QWidget* main_information_widget = new QWidget(tabbed_widget); | |
96 main_information_widget->setLayout(new QVBoxLayout); | |
97 | |
98 /* alt titles */ | |
46 | 99 main_information_widget->layout()->addWidget(new TextWidgets::SelectableTextParagraph( |
51 | 100 tr("Alternative titles"), QString::fromUtf8(Strings::Implode(anime.GetTitleSynonyms(), ", ").c_str()), |
15 | 101 main_information_widget)); |
9 | 102 |
103 /* details */ | |
104 QString details_data; | |
105 QTextStream details_data_s(&details_data); | |
15 | 106 details_data_s << Translate::ToString(anime.GetFormat()).c_str() << "\n" |
107 << anime.GetEpisodes() << "\n" | |
108 << Translate::ToString(anime.GetUserStatus()).c_str() << "\n" | |
46 | 109 << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear() << "\n" |
15 | 110 << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n" |
111 << anime.GetAudienceScore() << "%"; | |
46 | 112 main_information_widget->layout()->addWidget(new TextWidgets::LabelledTextParagraph( |
51 | 113 tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), details_data, main_information_widget)); |
9 | 114 |
115 /* synopsis */ | |
46 | 116 TextWidgets::SelectableTextParagraph* synopsis = new TextWidgets::SelectableTextParagraph( |
51 | 117 tr("Synopsis"), QString::fromUtf8(anime.GetSynopsis().c_str()), main_information_widget); |
9 | 118 |
119 synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
46 | 120 main_information_widget->layout()->addWidget(synopsis); |
9 | 121 |
122 QWidget* settings_widget = new QWidget(tabbed_widget); | |
46 | 123 settings_widget->setLayout(new QVBoxLayout); |
124 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); | |
125 | |
126 settings_widget->layout()->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget)); | |
127 | |
128 QWidget* sg_anime_list_content = new QWidget(settings_widget); | |
129 settings_widget->layout()->addWidget(sg_anime_list_content); | |
130 sg_anime_list_content->setLayout(new QVBoxLayout); | |
131 sg_anime_list_content->layout()->setSpacing(5); | |
132 sg_anime_list_content->layout()->setContentsMargins(12, 0, 0, 0); | |
133 | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
134 /* these macros make this a lot easier to edit */ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
135 #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
|
136 #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
|
137 #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
|
138 /* Creates a subsection with a width of 175 */ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
139 #define CREATE_SUBSECTION(x) \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
140 { \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
141 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
|
142 subsection->setLayout(new QVBoxLayout); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
143 subsection->setFixedWidth(LAYOUT_ITEM_WIDTH); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
144 subsection->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
145 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING); \ |
62 | 146 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
|
147 x; \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
148 layout->addWidget(subsection); \ |
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 /* 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
|
151 #define CREATE_SECTION(a, x) \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
152 { \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
153 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
|
154 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
|
155 layout->setSpacing(LAYOUT_HORIZ_SPACING); \ |
62 | 156 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
|
157 x; \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
158 layout->addStretch(); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
159 a->layout()->addWidget(section); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
160 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
161 /* 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
|
162 #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
|
163 { \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
164 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
|
165 subsection->setLayout(new QVBoxLayout); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
166 subsection->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
167 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING); \ |
62 | 168 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
|
169 x; \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
170 layout->addWidget(subsection); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
171 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
172 /* 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
|
173 #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
|
174 { \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
175 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
|
176 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
|
177 layout->setSpacing(LAYOUT_HORIZ_SPACING); \ |
62 | 178 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
|
179 x; \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
180 a->layout()->addWidget(section); \ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
181 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
182 |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
183 CREATE_SECTION(sg_anime_list_content, { |
46 | 184 /* Episodes watched section */ |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
185 CREATE_SUBSECTION({ |
46 | 186 subsection->layout()->addWidget(new QLabel(tr("Episodes watched:"), subsection)); |
187 | |
188 QSpinBox* spin_box = new QSpinBox(subsection); | |
51 | 189 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { |
190 progress = i; | |
191 }); | |
46 | 192 spin_box->setRange(0, anime.GetEpisodes()); |
193 spin_box->setSingleStep(1); | |
51 | 194 spin_box->setValue(progress = anime.GetUserProgress()); |
46 | 195 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
|
196 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
197 CREATE_SUBSECTION({ |
46 | 198 subsection->layout()->addWidget(new QLabel(tr(" "), subsection)); |
199 | |
51 | 200 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); |
201 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, [this](int state) { | |
202 rewatching = (state == Qt::Checked); | |
203 }); | |
204 checkbox->setCheckState(anime.GetUserIsRewatching() ? Qt::Checked : Qt::Unchecked); | |
205 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
|
206 }); |
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_SECTION(sg_anime_list_content, { |
46 | 209 /* Status & score section */ |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
210 CREATE_SUBSECTION({ |
46 | 211 subsection->layout()->addWidget(new QLabel(tr("Status:"), subsection)); |
212 | |
213 QStringList string_list; | |
214 for (unsigned int i = 0; i < ARRAYSIZE(Anime::ListStatuses); i++) | |
215 string_list.append(QString::fromStdString(Translate::ToString(Anime::ListStatuses[i]))); | |
216 | |
217 QComboBox* combo_box = new QComboBox(subsection); | |
218 combo_box->addItems(string_list); | |
51 | 219 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int i) { |
220 status = Anime::ListStatuses[i]; | |
221 }); | |
222 combo_box->setCurrentIndex(static_cast<int>(status = anime.GetUserStatus())-1); | |
46 | 223 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
|
224 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
225 CREATE_SUBSECTION({ |
46 | 226 subsection->layout()->addWidget(new QLabel(tr("Score:"), subsection)); |
227 | |
228 QSpinBox* spin_box = new QSpinBox(subsection); | |
51 | 229 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { |
230 score = i; | |
231 }); | |
46 | 232 spin_box->setRange(0, 100); |
233 spin_box->setSingleStep(5); | |
51 | 234 spin_box->setValue(score = anime.GetUserScore()); |
46 | 235 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
|
236 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
237 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
238 CREATE_FULL_WIDTH_SECTION(sg_anime_list_content, { |
46 | 239 /* Notes section */ |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
240 CREATE_FULL_WIDTH_SUBSECTION({ |
46 | 241 subsection->layout()->addWidget(new QLabel(tr("Notes:"), subsection)); |
242 | |
51 | 243 QLineEdit* line_edit = new QLineEdit(subsection); |
244 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) { | |
245 /* this sucks but I don't really want to implement anything smarter :) */ | |
246 notes = text.toStdString(); | |
247 }); | |
248 line_edit->setText(QString::fromStdString(notes = anime.GetUserNotes())); | |
46 | 249 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); |
250 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
|
251 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
252 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
253 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
|
254 /* Dates section */ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
255 CREATE_SUBSECTION({ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
256 subsection->layout()->addWidget(new QLabel(tr("Date started:"), subsection)); |
46 | 257 |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
258 OptionalDate* date = new OptionalDate(true, subsection); |
51 | 259 connect(date, &OptionalDate::DataChanged, this, [this](bool enabled, Date date) { |
260 started = (enabled) ? date : Date(); | |
261 }); | |
262 started = anime.GetUserDateStarted(); | |
263 if (!started.IsValid()) { | |
264 date->SetEnabled(false); | |
265 started = anime.GetAirDate(); | |
266 } | |
267 date->SetDate(started); | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
268 subsection->layout()->addWidget(date); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
269 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
270 CREATE_SUBSECTION({ |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
271 subsection->layout()->addWidget(new QLabel(tr("Date completed:"), subsection)); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
272 |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
273 OptionalDate* date = new OptionalDate(true, subsection); |
51 | 274 connect(date, &OptionalDate::DataChanged, this, [this](bool enabled, Date date) { |
275 completed = (enabled) ? date : Date(); | |
276 }); | |
277 completed = anime.GetUserDateCompleted(); | |
278 if (!completed.IsValid()) { | |
279 date->SetEnabled(false); | |
280 completed = anime.GetAirDate(); | |
281 } | |
282 date->SetDate(completed); | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
283 subsection->layout()->addWidget(date); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
284 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
285 }); |
46 | 286 |
287 settings_widget->layout()->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); | |
288 | |
289 QWidget* sg_local_content = new QWidget(settings_widget); | |
290 settings_widget->layout()->addWidget(sg_local_content); | |
291 sg_local_content->setLayout(new QVBoxLayout); | |
292 sg_local_content->layout()->setSpacing(5); | |
293 sg_local_content->layout()->setContentsMargins(12, 0, 0, 0); | |
294 | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
295 CREATE_FULL_WIDTH_SECTION(sg_local_content, { |
46 | 296 /* Alternative titles */ |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
297 CREATE_FULL_WIDTH_SUBSECTION({ |
46 | 298 subsection->layout()->addWidget(new QLabel(tr("Alternative titles:"), subsection)); |
299 | |
300 QLineEdit* line_edit = new QLineEdit(QString::fromStdString(anime.GetUserNotes()), subsection); | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
301 line_edit->setPlaceholderText( |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
302 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); |
46 | 303 subsection->layout()->addWidget(line_edit); |
304 | |
51 | 305 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); |
46 | 306 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
|
307 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
308 }); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
309 #undef CREATE_SECTION |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
310 #undef CREATE_SUBSECTION |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
311 #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
|
312 #undef CREATE_FULL_WIDTH_SUBSECTION |
46 | 313 |
314 static_cast<QBoxLayout*>(settings_widget->layout())->addStretch(); | |
9 | 315 |
51 | 316 tabbed_widget->addTab(main_information_widget, tr("Main information")); |
317 tabbed_widget->addTab(settings_widget, tr("My list and settings")); | |
9 | 318 |
319 QVBoxLayout* main_layout = new QVBoxLayout; | |
320 main_layout->addWidget(anime_title); | |
321 main_layout->addWidget(tabbed_widget); | |
62 | 322 main_layout->setContentsMargins(0, 0, 0, 0); |
9 | 323 main_widget->setLayout(main_layout); |
324 | |
325 QHBoxLayout* layout = new QHBoxLayout; | |
326 layout->addWidget(sidebar); | |
327 layout->addWidget(main_widget); | |
328 widget->setLayout(layout); | |
329 | |
330 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | |
331 connect(button_box, &QDialogButtonBox::accepted, this, [this, accept] { | |
51 | 332 SaveData(); |
9 | 333 accept(); |
334 QDialog::accept(); | |
335 }); | |
336 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); | |
337 | |
338 QVBoxLayout* buttons_layout = new QVBoxLayout; | |
339 buttons_layout->addWidget(widget); | |
340 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom); | |
341 setLayout(buttons_layout); | |
342 } | |
343 | |
344 #include "gui/dialog/moc_information.cpp" |