Mercurial > minori
annotate src/gui/widgets/anime_button.cc @ 255:fe702c8f161f
*: whatever
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 07 Feb 2024 17:04:06 -0500 |
parents | d14f8e0e40c3 |
children | 862d0d8619f6 |
rev | line source |
---|---|
253 | 1 #include "gui/widgets/anime_button.h" |
2 | |
3 #include "core/anime_db.h" | |
4 #include "core/strings.h" | |
5 #include "core/session.h" | |
6 #include "gui/widgets/text.h" | |
7 #include "gui/widgets/elided_label.h" | |
8 #include "gui/widgets/poster.h" | |
9 | |
10 #include <QWidget> | |
11 #include <QVBoxLayout> | |
12 #include <QHBoxLayout> | |
13 #include <QDate> | |
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 | |
29 AnimeButton::AnimeButton(QWidget* parent) : QFrame(parent) { | |
30 setFrameShadow(QFrame::Plain); | |
31 setFrameShape(QFrame::Box); | |
32 QHBoxLayout* ly = new QHBoxLayout(this); | |
33 | |
34 _poster = new Poster(this); | |
35 _poster->setFixedSize(120, 170); | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
36 _poster->SetClickable(false); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
37 ly->addWidget(_poster, 0, Qt::AlignTop); |
253 | 38 |
39 { | |
40 QWidget* misc_section = new QWidget(this); | |
41 misc_section->setFixedSize(354, 180); | |
42 | |
43 QVBoxLayout* misc_layout = new QVBoxLayout(misc_section); | |
44 misc_layout->setContentsMargins(0, 0, 0, 0); | |
45 | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
46 _title = new QLabel("", misc_section); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
47 _title->setAutoFillBackground(true); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
48 _title->setContentsMargins(4, 4, 4, 4); |
255 | 49 _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
|
50 { |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
51 QFont fnt(_title->font()); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
52 fnt.setWeight(QFont::Bold); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
53 _title->setFont(fnt); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
54 } |
253 | 55 misc_layout->addWidget(_title); |
56 | |
255 | 57 _info = new TextWidgets::LabelledParagraph(tr("Aired:\nEpisodes:\nGenres:\nProducers:\nScore:\nPopularity:"), "\n\n\n\n\n", misc_section); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
58 { |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
59 QFont fnt(_info->GetLabels()->font()); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
60 fnt.setWeight(QFont::Bold); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
61 _info->GetLabels()->setFont(fnt); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
62 } |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
63 _info->setContentsMargins(4, 0, 4, 0); |
253 | 64 _info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); |
65 misc_layout->addWidget(_info); | |
66 | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
67 QWidget* dummy = new QWidget(misc_section); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
68 dummy->setContentsMargins(4, 0, 4, 0); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
69 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
70 dummy_layout->setSpacing(0); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
71 // dummy_layout->setContentsMargins(0, 0, 0, 0); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
72 dummy_layout->setContentsMargins(0, 0, 0, 0); |
253 | 73 |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
74 _synopsis = new ElidedLabel("", dummy); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
75 _synopsis->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
76 dummy_layout->addWidget(_synopsis); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
77 misc_layout->addWidget(dummy); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
78 |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
79 ly->addWidget(misc_section, 0, Qt::AlignTop); |
253 | 80 } |
81 } | |
82 | |
83 AnimeButton::AnimeButton(const Anime::Anime& anime, QWidget* parent) : AnimeButton(parent) { | |
84 SetAnime(anime); | |
85 } | |
86 | |
87 void AnimeButton::SetAnime(const Anime::Anime& anime) { | |
88 _poster->SetAnime(anime); | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
89 _title->setText(Strings::ToQString(anime.GetUserPreferredTitle())); |
253 | 90 |
91 { | |
92 const QLocale& locale = session.config.locale.GetLocale(); | |
93 _info->GetParagraph()->SetText( | |
94 locale.toString(anime.GetAirDate().GetAsQDate(), "dd MMM yyyy") + "\n" + | |
95 QString::number(anime.GetEpisodes()) + "\n" + | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
96 Strings::ToQString(Strings::Implode(anime.GetGenres(), ", ")) + "\n" + |
253 | 97 "...\n" + |
98 QString::number(anime.GetAudienceScore()) + "%\n" + | |
99 "..." | |
100 ); | |
101 } | |
102 | |
103 { | |
104 QString synopsis = Strings::ToQString(anime.GetSynopsis()); | |
105 QFontMetrics metrics(_synopsis->font()); | |
106 _synopsis->SetText(Strings::ToQString(anime.GetSynopsis())); | |
107 } | |
108 } |