Mercurial > minori
comparison src/gui/widgets/anime_button.cc @ 370:ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 10:22:04 -0400 |
parents | f81bed4e04ac |
children |
comparison
equal
deleted
inserted
replaced
369:47c9f8502269 | 370:ea3a74ed2ef9 |
---|---|
12 #include <QVBoxLayout> | 12 #include <QVBoxLayout> |
13 #include <QWidget> | 13 #include <QWidget> |
14 | 14 |
15 #include <iostream> | 15 #include <iostream> |
16 | 16 |
17 /* This widget is only used on the Seasons page. */ | 17 /* This widget is only used on the Seasons page. |
18 * | |
19 * FIXME: If the synopsis is too long, it makes this widget look | |
20 * totally fucked. */ | |
18 | 21 |
19 /***********************************\ | 22 /***********************************\ |
20 *|---------| Title * | 23 *|---------| Title * |
21 *| | * | 24 *| | * |
22 *| | Aired * | 25 *| | Aired * |
26 *| | Popularity * | 29 *| | Popularity * |
27 *| | * | 30 *| | * |
28 *|_________| Synopsis * | 31 *|_________| Synopsis * |
29 \***********************************/ | 32 \***********************************/ |
30 | 33 |
31 AnimeButton::AnimeButton(QWidget* parent) : QFrame(parent) { | 34 AnimeButton::AnimeButton(QWidget *parent) : QFrame(parent) |
35 { | |
32 setFrameShadow(QFrame::Plain); | 36 setFrameShadow(QFrame::Plain); |
33 setFrameShape(QFrame::Box); | 37 setFrameShape(QFrame::Box); |
34 | 38 |
35 QHBoxLayout* ly = new QHBoxLayout(this); | 39 QHBoxLayout *ly = new QHBoxLayout(this); |
36 | 40 |
37 _poster.SetClickable(false); | 41 _poster.SetClickable(false); |
38 ly->addWidget(&_poster, 1, Qt::AlignTop); | 42 ly->addWidget(&_poster, 1, Qt::AlignTop); |
39 | 43 |
40 const std::vector<std::pair<std::string, std::string>> imap = { | 44 const std::vector<std::pair<std::string, std::string>> imap = { |
41 {Strings::Translate("Aired:"), ""}, | 45 {Strings::Translate("Aired:"), ""}, |
42 {Strings::Translate("Episodes:"), ""}, | 46 {Strings::Translate("Episodes:"), ""}, |
43 {Strings::Translate("Genres:"), ""}, | 47 {Strings::Translate("Genres:"), ""}, |
44 {Strings::Translate("Producers:"), ""}, | 48 {Strings::Translate("Producers:"), ""}, |
45 {Strings::Translate("Score:"), ""}, | 49 {Strings::Translate("Score:"), ""}, |
46 {Strings::Translate("Popularity:"), ""}, | 50 {Strings::Translate("Popularity:"), ""}, |
47 }; | 51 }; |
48 | 52 |
49 _info.SetData(imap); | 53 _info.SetData(imap); |
50 | 54 |
51 { | 55 { |
52 QWidget* misc_section = new QWidget(this); | 56 QWidget *misc_section = new QWidget(this); |
53 | 57 |
54 QVBoxLayout* misc_layout = new QVBoxLayout(misc_section); | 58 QVBoxLayout *misc_layout = new QVBoxLayout(misc_section); |
55 misc_layout->setContentsMargins(0, 0, 0, 0); | 59 misc_layout->setContentsMargins(0, 0, 0, 0); |
56 | 60 |
57 _title.setAutoFillBackground(true); | 61 _title.setAutoFillBackground(true); |
58 _title.setContentsMargins(4, 4, 4, 4); | 62 _title.setContentsMargins(4, 4, 4, 4); |
59 _title.setStyleSheet("background-color: rgba(0, 245, 25, 50);"); | 63 _title.setStyleSheet("background-color: rgba(0, 245, 25, 50);"); |
69 _info.setContentsMargins(4, 0, 4, 0); | 73 _info.setContentsMargins(4, 0, 4, 0); |
70 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | 74 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); |
71 misc_layout->addWidget(&_info); | 75 misc_layout->addWidget(&_info); |
72 | 76 |
73 { | 77 { |
74 QWidget* dummy = new QWidget(misc_section); | 78 QWidget *dummy = new QWidget(misc_section); |
75 dummy->setContentsMargins(4, 0, 4, 0); | 79 dummy->setContentsMargins(4, 0, 4, 0); |
76 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy); | 80 QVBoxLayout *dummy_layout = new QVBoxLayout(dummy); |
77 dummy_layout->setSpacing(0); | 81 dummy_layout->setSpacing(0); |
78 dummy_layout->setContentsMargins(0, 0, 0, 0); | 82 dummy_layout->setContentsMargins(0, 0, 0, 0); |
79 | 83 |
80 _synopsis.SetSelectable(false); | 84 _synopsis.SetSelectable(false); |
81 dummy_layout->addWidget(&_synopsis); | 85 dummy_layout->addWidget(&_synopsis); |
84 | 88 |
85 ly->addWidget(misc_section, 3, Qt::AlignTop); | 89 ly->addWidget(misc_section, 3, Qt::AlignTop); |
86 } | 90 } |
87 } | 91 } |
88 | 92 |
89 AnimeButton::AnimeButton(const Anime::Anime& anime, QWidget* parent) : AnimeButton(parent) { | 93 AnimeButton::AnimeButton(const Anime::Anime &anime, QWidget *parent) : AnimeButton(parent) |
94 { | |
90 SetAnime(anime); | 95 SetAnime(anime); |
91 } | 96 } |
92 | 97 |
93 void AnimeButton::SetAnime(const Anime::Anime& anime) { | 98 void AnimeButton::SetAnime(const Anime::Anime &anime) |
99 { | |
94 _poster.SetAnime(anime); | 100 _poster.SetAnime(anime); |
95 _title.setText(Strings::ToQString(anime.GetUserPreferredTitle())); | 101 _title.setText(Strings::ToQString(anime.GetUserPreferredTitle())); |
96 | 102 |
97 const QLocale& locale = session.config.locale.GetLocale(); | 103 const QLocale &locale = session.config.locale.GetLocale(); |
98 | 104 |
99 const std::vector<std::pair<std::string, std::string>> imap = { | 105 const std::vector<std::pair<std::string, std::string>> imap = { |
100 {Strings::Translate("Aired:"), Strings::ToUtf8String(locale.toString(anime.GetStartedDate().GetAsQDate(), "dd MMM yyyy"))}, | 106 {Strings::Translate("Aired:"), |
101 {Strings::Translate("Episodes:"), Strings::ToUtf8String(anime.GetEpisodes())}, | 107 Strings::ToUtf8String(locale.toString(anime.GetStartedDate().GetAsQDate(), "dd MMM yyyy"))}, |
102 {Strings::Translate("Genres:"), Strings::Implode(anime.GetGenres(), ", ")}, | 108 {Strings::Translate("Episodes:"), Strings::ToUtf8String(anime.GetEpisodes())}, |
103 {Strings::Translate("Producers:"), "..."}, | 109 {Strings::Translate("Genres:"), Strings::Implode(anime.GetGenres(), ", ")}, |
104 {Strings::Translate("Score:"), Strings::ToUtf8String(anime.GetAudienceScore()) + "%"}, | 110 {Strings::Translate("Producers:"), "..."}, |
105 {Strings::Translate("Popularity:"), "..."}, | 111 {Strings::Translate("Score:"), Strings::ToUtf8String(anime.GetAudienceScore()) + "%"}, |
112 {Strings::Translate("Popularity:"), "..."}, | |
106 }; | 113 }; |
107 | 114 |
108 _info.SetData(imap); | 115 _info.SetData(imap); |
109 | 116 |
110 _synopsis.SetText(anime.GetSynopsis()); | 117 _synopsis.SetText(anime.GetSynopsis()); |
111 } | 118 } |
112 | 119 |
113 bool AnimeButton::hasHeightForWidth() const { | 120 bool AnimeButton::hasHeightForWidth() const |
121 { | |
114 return true; | 122 return true; |
115 } | 123 } |
116 | 124 |
117 int AnimeButton::heightForWidth(int w) const { | 125 int AnimeButton::heightForWidth(int w) const |
126 { | |
118 return static_cast<int>(static_cast<double>(w) / 2.5); | 127 return static_cast<int>(static_cast<double>(w) / 2.5); |
119 } | 128 } |