9
|
1 #include "gui/dialog/information.h"
|
|
2 #include "core/anime.h"
|
|
3 #include "core/strings.h"
|
|
4 #include "gui/pages/anime_list.h"
|
|
5 #include "gui/translate/anime.h"
|
|
6 #include "gui/ui_utils.h"
|
|
7 #include "gui/window.h"
|
|
8 #include <QDebug>
|
|
9 #include <QDialogButtonBox>
|
|
10 #include <QPlainTextEdit>
|
|
11 #include <QTextStream>
|
|
12 #include <QVBoxLayout>
|
|
13 #include <functional>
|
|
14
|
|
15 InformationDialog::InformationDialog(Anime::Anime& anime, std::function<void()> accept, QWidget* parent)
|
15
|
16 : QDialog(parent) {
|
9
|
17 setFixedSize(842, 613);
|
|
18 setWindowTitle(tr("Anime Information"));
|
|
19 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
36
|
20
|
|
21 {
|
|
22 QPalette pal;
|
|
23 pal.setColor(QPalette::Window, Qt::white);
|
|
24 setPalette(pal);
|
|
25 }
|
9
|
26
|
|
27 QWidget* widget = new QWidget(this);
|
|
28
|
|
29 /* "sidebar", includes... just the anime image :) */
|
|
30 QWidget* sidebar = new QWidget(widget);
|
|
31 sidebar->setFixedWidth(175);
|
|
32
|
|
33 /* main widget */
|
|
34 QWidget* main_widget = new QWidget(widget);
|
36
|
35
|
|
36 {
|
|
37 QPalette pal;
|
|
38 pal.setColor(QPalette::Window, Qt::white);
|
|
39 main_widget->setPalette(pal);
|
|
40 }
|
|
41
|
9
|
42 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
43
|
|
44 /* anime title header text */
|
|
45 UiUtils::Paragraph* anime_title =
|
15
|
46 new UiUtils::Paragraph(QString::fromUtf8(anime.GetUserPreferredTitle().c_str()), main_widget);
|
9
|
47 anime_title->setReadOnly(true);
|
|
48 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
49 anime_title->setWordWrapMode(QTextOption::NoWrap);
|
|
50 anime_title->setFrameShape(QFrame::NoFrame);
|
|
51 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
|
52 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
53 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
36
|
54
|
|
55 {
|
|
56 QFont font(anime_title->font());
|
|
57 font.setPointSize(12);
|
|
58 anime_title->setFont(font);
|
|
59 }
|
|
60
|
|
61 {
|
|
62 QPalette pal;
|
|
63 pal.setColor(QPalette::Window, QColor(255, 255, 255, 0));
|
|
64 pal.setColor(QPalette::WindowText, Qt::blue);
|
|
65 }
|
9
|
66
|
|
67 /* tabbed widget */
|
|
68 QTabWidget* tabbed_widget = new QTabWidget(main_widget);
|
|
69 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
70
|
|
71 /* main info tab */
|
|
72 QWidget* main_information_widget = new QWidget(tabbed_widget);
|
|
73 main_information_widget->setLayout(new QVBoxLayout);
|
|
74
|
|
75 /* alt titles */
|
|
76 main_information_widget->layout()->addWidget(new UiUtils::SelectableTextParagraph(
|
15
|
77 "Alternative titles", QString::fromUtf8(Strings::Implode(anime.GetTitleSynonyms(), ", ").c_str()),
|
|
78 main_information_widget));
|
9
|
79
|
|
80 /* details */
|
|
81 QString details_data;
|
|
82 QTextStream details_data_s(&details_data);
|
15
|
83 details_data_s << Translate::ToString(anime.GetFormat()).c_str() << "\n"
|
|
84 << anime.GetEpisodes() << "\n"
|
|
85 << Translate::ToString(anime.GetUserStatus()).c_str() << "\n"
|
|
86 << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear()
|
|
87 << "\n"
|
|
88 << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n"
|
|
89 << anime.GetAudienceScore() << "%";
|
9
|
90 main_information_widget->layout()->addWidget(new UiUtils::LabelledTextParagraph(
|
15
|
91 "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, main_information_widget));
|
9
|
92
|
|
93 /* synopsis */
|
|
94 UiUtils::SelectableTextParagraph* synopsis = new UiUtils::SelectableTextParagraph(
|
15
|
95 "Synopsis", QString::fromUtf8(anime.GetSynopsis().c_str()), main_information_widget);
|
9
|
96
|
|
97 synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
|
98 ((QVBoxLayout*)main_information_widget->layout())->addWidget(synopsis);
|
|
99
|
|
100 QWidget* settings_widget = new QWidget(tabbed_widget);
|
|
101
|
|
102 tabbed_widget->addTab(main_information_widget, "Main information");
|
|
103 tabbed_widget->addTab(settings_widget, "My list and settings");
|
|
104
|
|
105 QVBoxLayout* main_layout = new QVBoxLayout;
|
|
106 main_layout->addWidget(anime_title);
|
|
107 main_layout->addWidget(tabbed_widget);
|
|
108 main_layout->setMargin(0);
|
|
109 main_widget->setLayout(main_layout);
|
|
110
|
|
111 QHBoxLayout* layout = new QHBoxLayout;
|
|
112 layout->addWidget(sidebar);
|
|
113 layout->addWidget(main_widget);
|
|
114 widget->setLayout(layout);
|
|
115
|
|
116 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
|
117 connect(button_box, &QDialogButtonBox::accepted, this, [this, accept] {
|
|
118 accept();
|
|
119 QDialog::accept();
|
|
120 });
|
|
121 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
122
|
|
123 QVBoxLayout* buttons_layout = new QVBoxLayout;
|
|
124 buttons_layout->addWidget(widget);
|
|
125 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom);
|
|
126 setLayout(buttons_layout);
|
|
127 }
|
|
128
|
|
129 #include "gui/dialog/moc_information.cpp"
|