Mercurial > minori
comparison src/gui/widgets/anime_button.cc @ 273:f31305b9f60a
*: various code safety changes
this also makes the code build on Qt 5.7. I can't test it though
because I don't have it working... FAIL!
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 18 Apr 2024 16:53:17 -0400 |
parents | 862d0d8619f6 |
children | 9a88e1725fd2 |
comparison
equal
deleted
inserted
replaced
272:5437009cb10e | 273:f31305b9f60a |
---|---|
24 *| | Popularity * | 24 *| | Popularity * |
25 *| | * | 25 *| | * |
26 *|_________| Synopsis * | 26 *|_________| Synopsis * |
27 \***********************************/ | 27 \***********************************/ |
28 | 28 |
29 AnimeButton::AnimeButton(QWidget* parent) : QFrame(parent) { | 29 AnimeButton::AnimeButton(QWidget* parent) |
30 : QFrame(parent) | |
31 , _info(tr("Aired:\nEpisodes:\nGenres:\nProducers:\nScore:\nPopularity:"), "\n\n\n\n\n", nullptr) | |
32 , _synopsis("", nullptr) { | |
30 setFrameShadow(QFrame::Plain); | 33 setFrameShadow(QFrame::Plain); |
31 setFrameShape(QFrame::Box); | 34 setFrameShape(QFrame::Box); |
32 QHBoxLayout* ly = new QHBoxLayout(this); | 35 QHBoxLayout* ly = new QHBoxLayout(this); |
33 | 36 |
34 _poster = new Poster(this); | 37 _poster.setFixedSize(120, 170); |
35 _poster->setFixedSize(120, 170); | 38 _poster.SetClickable(false); |
36 _poster->SetClickable(false); | 39 ly->addWidget(&_poster, 0, Qt::AlignTop); |
37 ly->addWidget(_poster, 0, Qt::AlignTop); | |
38 | 40 |
39 { | 41 { |
40 QWidget* misc_section = new QWidget(this); | 42 QWidget* misc_section = new QWidget(this); |
41 misc_section->setFixedSize(354, 180); | 43 misc_section->setFixedSize(354, 180); |
42 | 44 |
43 QVBoxLayout* misc_layout = new QVBoxLayout(misc_section); | 45 QVBoxLayout* misc_layout = new QVBoxLayout(misc_section); |
44 misc_layout->setContentsMargins(0, 0, 0, 0); | 46 misc_layout->setContentsMargins(0, 0, 0, 0); |
45 | 47 |
46 _title = new QLabel("", misc_section); | 48 _title.setAutoFillBackground(true); |
47 _title->setAutoFillBackground(true); | 49 _title.setContentsMargins(4, 4, 4, 4); |
48 _title->setContentsMargins(4, 4, 4, 4); | 50 _title.setStyleSheet("background-color: rgba(0, 245, 25, 50);"); |
49 _title->setStyleSheet("background-color: rgba(0, 245, 25, 50);"); | |
50 { | 51 { |
51 QFont fnt(_title->font()); | 52 QFont fnt(_title.font()); |
52 fnt.setWeight(QFont::Bold); | 53 fnt.setWeight(QFont::Bold); |
53 _title->setFont(fnt); | 54 _title.setFont(fnt); |
54 } | 55 } |
55 misc_layout->addWidget(_title); | 56 misc_layout->addWidget(&_title); |
56 | 57 |
57 _info = new TextWidgets::LabelledParagraph(tr("Aired:\nEpisodes:\nGenres:\nProducers:\nScore:\nPopularity:"), | |
58 "\n\n\n\n\n", misc_section); | |
59 { | 58 { |
60 QFont fnt(_info->GetLabels()->font()); | 59 QFont fnt(_info.GetLabels()->font()); |
61 fnt.setWeight(QFont::Bold); | 60 fnt.setWeight(QFont::Bold); |
62 _info->GetLabels()->setFont(fnt); | 61 _info.GetLabels()->setFont(fnt); |
63 } | 62 } |
64 _info->setContentsMargins(4, 0, 4, 0); | |
65 _info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | |
66 misc_layout->addWidget(_info); | |
67 | 63 |
68 QWidget* dummy = new QWidget(misc_section); | 64 _info.setContentsMargins(4, 0, 4, 0); |
69 dummy->setContentsMargins(4, 0, 4, 0); | 65 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); |
70 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy); | 66 misc_layout->addWidget(&_info); |
71 dummy_layout->setSpacing(0); | |
72 // dummy_layout->setContentsMargins(0, 0, 0, 0); | |
73 dummy_layout->setContentsMargins(0, 0, 0, 0); | |
74 | 67 |
75 _synopsis = new ElidedLabel("", dummy); | 68 { |
76 _synopsis->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | 69 QWidget* dummy = new QWidget(misc_section); |
77 dummy_layout->addWidget(_synopsis); | 70 dummy->setContentsMargins(4, 0, 4, 0); |
78 misc_layout->addWidget(dummy); | 71 QVBoxLayout* dummy_layout = new QVBoxLayout(dummy); |
72 dummy_layout->setSpacing(0); | |
73 dummy_layout->setContentsMargins(0, 0, 0, 0); | |
74 | |
75 _synopsis.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
76 dummy_layout->addWidget(&_synopsis); | |
77 misc_layout->addWidget(dummy); | |
78 } | |
79 | 79 |
80 ly->addWidget(misc_section, 0, Qt::AlignTop); | 80 ly->addWidget(misc_section, 0, Qt::AlignTop); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 AnimeButton::AnimeButton(const Anime::Anime& anime, QWidget* parent) : AnimeButton(parent) { | 84 AnimeButton::AnimeButton(const Anime::Anime& anime, QWidget* parent) : AnimeButton(parent) { |
85 SetAnime(anime); | 85 SetAnime(anime); |
86 } | 86 } |
87 | 87 |
88 void AnimeButton::SetAnime(const Anime::Anime& anime) { | 88 void AnimeButton::SetAnime(const Anime::Anime& anime) { |
89 _poster->SetAnime(anime); | 89 _poster.SetAnime(anime); |
90 _title->setText(Strings::ToQString(anime.GetUserPreferredTitle())); | 90 _title.setText(Strings::ToQString(anime.GetUserPreferredTitle())); |
91 | 91 |
92 { | 92 { |
93 const QLocale& locale = session.config.locale.GetLocale(); | 93 const QLocale& locale = session.config.locale.GetLocale(); |
94 _info->GetParagraph()->SetText(locale.toString(anime.GetAirDate().GetAsQDate(), "dd MMM yyyy") + "\n" + | 94 _info.GetParagraph()->SetText(locale.toString(anime.GetAirDate().GetAsQDate(), "dd MMM yyyy") + "\n" + |
95 QString::number(anime.GetEpisodes()) + "\n" + | 95 QString::number(anime.GetEpisodes()) + "\n" + |
96 Strings::ToQString(Strings::Implode(anime.GetGenres(), ", ")) + "\n" + "...\n" + | 96 Strings::ToQString(Strings::Implode(anime.GetGenres(), ", ")) + "\n" + "...\n" + |
97 QString::number(anime.GetAudienceScore()) + "%\n" + "..."); | 97 QString::number(anime.GetAudienceScore()) + "%\n" + "..."); |
98 } | 98 } |
99 | 99 |
100 { | 100 _synopsis.SetText(Strings::ToQString(anime.GetSynopsis())); |
101 QString synopsis = Strings::ToQString(anime.GetSynopsis()); | |
102 QFontMetrics metrics(_synopsis->font()); | |
103 _synopsis->SetText(Strings::ToQString(anime.GetSynopsis())); | |
104 } | |
105 } | 101 } |