comparison src/gui/widgets/anime_button.cc @ 253:b3549da699a6

*: ooooh! stupid big commit! oops
author Paper <paper@paper.us.eu.org>
date Tue, 06 Feb 2024 16:56:32 -0500
parents
children d14f8e0e40c3
comparison
equal deleted inserted replaced
252:a0eeb2cc7e6d 253:b3549da699a6
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);
36 ly->addWidget(_poster);
37
38 {
39 QWidget* misc_section = new QWidget(this);
40 misc_section->setFixedSize(354, 180);
41
42 QVBoxLayout* misc_layout = new QVBoxLayout(misc_section);
43 misc_layout->setContentsMargins(0, 0, 0, 0);
44
45 _title = new TextWidgets::Line("", misc_section);
46 misc_layout->addWidget(_title);
47
48 /* need to make a separate "labelled paragraph" for this */
49 _info = new TextWidgets::LabelledParagraph(tr("Aired:\nEpisodes:\nProducers:\nScore:\nPopularity:"), "\n\n\n\n", misc_section);
50 _info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
51 misc_layout->addWidget(_info);
52
53 _synopsis = new ElidedLabel("", misc_section);
54 misc_layout->addWidget(_synopsis);
55
56 ly->addWidget(misc_section);
57 }
58 }
59
60 AnimeButton::AnimeButton(const Anime::Anime& anime, QWidget* parent) : AnimeButton(parent) {
61 SetAnime(anime);
62 }
63
64 void AnimeButton::SetAnime(const Anime::Anime& anime) {
65 _poster->SetAnime(anime);
66 _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle()));
67
68 {
69 const QLocale& locale = session.config.locale.GetLocale();
70 _info->GetParagraph()->SetText(
71 locale.toString(anime.GetAirDate().GetAsQDate(), "dd MMM yyyy") + "\n" +
72 QString::number(anime.GetEpisodes()) + "\n" +
73 "...\n" +
74 QString::number(anime.GetAudienceScore()) + "%\n" +
75 "..."
76 );
77 }
78
79 {
80 QString synopsis = Strings::ToQString(anime.GetSynopsis());
81 QFontMetrics metrics(_synopsis->font());
82 _synopsis->SetText(Strings::ToQString(anime.GetSynopsis()));
83 }
84 }