comparison 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
comparison
equal deleted inserted replaced
7:07a9095eaeed 8:b1f73678ef61
23 this->anime = &a; 23 this->anime = &a;
24 setFixedSize(842, 613); 24 setFixedSize(842, 613);
25 setWindowTitle(tr("Anime Information")); 25 setWindowTitle(tr("Anime Information"));
26 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); 26 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
27 setObjectName("infodiag"); 27 setObjectName("infodiag");
28
29 /* main widget */
28 QWidget* widget = new QWidget(this); 30 QWidget* widget = new QWidget(this);
29 widget->resize(842-175, 530); 31 widget->resize(842-175, 530);
30 widget->move(175, 0); 32 widget->move(175, 0);
31 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white"); 33 widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white");
32 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 34 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
35
36 /* anime title header text */
33 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromUtf8(anime->GetUserPreferredTitle().c_str()), widget); 37 QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromUtf8(anime->GetUserPreferredTitle().c_str()), widget);
34 anime_title->setReadOnly(true); 38 anime_title->setReadOnly(true);
35 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 39 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
36 anime_title->setWordWrapMode(QTextOption::NoWrap); 40 anime_title->setWordWrapMode(QTextOption::NoWrap);
37 anime_title->setFrameShape(QFrame::NoFrame); 41 anime_title->setFrameShape(QFrame::NoFrame);
39 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 43 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
40 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 44 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
41 anime_title->setStyleSheet("font-size: 16px; color: blue; background: transparent;"); 45 anime_title->setStyleSheet("font-size: 16px; color: blue; background: transparent;");
42 anime_title->resize(636, 28); 46 anime_title->resize(636, 28);
43 anime_title->move(0, 12); 47 anime_title->move(0, 12);
48
49 /* tabbed widget */
44 QTabWidget* tabbed_widget = new QTabWidget(widget); 50 QTabWidget* tabbed_widget = new QTabWidget(widget);
45 tabbed_widget->resize(636, 485); 51 tabbed_widget->resize(636, 485);
46 tabbed_widget->move(0, 45); 52 tabbed_widget->move(0, 45);
47 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 53 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
54
55 /* main info tab */
48 QWidget* main_information_widget = new QWidget(tabbed_widget); 56 QWidget* main_information_widget = new QWidget(tabbed_widget);
49 main_information_widget->setLayout(new QVBoxLayout); 57 main_information_widget->setLayout(new QVBoxLayout);
50 58
51 QString alternative_titles = QString::fromUtf8(StringUtils::Implode(anime->GetTitleSynonyms(), ", ").c_str()); 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));
52 61
53 QWidget* alternative_titles_w = UiUtils::CreateSelectableTextParagraph(main_information_widget, "Alternative titles", alternative_titles)->parentWidget()->parentWidget(); 62 /* details */
54 //alternative_titles_w->setFixedHeight(60); 63 QString details_data;
55 main_information_widget->layout()->addWidget(alternative_titles_w);
56
57 QString details_data("");
58 QTextStream details_data_s(&details_data); 64 QTextStream details_data_s(&details_data);
59 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n" 65 details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n"
60 << anime->episodes << "\n" 66 << anime->episodes << "\n"
61 << AnimeAiringToStringMap[anime->airing].c_str() << "\n" 67 << AnimeAiringToStringMap[anime->airing].c_str() << "\n"
62 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n" 68 << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n"
63 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n" 69 << StringUtils::Implode(anime->genres, ", ").c_str() << "\n"
64 << anime->audience_score << "%\n"; 70 << anime->audience_score << "%";
65 QWidget* soidjhfh = UiUtils::CreateTextParagraphWithLabels(main_information_widget, "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data)->parentWidget()->parentWidget(); 71 main_information_widget->layout()->addWidget(new UiUtils::LabelledTextParagraph("Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, main_information_widget));
66 main_information_widget->layout()->addWidget(soidjhfh);
67 72
68 QPlainTextEdit* synopsis = UiUtils::CreateSelectableTextParagraph(main_information_widget, "Synopsis", QString::fromUtf8(anime->synopsis.c_str())); 73 /* synopsis */
69 synopsis->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); 74 UiUtils::SelectableTextParagraph* synopsis = new UiUtils::SelectableTextParagraph("Synopsis", QString::fromUtf8(anime->synopsis.c_str()), main_information_widget);
70 synopsis->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); 75 synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
71 synopsis->parentWidget()->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); 76 ((QVBoxLayout*)main_information_widget->layout())->addWidget(synopsis);
72 ((QVBoxLayout*)main_information_widget->layout())->addWidget(synopsis->parentWidget()->parentWidget());
73 77
74 //((QVBoxLayout*)main_information_widget->layout())->addStretch(); 78 //((QVBoxLayout*)main_information_widget->layout())->addStretch();
75 79
80 QWidget* settings_widget = new QWidget(tabbed_widget);
81
76 tabbed_widget->addTab(main_information_widget, "Main information"); 82 tabbed_widget->addTab(main_information_widget, "Main information");
77 QWidget* settings_widget = new QWidget(tabbed_widget);
78 tabbed_widget->addTab(settings_widget, "My list and settings"); 83 tabbed_widget->addTab(settings_widget, "My list and settings");
79 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 84 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
80 connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK); 85 connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK);
81 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); 86 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
82 QVBoxLayout* buttons_layout = new QVBoxLayout(this); 87 QVBoxLayout* buttons_layout = new QVBoxLayout(this);