Mercurial > minori
annotate src/dialog/information.cpp @ 8:b1f73678ef61
update
text paragraphs are now their own objects, as they should be
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 26 Aug 2023 03:39:34 -0400 |
parents | 07a9095eaeed |
children |
rev | line source |
---|---|
7 | 1 #include <QPlainTextEdit> |
2 #include <QVBoxLayout> | |
3 #include <QTextStream> | |
4 #include <QDebug> | |
2 | 5 #include "window.h" |
6 #include "anime.h" | |
7 | 7 #include "anime_list.h" |
2 | 8 #include "information.h" |
9 #include "ui_utils.h" | |
10 #include "string_utils.h" | |
11 | |
12 #include <QDialogButtonBox> | |
13 | |
14 void InformationDialog::OnOK() { | |
15 model->UpdateAnime(*anime); | |
16 QDialog::accept(); | |
17 } | |
18 | |
19 InformationDialog::InformationDialog(Anime& a, AnimeListWidgetModel* model, QWidget* parent) | |
20 : QDialog(parent) | |
21 { | |
22 this->model = model; | |
23 this->anime = &a; | |
24 setFixedSize(842, 613); | |
25 setWindowTitle(tr("Anime Information")); | |
26 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
27 setObjectName("infodiag"); | |
8 | 28 |
29 /* main widget */ | |
2 | 30 QWidget* widget = new QWidget(this); |
31 widget->resize(842-175, 530); | |
32 widget->move(175, 0); | |
33 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white"); | |
34 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | |
8 | 35 |
36 /* anime title header text */ | |
7 | 37 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromUtf8(anime->GetUserPreferredTitle().c_str()), widget); |
2 | 38 anime_title->setReadOnly(true); |
39 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
40 anime_title->setWordWrapMode(QTextOption::NoWrap); | |
41 anime_title->setFrameShape(QFrame::NoFrame); | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
42 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
43 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
44 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
45 anime_title->setStyleSheet("font-size: 16px; color: blue; background: transparent;"); |
2 | 46 anime_title->resize(636, 28); |
47 anime_title->move(0, 12); | |
8 | 48 |
49 /* tabbed widget */ | |
2 | 50 QTabWidget* tabbed_widget = new QTabWidget(widget); |
51 tabbed_widget->resize(636, 485); | |
52 tabbed_widget->move(0, 45); | |
53 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | |
8 | 54 |
55 /* main info tab */ | |
2 | 56 QWidget* main_information_widget = new QWidget(tabbed_widget); |
7 | 57 main_information_widget->setLayout(new QVBoxLayout); |
58 | |
8 | 59 /* alt titles */ |
60 main_information_widget->layout()->addWidget(new UiUtils::SelectableTextParagraph("Alternative titles", QString::fromUtf8(StringUtils::Implode(anime->GetTitleSynonyms(), ", ").c_str()), main_information_widget)); | |
7 | 61 |
8 | 62 /* details */ |
63 QString details_data; | |
2 | 64 QTextStream details_data_s(&details_data); |
65 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n" | |
66 << anime->episodes << "\n" | |
67 << AnimeAiringToStringMap[anime->airing].c_str() << "\n" | |
68 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n" | |
69 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n" | |
8 | 70 << anime->audience_score << "%"; |
71 main_information_widget->layout()->addWidget(new UiUtils::LabelledTextParagraph("Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, main_information_widget)); | |
7 | 72 |
8 | 73 /* synopsis */ |
74 UiUtils::SelectableTextParagraph* synopsis = new UiUtils::SelectableTextParagraph("Synopsis", QString::fromUtf8(anime->synopsis.c_str()), main_information_widget); | |
75 synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
76 ((QVBoxLayout*)main_information_widget->layout())->addWidget(synopsis); | |
7 | 77 |
78 //((QVBoxLayout*)main_information_widget->layout())->addStretch(); | |
79 | |
8 | 80 QWidget* settings_widget = new QWidget(tabbed_widget); |
81 | |
2 | 82 tabbed_widget->addTab(main_information_widget, "Main information"); |
3 | 83 tabbed_widget->addTab(settings_widget, "My list and settings"); |
2 | 84 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); |
3 | 85 connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK); |
2 | 86 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
87 QVBoxLayout* buttons_layout = new QVBoxLayout(this); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
88 //buttons_layout->addWidget(widget, 0, Qt::AlignTop); |
2 | 89 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom); |
90 // this should probably be win32-only | |
91 setStyleSheet(UiUtils::IsInDarkMode() ? "" : "QDialog#infodiag{background-color: white;}"); | |
92 setLayout(buttons_layout); | |
93 } | |
94 | |
95 #include "moc_information.cpp" |