annotate src/dialog/information.cpp @ 2:23d0d9319a00

Update Also converted everything to LF from CRLF
author Paper <mrpapersonic@gmail.com>
date Sat, 12 Aug 2023 03:16:26 -0400
parents 1ae666fdf9e2
children 190ded9438c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
1 #include "window.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
2 #include "anime.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
3 #include "information.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
4 #include "ui_utils.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
5 #include "string_utils.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
6
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
7 #include <QDialogButtonBox>
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
8
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
9 void InformationDialog::OnOK() {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
10 model->UpdateAnime(*anime);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
11 QDialog::accept();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
12 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
13
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
14 InformationDialog::InformationDialog(Anime& a, AnimeListWidgetModel* model, QWidget* parent)
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
15 : QDialog(parent)
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
16 {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
17 this->model = model;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
18 this->anime = &a;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
19 setFixedSize(842, 613);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
20 setWindowTitle(tr("Anime Information"));
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
21 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
22 setObjectName("infodiag");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
23 QWidget* widget = new QWidget(this);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
24 widget->resize(842-175, 530);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
25 widget->move(175, 0);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
26 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
27 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
28 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromWCharArray(anime->title.english.c_str()), widget);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
29 anime_title->setReadOnly(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
30 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
31 anime_title->setWordWrapMode(QTextOption::NoWrap);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
32 anime_title->setFrameShape(QFrame::NoFrame);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
33 anime_title->resize(636, 28);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
34 anime_title->move(0, 12);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
35 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
36 anime_title->setStyleSheet("font-size: 16px; color: blue");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
37 QTabWidget* tabbed_widget = new QTabWidget(widget);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
38 tabbed_widget->resize(636, 485);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
39 tabbed_widget->move(0, 45);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
40 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
41 QWidget* main_information_widget = new QWidget(tabbed_widget);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
42 UiUtils::CreateSelectableTextParagraph(main_information_widget, "Alternative titles", "-", QPoint(6, 6), QSize(636-18, 56));
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
43 QString details_data("");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
44 QTextStream details_data_s(&details_data);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
45 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
46 << anime->episodes << "\n"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
47 << AnimeAiringToStringMap[anime->airing].c_str() << "\n"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
48 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
49 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
50 << anime->audience_score << "%\n";
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
51 UiUtils::CreateTextParagraphWithLabels(main_information_widget, "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, QPoint(6, 62), QSize(636-18, 142));
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
52 UiUtils::CreateSelectableTextParagraph(main_information_widget, "Synopsis", QString::fromWCharArray(anime->synopsis.c_str()), QPoint(6, 202), QSize(636-18, 253));
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
53 tabbed_widget->addTab(main_information_widget, "Main information");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
54 QWidget* settings_widget = new QWidget(tabbed_widget);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
55
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
56 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
57 connect(button_box, &QDialogButtonBox::accepted, this, &OnOK);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
58 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
59 QVBoxLayout* buttons_layout = new QVBoxLayout(widget);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
60 buttons_layout->addWidget(widget, 0, Qt::AlignTop);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
61 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
62 // this should probably be win32-only
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
63 setStyleSheet(UiUtils::IsInDarkMode() ? "" : "QDialog#infodiag{background-color: white;}");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
64 setLayout(buttons_layout);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
65 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
66
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
67 #include "moc_information.cpp"