Mercurial > minori
annotate src/gui/widgets/anime_button.cc @ 337:a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
1: animone now has its own syntax divergent from anisthesia,
making different platforms actually have their own sections
2: process names in animone are now called `comm' (this will
probably break things). this is what its called in bsd/linux
so I'm just going to use it everywhere
3: the X11 code now checks for the existence of a UTF-8 window title
and passes it if available
4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK!
I still actually need to test the bsd code. to be honest I'm probably
going to move all of the bsds into separate files because they're
all essentially different operating systems at this point
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 19 Jun 2024 12:51:15 -0400 |
parents | 5d3c9b31aa6e |
children | 6b0768158dcd |
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 |
15 /* This widget is only used on the Seasons page. */ | |
16 | |
17 /***********************************\ | |
18 *|---------| Title * | |
19 *| | * | |
20 *| | Aired * | |
21 *| | Episodes * | |
22 *| Poster | Producers * | |
23 *| | Score * | |
24 *| | Popularity * | |
25 *| | * | |
26 *|_________| Synopsis * | |
27 \***********************************/ | |
28 | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
29 AnimeButton::AnimeButton(QWidget* parent) |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
30 : QFrame(parent) |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
31 , _info(tr("Aired:\nEpisodes:\nGenres:\nProducers:\nScore:\nPopularity:"), "\n\n\n\n\n", nullptr) |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
32 , _synopsis("", nullptr) { |
253 | 33 setFrameShadow(QFrame::Plain); |
34 setFrameShape(QFrame::Box); | |
35 QHBoxLayout* ly = new QHBoxLayout(this); | |
36 | |
295 | 37 /* XXX does Qt have a "fixed ratio"? */ |
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 _poster.SetClickable(false); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
40 ly->addWidget(&_poster, 0, Qt::AlignTop); |
253 | 41 |
42 { | |
43 QWidget* misc_section = new QWidget(this); | |
44 misc_section->setFixedSize(354, 180); | |
45 | |
46 QVBoxLayout* misc_layout = new QVBoxLayout(misc_section); | |
47 misc_layout->setContentsMargins(0, 0, 0, 0); | |
48 | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
49 _title.setAutoFillBackground(true); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
50 _title.setContentsMargins(4, 4, 4, 4); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
51 _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
|
52 { |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
53 QFont fnt(_title.font()); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
54 fnt.setWeight(QFont::Bold); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
55 _title.setFont(fnt); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
56 } |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
57 misc_layout->addWidget(&_title); |
253 | 58 |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
59 { |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
60 QFont fnt(_info.GetLabels()->font()); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
61 fnt.setWeight(QFont::Bold); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
62 _info.GetLabels()->setFont(fnt); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
63 } |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
64 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
65 _info.setContentsMargins(4, 0, 4, 0); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
66 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
67 misc_layout->addWidget(&_info); |
253 | 68 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
69 { |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
70 QWidget* dummy = new QWidget(misc_section); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
71 dummy->setContentsMargins(4, 0, 4, 0); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
72 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
73 dummy_layout->setSpacing(0); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
74 dummy_layout->setContentsMargins(0, 0, 0, 0); |
253 | 75 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
76 _synopsis.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
77 dummy_layout->addWidget(&_synopsis); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
78 misc_layout->addWidget(dummy); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
79 } |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
80 |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
81 ly->addWidget(misc_section, 0, Qt::AlignTop); |
253 | 82 } |
83 } | |
84 | |
85 AnimeButton::AnimeButton(const Anime::Anime& anime, QWidget* parent) : AnimeButton(parent) { | |
86 SetAnime(anime); | |
87 } | |
88 | |
89 void AnimeButton::SetAnime(const Anime::Anime& anime) { | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
90 _poster.SetAnime(anime); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
91 _title.setText(Strings::ToQString(anime.GetUserPreferredTitle())); |
253 | 92 |
93 { | |
94 const QLocale& locale = session.config.locale.GetLocale(); | |
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
95 _info.GetData()->setText(locale.toString(anime.GetStartedDate().GetAsQDate(), "dd MMM yyyy") + "\n" + |
291 | 96 QString::number(anime.GetEpisodes()) + "\n" + |
97 Strings::ToQString(Strings::Implode(anime.GetGenres(), ", ")) + "\n" + "...\n" + | |
98 QString::number(anime.GetAudienceScore()) + "%\n" + "..."); | |
253 | 99 } |
100 | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
101 _synopsis.SetText(Strings::ToQString(anime.GetSynopsis())); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
102 } |