annotate src/gui/dialog/information.cpp @ 36:2743011a6042

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