comparison src/gui/widgets/anime_button.cc @ 348:6b0768158dcd

text: redesign almost every widget i.e. Paragraph is now a QLabel, etc etc, some things will probably break, idc
author Paper <paper@paper.us.eu.org>
date Tue, 25 Jun 2024 11:19:54 -0400
parents 5d3c9b31aa6e
children f81bed4e04ac
comparison
equal deleted inserted replaced
347:a0aa8c8c4307 348:6b0768158dcd
9 9
10 #include <QDate> 10 #include <QDate>
11 #include <QHBoxLayout> 11 #include <QHBoxLayout>
12 #include <QVBoxLayout> 12 #include <QVBoxLayout>
13 #include <QWidget> 13 #include <QWidget>
14
15 #include <iostream>
14 16
15 /* This widget is only used on the Seasons page. */ 17 /* This widget is only used on the Seasons page. */
16 18
17 /***********************************\ 19 /***********************************\
18 *|---------| Title * 20 *|---------| Title *
24 *| | Popularity * 26 *| | Popularity *
25 *| | * 27 *| | *
26 *|_________| Synopsis * 28 *|_________| Synopsis *
27 \***********************************/ 29 \***********************************/
28 30
29 AnimeButton::AnimeButton(QWidget* parent) 31 AnimeButton::AnimeButton(QWidget* parent) : QFrame(parent) {
30 : QFrame(parent)
31 , _info(tr("Aired:\nEpisodes:\nGenres:\nProducers:\nScore:\nPopularity:"), "\n\n\n\n\n", nullptr)
32 , _synopsis("", nullptr) {
33 setFrameShadow(QFrame::Plain); 32 setFrameShadow(QFrame::Plain);
34 setFrameShape(QFrame::Box); 33 setFrameShape(QFrame::Box);
34
35 QHBoxLayout* ly = new QHBoxLayout(this); 35 QHBoxLayout* ly = new QHBoxLayout(this);
36 36
37 /* XXX does Qt have a "fixed ratio"? */ 37 _poster.SetClickable(false);
38 _poster.setFixedSize(120, 170); 38 _poster.setFixedSize(120, 170);
39 _poster.SetClickable(false);
40 ly->addWidget(&_poster, 0, Qt::AlignTop); 39 ly->addWidget(&_poster, 0, Qt::AlignTop);
40
41 const std::vector<std::pair<std::string, std::string>> imap = {
42 {Strings::Translate("Aired:"), ""},
43 {Strings::Translate("Episodes:"), ""},
44 {Strings::Translate("Genres:"), ""},
45 {Strings::Translate("Producers:"), ""},
46 {Strings::Translate("Score:"), ""},
47 {Strings::Translate("Popularity:"), ""},
48 };
49
50 _info.SetData(imap);
41 51
42 { 52 {
43 QWidget* misc_section = new QWidget(this); 53 QWidget* misc_section = new QWidget(this);
44 misc_section->setFixedSize(354, 180); 54 misc_section->setFixedSize(354, 180);
45 55
54 fnt.setWeight(QFont::Bold); 64 fnt.setWeight(QFont::Bold);
55 _title.setFont(fnt); 65 _title.setFont(fnt);
56 } 66 }
57 misc_layout->addWidget(&_title); 67 misc_layout->addWidget(&_title);
58 68
59 { 69 _info.SetStyle(TextWidgets::LabelledParagraph::Style::BoldedLabels);
60 QFont fnt(_info.GetLabels()->font());
61 fnt.setWeight(QFont::Bold);
62 _info.GetLabels()->setFont(fnt);
63 }
64 70
65 _info.setContentsMargins(4, 0, 4, 0); 71 _info.setContentsMargins(4, 0, 4, 0);
66 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); 72 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
67 misc_layout->addWidget(&_info); 73 misc_layout->addWidget(&_info);
68 74
72 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy); 78 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy);
73 dummy_layout->setSpacing(0); 79 dummy_layout->setSpacing(0);
74 dummy_layout->setContentsMargins(0, 0, 0, 0); 80 dummy_layout->setContentsMargins(0, 0, 0, 0);
75 81
76 _synopsis.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); 82 _synopsis.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
83 _synopsis.SetSelectable(false);
77 dummy_layout->addWidget(&_synopsis); 84 dummy_layout->addWidget(&_synopsis);
78 misc_layout->addWidget(dummy); 85 misc_layout->addWidget(dummy);
79 } 86 }
80 87
81 ly->addWidget(misc_section, 0, Qt::AlignTop); 88 ly->addWidget(misc_section, 0, Qt::AlignTop);
88 95
89 void AnimeButton::SetAnime(const Anime::Anime& anime) { 96 void AnimeButton::SetAnime(const Anime::Anime& anime) {
90 _poster.SetAnime(anime); 97 _poster.SetAnime(anime);
91 _title.setText(Strings::ToQString(anime.GetUserPreferredTitle())); 98 _title.setText(Strings::ToQString(anime.GetUserPreferredTitle()));
92 99
93 { 100 const QLocale& locale = session.config.locale.GetLocale();
94 const QLocale& locale = session.config.locale.GetLocale();
95 _info.GetData()->setText(locale.toString(anime.GetStartedDate().GetAsQDate(), "dd MMM yyyy") + "\n" +
96 QString::number(anime.GetEpisodes()) + "\n" +
97 Strings::ToQString(Strings::Implode(anime.GetGenres(), ", ")) + "\n" + "...\n" +
98 QString::number(anime.GetAudienceScore()) + "%\n" + "...");
99 }
100 101
101 _synopsis.SetText(Strings::ToQString(anime.GetSynopsis())); 102 const std::vector<std::pair<std::string, std::string>> imap = {
103 {Strings::Translate("Aired:"), Strings::ToUtf8String(locale.toString(anime.GetStartedDate().GetAsQDate(), "dd MMM yyyy"))},
104 {Strings::Translate("Episodes:"), Strings::ToUtf8String(anime.GetEpisodes())},
105 {Strings::Translate("Genres:"), Strings::Implode(anime.GetGenres(), ", ")},
106 {Strings::Translate("Producers:"), "..."},
107 {Strings::Translate("Score:"), Strings::ToUtf8String(anime.GetAudienceScore()) + "%"},
108 {Strings::Translate("Popularity:"), "..."},
109 };
110
111 _info.SetData(imap);
112
113 _synopsis.SetText(anime.GetSynopsis());
102 } 114 }