Mercurial > minori
annotate 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 |
rev | line source |
---|---|
253 | 1 #include "gui/widgets/anime_button.h" |
2 | |
3 #include "core/anime_db.h" | |
258 | 4 #include "core/session.h" |
253 | 5 #include "core/strings.h" |
6 #include "gui/widgets/elided_label.h" | |
7 #include "gui/widgets/poster.h" | |
258 | 8 #include "gui/widgets/text.h" |
253 | 9 |
258 | 10 #include <QDate> |
11 #include <QHBoxLayout> | |
253 | 12 #include <QVBoxLayout> |
258 | 13 #include <QWidget> |
253 | 14 |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
15 #include <iostream> |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
16 |
253 | 17 /* This widget is only used on the Seasons page. */ |
18 | |
19 /***********************************\ | |
20 *|---------| Title * | |
21 *| | * | |
22 *| | Aired * | |
23 *| | Episodes * | |
24 *| Poster | Producers * | |
25 *| | Score * | |
26 *| | Popularity * | |
27 *| | * | |
28 *|_________| Synopsis * | |
29 \***********************************/ | |
30 | |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
31 AnimeButton::AnimeButton(QWidget* parent) : QFrame(parent) { |
253 | 32 setFrameShadow(QFrame::Plain); |
33 setFrameShape(QFrame::Box); | |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
34 |
253 | 35 QHBoxLayout* ly = new QHBoxLayout(this); |
36 | |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
37 _poster.SetClickable(false); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
38 _poster.setFixedSize(120, 170); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
39 ly->addWidget(&_poster, 0, Qt::AlignTop); |
253 | 40 |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
41 const std::vector<std::pair<std::string, std::string>> imap = { |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
42 {Strings::Translate("Aired:"), ""}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
43 {Strings::Translate("Episodes:"), ""}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
44 {Strings::Translate("Genres:"), ""}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
45 {Strings::Translate("Producers:"), ""}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
46 {Strings::Translate("Score:"), ""}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
47 {Strings::Translate("Popularity:"), ""}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
48 }; |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
49 |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
50 _info.SetData(imap); |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
51 |
253 | 52 { |
53 QWidget* misc_section = new QWidget(this); | |
54 misc_section->setFixedSize(354, 180); | |
55 | |
56 QVBoxLayout* misc_layout = new QVBoxLayout(misc_section); | |
57 misc_layout->setContentsMargins(0, 0, 0, 0); | |
58 | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
59 _title.setAutoFillBackground(true); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
60 _title.setContentsMargins(4, 4, 4, 4); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
61 _title.setStyleSheet("background-color: rgba(0, 245, 25, 50);"); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
62 { |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
63 QFont fnt(_title.font()); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
64 fnt.setWeight(QFont::Bold); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
65 _title.setFont(fnt); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
66 } |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
67 misc_layout->addWidget(&_title); |
253 | 68 |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
69 _info.SetStyle(TextWidgets::LabelledParagraph::Style::BoldedLabels); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
70 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
71 _info.setContentsMargins(4, 0, 4, 0); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
72 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
73 misc_layout->addWidget(&_info); |
253 | 74 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
75 { |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
76 QWidget* dummy = new QWidget(misc_section); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
77 dummy->setContentsMargins(4, 0, 4, 0); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
78 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
79 dummy_layout->setSpacing(0); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
80 dummy_layout->setContentsMargins(0, 0, 0, 0); |
253 | 81 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
82 _synopsis.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
83 _synopsis.SetSelectable(false); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
84 dummy_layout->addWidget(&_synopsis); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
85 misc_layout->addWidget(dummy); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
86 } |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
87 |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
88 ly->addWidget(misc_section, 0, Qt::AlignTop); |
253 | 89 } |
90 } | |
91 | |
92 AnimeButton::AnimeButton(const Anime::Anime& anime, QWidget* parent) : AnimeButton(parent) { | |
93 SetAnime(anime); | |
94 } | |
95 | |
96 void AnimeButton::SetAnime(const Anime::Anime& anime) { | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
97 _poster.SetAnime(anime); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
98 _title.setText(Strings::ToQString(anime.GetUserPreferredTitle())); |
253 | 99 |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
100 const QLocale& locale = session.config.locale.GetLocale(); |
253 | 101 |
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
102 const std::vector<std::pair<std::string, std::string>> imap = { |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
103 {Strings::Translate("Aired:"), Strings::ToUtf8String(locale.toString(anime.GetStartedDate().GetAsQDate(), "dd MMM yyyy"))}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
104 {Strings::Translate("Episodes:"), Strings::ToUtf8String(anime.GetEpisodes())}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
105 {Strings::Translate("Genres:"), Strings::Implode(anime.GetGenres(), ", ")}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
106 {Strings::Translate("Producers:"), "..."}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
107 {Strings::Translate("Score:"), Strings::ToUtf8String(anime.GetAudienceScore()) + "%"}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
108 {Strings::Translate("Popularity:"), "..."}, |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
109 }; |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
110 |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
111 _info.SetData(imap); |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
112 |
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
113 _synopsis.SetText(anime.GetSynopsis()); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
114 } |