comparison 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
comparison
equal deleted inserted replaced
6:1d82f6e04d7d 7:07a9095eaeed
1 #include <QPlainTextEdit>
2 #include <QVBoxLayout>
3 #include <QTextStream>
4 #include <QDebug>
1 #include "window.h" 5 #include "window.h"
2 #include "anime.h" 6 #include "anime.h"
7 #include "anime_list.h"
3 #include "information.h" 8 #include "information.h"
4 #include "ui_utils.h" 9 #include "ui_utils.h"
5 #include "string_utils.h" 10 #include "string_utils.h"
6 11
7 #include <QDialogButtonBox> 12 #include <QDialogButtonBox>
23 QWidget* widget = new QWidget(this); 28 QWidget* widget = new QWidget(this);
24 widget->resize(842-175, 530); 29 widget->resize(842-175, 530);
25 widget->move(175, 0); 30 widget->move(175, 0);
26 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white"); 31 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white");
27 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 32 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
28 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromUtf8(anime->title.english.c_str()), widget); 33 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromUtf8(anime->GetUserPreferredTitle().c_str()), widget);
29 anime_title->setReadOnly(true); 34 anime_title->setReadOnly(true);
30 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 35 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
31 anime_title->setWordWrapMode(QTextOption::NoWrap); 36 anime_title->setWordWrapMode(QTextOption::NoWrap);
32 anime_title->setFrameShape(QFrame::NoFrame); 37 anime_title->setFrameShape(QFrame::NoFrame);
33 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 38 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
39 QTabWidget* tabbed_widget = new QTabWidget(widget); 44 QTabWidget* tabbed_widget = new QTabWidget(widget);
40 tabbed_widget->resize(636, 485); 45 tabbed_widget->resize(636, 485);
41 tabbed_widget->move(0, 45); 46 tabbed_widget->move(0, 45);
42 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 47 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
43 QWidget* main_information_widget = new QWidget(tabbed_widget); 48 QWidget* main_information_widget = new QWidget(tabbed_widget);
44 UiUtils::CreateSelectableTextParagraph(main_information_widget, "Alternative titles", "-", QPoint(6, 6), QSize(636-18, 56)); 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
45 QString details_data(""); 57 QString details_data("");
46 QTextStream details_data_s(&details_data); 58 QTextStream details_data_s(&details_data);
47 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n" 59 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n"
48 << anime->episodes << "\n" 60 << anime->episodes << "\n"
49 << AnimeAiringToStringMap[anime->airing].c_str() << "\n" 61 << AnimeAiringToStringMap[anime->airing].c_str() << "\n"
50 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n" 62 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n"
51 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n" 63 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n"
52 << anime->audience_score << "%\n"; 64 << anime->audience_score << "%\n";
53 UiUtils::CreateTextParagraphWithLabels(main_information_widget, "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, QPoint(6, 62), QSize(636-18, 142)); 65 QWidget* soidjhfh = UiUtils::CreateTextParagraphWithLabels(main_information_widget, "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data)->parentWidget()->parentWidget();
54 UiUtils::CreateSelectableTextParagraph(main_information_widget, "Synopsis", QString::fromUtf8(anime->synopsis.c_str()), QPoint(6, 202), QSize(636-18, 253)); 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
55 tabbed_widget->addTab(main_information_widget, "Main information"); 76 tabbed_widget->addTab(main_information_widget, "Main information");
56 QWidget* settings_widget = new QWidget(tabbed_widget); 77 QWidget* settings_widget = new QWidget(tabbed_widget);
57 tabbed_widget->addTab(settings_widget, "My list and settings"); 78 tabbed_widget->addTab(settings_widget, "My list and settings");
58 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 79 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
59 connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK); 80 connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK);