9
|
1 #include "gui/dialog/information.h"
|
|
2 #include "core/anime.h"
|
46
|
3 #include "core/array.h"
|
9
|
4 #include "core/strings.h"
|
|
5 #include "gui/pages/anime_list.h"
|
|
6 #include "gui/translate/anime.h"
|
46
|
7 #include "gui/widgets/text.h"
|
9
|
8 #include "gui/window.h"
|
46
|
9 #include <QCheckBox>
|
|
10 #include <QComboBox>
|
9
|
11 #include <QDebug>
|
|
12 #include <QDialogButtonBox>
|
46
|
13 #include <QLineEdit>
|
9
|
14 #include <QPlainTextEdit>
|
46
|
15 #include <QSpinBox>
|
|
16 #include <QStringList>
|
9
|
17 #include <QTextStream>
|
|
18 #include <QVBoxLayout>
|
|
19 #include <functional>
|
|
20
|
46
|
21 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list,
|
|
22 which sucks. Think of a better way to implement this later. */
|
|
23 InformationDialog::InformationDialog(const Anime::Anime& anime, std::function<void()> accept, QWidget* parent)
|
15
|
24 : QDialog(parent) {
|
9
|
25 setFixedSize(842, 613);
|
|
26 setWindowTitle(tr("Anime Information"));
|
|
27 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
36
|
28
|
|
29 {
|
|
30 QPalette pal;
|
|
31 pal.setColor(QPalette::Window, Qt::white);
|
|
32 setPalette(pal);
|
|
33 }
|
9
|
34
|
|
35 QWidget* widget = new QWidget(this);
|
|
36
|
|
37 /* "sidebar", includes... just the anime image :) */
|
|
38 QWidget* sidebar = new QWidget(widget);
|
|
39 sidebar->setFixedWidth(175);
|
|
40
|
|
41 /* main widget */
|
|
42 QWidget* main_widget = new QWidget(widget);
|
36
|
43
|
|
44 {
|
|
45 QPalette pal;
|
|
46 pal.setColor(QPalette::Window, Qt::white);
|
|
47 main_widget->setPalette(pal);
|
|
48 }
|
|
49
|
9
|
50 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
51
|
|
52 /* anime title header text */
|
46
|
53 TextWidgets::Paragraph* anime_title =
|
|
54 new TextWidgets::Paragraph(QString::fromUtf8(anime.GetUserPreferredTitle().c_str()), main_widget);
|
9
|
55 anime_title->setReadOnly(true);
|
|
56 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
57 anime_title->setWordWrapMode(QTextOption::NoWrap);
|
|
58 anime_title->setFrameShape(QFrame::NoFrame);
|
|
59 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
|
60 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
61 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
36
|
62
|
|
63 {
|
|
64 QFont font(anime_title->font());
|
|
65 font.setPointSize(12);
|
|
66 anime_title->setFont(font);
|
|
67 }
|
|
68
|
|
69 {
|
|
70 QPalette pal;
|
46
|
71 pal.setColor(QPalette::Window, Qt::transparent);
|
36
|
72 pal.setColor(QPalette::WindowText, Qt::blue);
|
|
73 }
|
9
|
74
|
|
75 /* tabbed widget */
|
|
76 QTabWidget* tabbed_widget = new QTabWidget(main_widget);
|
|
77 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
78
|
|
79 /* main info tab */
|
|
80 QWidget* main_information_widget = new QWidget(tabbed_widget);
|
|
81 main_information_widget->setLayout(new QVBoxLayout);
|
|
82
|
|
83 /* alt titles */
|
46
|
84 main_information_widget->layout()->addWidget(new TextWidgets::SelectableTextParagraph(
|
15
|
85 "Alternative titles", QString::fromUtf8(Strings::Implode(anime.GetTitleSynonyms(), ", ").c_str()),
|
|
86 main_information_widget));
|
9
|
87
|
|
88 /* details */
|
|
89 QString details_data;
|
|
90 QTextStream details_data_s(&details_data);
|
15
|
91 details_data_s << Translate::ToString(anime.GetFormat()).c_str() << "\n"
|
|
92 << anime.GetEpisodes() << "\n"
|
|
93 << Translate::ToString(anime.GetUserStatus()).c_str() << "\n"
|
46
|
94 << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear() << "\n"
|
15
|
95 << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n"
|
|
96 << anime.GetAudienceScore() << "%";
|
46
|
97 main_information_widget->layout()->addWidget(new TextWidgets::LabelledTextParagraph(
|
15
|
98 "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, main_information_widget));
|
9
|
99
|
|
100 /* synopsis */
|
46
|
101 TextWidgets::SelectableTextParagraph* synopsis = new TextWidgets::SelectableTextParagraph(
|
15
|
102 "Synopsis", QString::fromUtf8(anime.GetSynopsis().c_str()), main_information_widget);
|
9
|
103
|
|
104 synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
46
|
105 main_information_widget->layout()->addWidget(synopsis);
|
9
|
106
|
|
107 QWidget* settings_widget = new QWidget(tabbed_widget);
|
46
|
108 settings_widget->setLayout(new QVBoxLayout);
|
|
109 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
|
110
|
|
111 settings_widget->layout()->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget));
|
|
112
|
|
113 QWidget* sg_anime_list_content = new QWidget(settings_widget);
|
|
114 settings_widget->layout()->addWidget(sg_anime_list_content);
|
|
115 sg_anime_list_content->setLayout(new QVBoxLayout);
|
|
116 sg_anime_list_content->layout()->setSpacing(5);
|
|
117 sg_anime_list_content->layout()->setContentsMargins(12, 0, 0, 0);
|
|
118
|
|
119 /* Note: PLEASE find a way we can consolidate these. By ANY other means than
|
|
120 putting them in a separate function. Macros are very much preferred. */
|
|
121 #define LAYOUT_HORIZ_SPACING 9
|
|
122 #define LAYOUT_VERT_SPACING 5
|
|
123 {
|
|
124 /* Episodes watched section */
|
|
125 QWidget* section = new QWidget(sg_anime_list_content);
|
|
126 QHBoxLayout* layout = new QHBoxLayout;
|
|
127 layout->setSpacing(LAYOUT_HORIZ_SPACING);
|
|
128 layout->setMargin(0);
|
|
129 section->setLayout(layout);
|
|
130 {
|
|
131 QWidget* subsection = new QWidget(section);
|
|
132 subsection->setLayout(new QVBoxLayout);
|
|
133 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING);
|
|
134 subsection->layout()->setMargin(0);
|
|
135
|
|
136 subsection->layout()->addWidget(new QLabel(tr("Episodes watched:"), subsection));
|
|
137
|
|
138 QSpinBox* spin_box = new QSpinBox(subsection);
|
|
139 spin_box->setRange(0, anime.GetEpisodes());
|
|
140 spin_box->setSingleStep(1);
|
|
141 spin_box->setValue(anime.GetUserProgress());
|
|
142 subsection->layout()->addWidget(spin_box);
|
|
143
|
|
144 layout->addWidget(subsection);
|
|
145 }
|
|
146 {
|
|
147 QWidget* subsection = new QWidget(section);
|
|
148 subsection->setLayout(new QVBoxLayout);
|
|
149 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING);
|
|
150 subsection->layout()->setMargin(0);
|
|
151
|
|
152 subsection->layout()->addWidget(new QLabel(tr(" "), subsection));
|
|
153
|
|
154 QCheckBox* rewatched_checkbox = new QCheckBox("Rewatching");
|
|
155 subsection->layout()->addWidget(rewatched_checkbox);
|
|
156
|
|
157 layout->addWidget(subsection);
|
|
158 }
|
|
159 sg_anime_list_content->layout()->addWidget(section);
|
|
160 }
|
|
161 {
|
|
162 /* Status & score section */
|
|
163 QWidget* section = new QWidget(sg_anime_list_content);
|
|
164 QHBoxLayout* layout = new QHBoxLayout;
|
|
165 layout->setSpacing(LAYOUT_HORIZ_SPACING);
|
|
166 layout->setMargin(0);
|
|
167 section->setLayout(layout);
|
|
168 {
|
|
169 QWidget* subsection = new QWidget(section);
|
|
170 subsection->setLayout(new QVBoxLayout);
|
|
171 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING);
|
|
172 subsection->layout()->setMargin(0);
|
|
173
|
|
174 subsection->layout()->addWidget(new QLabel(tr("Status:"), subsection));
|
|
175
|
|
176 QStringList string_list;
|
|
177 for (unsigned int i = 0; i < ARRAYSIZE(Anime::ListStatuses); i++)
|
|
178 string_list.append(QString::fromStdString(Translate::ToString(Anime::ListStatuses[i])));
|
|
179
|
|
180 QComboBox* combo_box = new QComboBox(subsection);
|
|
181 combo_box->addItems(string_list);
|
|
182 subsection->layout()->addWidget(combo_box);
|
|
183
|
|
184 layout->addWidget(subsection);
|
|
185 }
|
|
186 {
|
|
187 QWidget* subsection = new QWidget(section);
|
|
188 subsection->setLayout(new QVBoxLayout);
|
|
189 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING);
|
|
190 subsection->layout()->setMargin(0);
|
|
191
|
|
192 subsection->layout()->addWidget(new QLabel(tr("Score:"), subsection));
|
|
193
|
|
194 QSpinBox* spin_box = new QSpinBox(subsection);
|
|
195 spin_box->setRange(0, 100);
|
|
196 spin_box->setSingleStep(5);
|
|
197 spin_box->setValue(anime.GetUserScore());
|
|
198 subsection->layout()->addWidget(spin_box);
|
|
199
|
|
200 layout->addWidget(subsection);
|
|
201 }
|
|
202 sg_anime_list_content->layout()->addWidget(section);
|
|
203 }
|
|
204 {
|
|
205 /* Notes section */
|
|
206 QWidget* section = new QWidget(sg_anime_list_content);
|
|
207 QHBoxLayout* layout = new QHBoxLayout;
|
|
208 layout->setSpacing(LAYOUT_HORIZ_SPACING);
|
|
209 layout->setMargin(0);
|
|
210 section->setLayout(layout);
|
|
211 {
|
|
212 QWidget* subsection = new QWidget(section);
|
|
213 subsection->setLayout(new QVBoxLayout);
|
|
214 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING);
|
|
215 subsection->layout()->setMargin(0);
|
|
216
|
|
217 subsection->layout()->addWidget(new QLabel(tr("Notes:"), subsection));
|
|
218
|
|
219 QLineEdit* line_edit = new QLineEdit(QString::fromStdString(anime.GetUserNotes()), subsection);
|
|
220 line_edit->setPlaceholderText(tr("Enter your notes about this anime"));
|
|
221 subsection->layout()->addWidget(line_edit);
|
|
222
|
|
223 layout->addWidget(subsection);
|
|
224 }
|
|
225 sg_anime_list_content->layout()->addWidget(section);
|
|
226 }
|
|
227
|
|
228 settings_widget->layout()->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget));
|
|
229
|
|
230 QWidget* sg_local_content = new QWidget(settings_widget);
|
|
231 settings_widget->layout()->addWidget(sg_local_content);
|
|
232 sg_local_content->setLayout(new QVBoxLayout);
|
|
233 sg_local_content->layout()->setSpacing(5);
|
|
234 sg_local_content->layout()->setContentsMargins(12, 0, 0, 0);
|
|
235
|
|
236 {
|
|
237 /* Alternative titles */
|
|
238 QWidget* section = new QWidget(sg_local_content);
|
|
239 QHBoxLayout* layout = new QHBoxLayout;
|
|
240 layout->setSpacing(LAYOUT_HORIZ_SPACING);
|
|
241 layout->setMargin(0);
|
|
242 section->setLayout(layout);
|
|
243 {
|
|
244 QWidget* subsection = new QWidget(section);
|
|
245 subsection->setLayout(new QVBoxLayout);
|
|
246 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING);
|
|
247 subsection->layout()->setMargin(0);
|
|
248
|
|
249 subsection->layout()->addWidget(new QLabel(tr("Alternative titles:"), subsection));
|
|
250
|
|
251 QLineEdit* line_edit = new QLineEdit(QString::fromStdString(anime.GetUserNotes()), subsection);
|
|
252 line_edit->setPlaceholderText(tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)"));
|
|
253 subsection->layout()->addWidget(line_edit);
|
|
254
|
|
255 QCheckBox* checkbox = new QCheckBox("Use the first alternative title to search for torrents");
|
|
256 subsection->layout()->addWidget(checkbox);
|
|
257
|
|
258 layout->addWidget(subsection);
|
|
259 }
|
|
260 sg_local_content->layout()->addWidget(section);
|
|
261 }
|
|
262
|
|
263 static_cast<QBoxLayout*>(settings_widget->layout())->addStretch();
|
9
|
264
|
|
265 tabbed_widget->addTab(main_information_widget, "Main information");
|
|
266 tabbed_widget->addTab(settings_widget, "My list and settings");
|
|
267
|
|
268 QVBoxLayout* main_layout = new QVBoxLayout;
|
|
269 main_layout->addWidget(anime_title);
|
|
270 main_layout->addWidget(tabbed_widget);
|
|
271 main_layout->setMargin(0);
|
|
272 main_widget->setLayout(main_layout);
|
|
273
|
|
274 QHBoxLayout* layout = new QHBoxLayout;
|
|
275 layout->addWidget(sidebar);
|
|
276 layout->addWidget(main_widget);
|
|
277 widget->setLayout(layout);
|
|
278
|
|
279 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
|
280 connect(button_box, &QDialogButtonBox::accepted, this, [this, accept] {
|
|
281 accept();
|
|
282 QDialog::accept();
|
|
283 });
|
|
284 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
285
|
|
286 QVBoxLayout* buttons_layout = new QVBoxLayout;
|
|
287 buttons_layout->addWidget(widget);
|
|
288 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom);
|
|
289 setLayout(buttons_layout);
|
|
290 }
|
|
291
|
|
292 #include "gui/dialog/moc_information.cpp"
|