Mercurial > minori
annotate src/dialog/information.cpp @ 7:07a9095eaeed
Update
Refactored some code, moved some around
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Thu, 24 Aug 2023 23:11:38 -0400 |
| parents | 1d82f6e04d7d |
| children | b1f73678ef61 |
| 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"); | |
| 28 QWidget* widget = new QWidget(this); | |
| 29 widget->resize(842-175, 530); | |
| 30 widget->move(175, 0); | |
| 31 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white"); | |
| 32 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | |
| 7 | 33 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromUtf8(anime->GetUserPreferredTitle().c_str()), widget); |
| 2 | 34 anime_title->setReadOnly(true); |
| 35 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
| 36 anime_title->setWordWrapMode(QTextOption::NoWrap); | |
| 37 anime_title->setFrameShape(QFrame::NoFrame); | |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
38 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
39 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
40 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
41 anime_title->setStyleSheet("font-size: 16px; color: blue; background: transparent;"); |
| 2 | 42 anime_title->resize(636, 28); |
| 43 anime_title->move(0, 12); | |
| 44 QTabWidget* tabbed_widget = new QTabWidget(widget); | |
| 45 tabbed_widget->resize(636, 485); | |
| 46 tabbed_widget->move(0, 45); | |
| 47 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | |
| 48 QWidget* main_information_widget = new QWidget(tabbed_widget); | |
| 7 | 49 main_information_widget->setLayout(new QVBoxLayout); |
| 50 | |
| 51 QString alternative_titles = QString::fromUtf8(StringUtils::Implode(anime->GetTitleSynonyms(), ", ").c_str()); | |
| 52 | |
| 53 QWidget* alternative_titles_w = UiUtils::CreateSelectableTextParagraph(main_information_widget, "Alternative titles", alternative_titles)->parentWidget()->parentWidget(); | |
| 54 //alternative_titles_w->setFixedHeight(60); | |
| 55 main_information_widget->layout()->addWidget(alternative_titles_w); | |
| 56 | |
| 2 | 57 QString details_data(""); |
| 58 QTextStream details_data_s(&details_data); | |
| 59 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n" | |
| 60 << anime->episodes << "\n" | |
| 61 << AnimeAiringToStringMap[anime->airing].c_str() << "\n" | |
| 62 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n" | |
| 63 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n" | |
| 64 << anime->audience_score << "%\n"; | |
| 7 | 65 QWidget* soidjhfh = UiUtils::CreateTextParagraphWithLabels(main_information_widget, "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data)->parentWidget()->parentWidget(); |
| 66 main_information_widget->layout()->addWidget(soidjhfh); | |
| 67 | |
| 68 QPlainTextEdit* synopsis = UiUtils::CreateSelectableTextParagraph(main_information_widget, "Synopsis", QString::fromUtf8(anime->synopsis.c_str())); | |
| 69 synopsis->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
| 70 synopsis->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
| 71 synopsis->parentWidget()->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
| 72 ((QVBoxLayout*)main_information_widget->layout())->addWidget(synopsis->parentWidget()->parentWidget()); | |
| 73 | |
| 74 //((QVBoxLayout*)main_information_widget->layout())->addStretch(); | |
| 75 | |
| 2 | 76 tabbed_widget->addTab(main_information_widget, "Main information"); |
| 77 QWidget* settings_widget = new QWidget(tabbed_widget); | |
| 3 | 78 tabbed_widget->addTab(settings_widget, "My list and settings"); |
| 2 | 79 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); |
| 3 | 80 connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK); |
| 2 | 81 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
|
82 QVBoxLayout* buttons_layout = new QVBoxLayout(this); |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
83 //buttons_layout->addWidget(widget, 0, Qt::AlignTop); |
| 2 | 84 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom); |
| 85 // this should probably be win32-only | |
| 86 setStyleSheet(UiUtils::IsInDarkMode() ? "" : "QDialog#infodiag{background-color: white;}"); | |
| 87 setLayout(buttons_layout); | |
| 88 } | |
| 89 | |
| 90 #include "moc_information.cpp" |
