comparison 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
comparison
equal deleted inserted replaced
1:1ae666fdf9e2 2:23d0d9319a00
2 #include "anime.h" 2 #include "anime.h"
3 #include "information.h" 3 #include "information.h"
4 #include "ui_utils.h" 4 #include "ui_utils.h"
5 #include "string_utils.h" 5 #include "string_utils.h"
6 6
7 InformationDialog::InformationDialog(wxWindow* parent, wxWindowID id, const wxString& title, const Anime& anime, 7 #include <QDialogButtonBox>
8 const wxPoint& position, long style)
9 : wxDialog(parent, id, title, position, wxSize(840, 613), style) {
10 wxFont font;
11 this->SetBackgroundColour(*wxWHITE);
12 wxPanel* left_panel = new wxPanel(this, wxID_ANY, wxPoint(0, 12), wxSize(170, 518));
13 wxPanel* right_panel = new wxPanel(this, wxID_ANY, wxPoint(170, 12), wxSize(840-186, 518));
14 right_panel->SetBackgroundColour(*wxWHITE);
15 wxTextCtrl* anime_title = new wxTextCtrl(right_panel, wxID_ANY, anime.title, wxPoint(0, 0), wxSize(840-186, 28), wxTE_LEFT | wxBORDER_NONE | wxTE_BESTWRAP | wxTE_READONLY | wxTE_MULTILINE | wxTE_NO_VSCROLL);
16 anime_title->SetForegroundColour(wxTheColourDatabase->Find("STEEL BLUE"));
17 font = anime_title->GetFont();
18 font.SetPointSize(12);
19 anime_title->SetFont(font);
20 wxNotebook* notebook = new wxNotebook(right_panel, wxID_ANY, wxPoint(0, 35), wxSize(840-186, 518-35));
21 notebook->SetBackgroundColour(*wxWHITE);
22 wxPanel* main_information_panel = new wxPanel(notebook, wxID_ANY, wxPoint(6, 6), wxDefaultSize);
23 UiUtils::CreateSelectableTextParagraph(main_information_panel, L"Alternative titles", L"-", 840-186-6-6, 15);
24 std::wstringstream details_data;
25 details_data << AnimeFormatToStringMap[anime.type] << "\n"
26 << anime.episodes << "\n"
27 << AnimeAiringToStringMap[anime.airing] << "\n"
28 << AnimeSeasonToStringMap[anime.season] << " " << int(anime.air_date.year()) << "\n"
29 << StringUtils::Implode(anime.genres, ", ") << "\n"
30 << anime.audience_score << "%\n";
31 UiUtils::CreateTextParagraphWithLabels(main_information_panel, L"Details", L"Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data.str().c_str(), 840-186-6-6, 94, 0, 50);
32 UiUtils::CreateSelectableTextParagraph(main_information_panel, L"Synopsis", anime.synopsis.c_str(), 840-186-6-6, 200, 0, 200);
33 8
34 wxPanel* data_input_panel = new wxPanel(notebook, wxID_ANY, wxPoint(6, 6), wxDefaultSize); 9 void InformationDialog::OnOK() {
10 model->UpdateAnime(*anime);
11 QDialog::accept();
12 }
13
14 InformationDialog::InformationDialog(Anime& a, AnimeListWidgetModel* model, QWidget* parent)
15 : QDialog(parent)
16 {
17 this->model = model;
18 this->anime = &a;
19 setFixedSize(842, 613);
20 setWindowTitle(tr("Anime Information"));
21 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
22 setObjectName("infodiag");
23 QWidget* widget = new QWidget(this);
24 widget->resize(842-175, 530);
25 widget->move(175, 0);
26 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white");
27 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
28 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromWCharArray(anime->title.english.c_str()), widget);
29 anime_title->setReadOnly(true);
30 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
31 anime_title->setWordWrapMode(QTextOption::NoWrap);
32 anime_title->setFrameShape(QFrame::NoFrame);
33 anime_title->resize(636, 28);
34 anime_title->move(0, 12);
35 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
36 anime_title->setStyleSheet("font-size: 16px; color: blue");
37 QTabWidget* tabbed_widget = new QTabWidget(widget);
38 tabbed_widget->resize(636, 485);
39 tabbed_widget->move(0, 45);
40 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
41 QWidget* main_information_widget = new QWidget(tabbed_widget);
42 UiUtils::CreateSelectableTextParagraph(main_information_widget, "Alternative titles", "-", QPoint(6, 6), QSize(636-18, 56));
43 QString details_data("");
44 QTextStream details_data_s(&details_data);
45 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n"
46 << anime->episodes << "\n"
47 << AnimeAiringToStringMap[anime->airing].c_str() << "\n"
48 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n"
49 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n"
50 << anime->audience_score << "%\n";
51 UiUtils::CreateTextParagraphWithLabels(main_information_widget, "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, QPoint(6, 62), QSize(636-18, 142));
52 UiUtils::CreateSelectableTextParagraph(main_information_widget, "Synopsis", QString::fromWCharArray(anime->synopsis.c_str()), QPoint(6, 202), QSize(636-18, 253));
53 tabbed_widget->addTab(main_information_widget, "Main information");
54 QWidget* settings_widget = new QWidget(tabbed_widget);
35 55
36 notebook->AddPage(main_information_panel, "Main information"); 56 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
37 notebook->AddPage(data_input_panel, "Anime list and settings"); 57 connect(button_box, &QDialogButtonBox::accepted, this, &OnOK);
38 58 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
59 QVBoxLayout* buttons_layout = new QVBoxLayout(widget);
60 buttons_layout->addWidget(widget, 0, Qt::AlignTop);
61 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom);
62 // this should probably be win32-only
63 setStyleSheet(UiUtils::IsInDarkMode() ? "" : "QDialog#infodiag{background-color: white;}");
64 setLayout(buttons_layout);
39 } 65 }
66
67 #include "moc_information.cpp"