Mercurial > minori
comparison src/gui/widgets/anime_info.cc @ 291:9a88e1725fd2
*: refactor lots of stuff
I forgot to put this into different commits, oops!
anyway, it doesn't really matter *that* much since this is an
unfinished hobby project anyway. once it starts getting stable
commit history will be more important, but for now it's not
that big of a deal
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 12 May 2024 16:31:07 -0400 |
parents | 862d0d8619f6 |
children | b1f625b0227c |
comparison
equal
deleted
inserted
replaced
290:9347e2eaf6e5 | 291:9a88e1725fd2 |
---|---|
4 #include "gui/translate/anime.h" | 4 #include "gui/translate/anime.h" |
5 #include "gui/widgets/text.h" | 5 #include "gui/widgets/text.h" |
6 #include <QHBoxLayout> | 6 #include <QHBoxLayout> |
7 #include <QTextStream> | 7 #include <QTextStream> |
8 | 8 |
9 AnimeInfoWidget::AnimeInfoWidget(QWidget* parent) : QWidget(parent) { | 9 AnimeInfoWidget::AnimeInfoWidget(QWidget* parent) |
10 : QWidget(parent) | |
11 , _title(tr("Alternative titles"), "") | |
12 , _details(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), "") | |
13 , _synopsis(tr("Synopsis"), "") { | |
10 QVBoxLayout* layout = new QVBoxLayout(this); | 14 QVBoxLayout* layout = new QVBoxLayout(this); |
11 | 15 |
12 _title.reset(new TextWidgets::OneLineSection(tr("Alternative titles"), "", this)); | 16 layout->addWidget(&_title); |
13 layout->addWidget(_title.get()); | 17 layout->addWidget(&_details); |
14 | 18 layout->addWidget(&_synopsis); |
15 _details.reset(new TextWidgets::LabelledSection( | |
16 tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), "", this)); | |
17 layout->addWidget(_details.get()); | |
18 | |
19 _synopsis.reset(new TextWidgets::SelectableSection(tr("Synopsis"), "", this)); | |
20 _synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | |
21 layout->addWidget(_synopsis.get()); | |
22 | |
23 layout->addStretch(); | |
24 } | 19 } |
25 | 20 |
26 AnimeInfoWidget::AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent) : AnimeInfoWidget(parent) { | 21 AnimeInfoWidget::AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent) : AnimeInfoWidget(parent) { |
27 SetAnime(anime); | 22 SetAnime(anime); |
28 } | 23 } |
29 | 24 |
30 void AnimeInfoWidget::SetAnime(const Anime::Anime& anime) { | 25 void AnimeInfoWidget::SetAnime(const Anime::Anime& anime) { |
31 /* alt titles */ | 26 /* alt titles */ |
32 _title->GetLine()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); | 27 _title.GetLine()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); |
33 | 28 |
34 /* details */ | 29 /* details */ |
35 QString details_data; | 30 QString details_data; |
36 QTextStream details_data_s(&details_data); | 31 QTextStream details_data_s(&details_data); |
32 | |
37 /* we have to convert ALL of these strings to | 33 /* we have to convert ALL of these strings to |
38 * QString because QTextStream sucks and assumes | 34 * QString because QTextStream sucks and assumes |
39 * Latin1 (on Windows?) | 35 * Latin1 (on Windows?) */ |
40 */ | |
41 const auto genres = anime.GetGenres(); | 36 const auto genres = anime.GetGenres(); |
42 details_data_s << Strings::ToQString(Translate::ToLocalString(anime.GetFormat())) << "\n" | 37 details_data_s << Strings::ToQString(Translate::ToLocalString(anime.GetFormat())) << "\n" |
43 << anime.GetEpisodes() << "\n" | 38 << anime.GetEpisodes() << "\n" |
44 << Strings::ToQString(Translate::ToLocalString(anime.GetAiringStatus())) << "\n" | 39 << Strings::ToQString(Translate::ToLocalString(anime.GetAiringStatus())) << "\n" |
45 << Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) << " " | 40 << Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) << " " |
46 << anime.GetAirDate().GetYear().value_or(2000) << "\n" | 41 << anime.GetAirDate().GetYear().value_or(2000) << "\n" |
47 << Strings::ToQString((genres.size() > 1) ? Strings::Implode(genres, ", ") : "-") << "\n" | 42 << Strings::ToQString((genres.size() > 1) ? Strings::Implode(genres, ", ") : "-") << "\n" |
48 << anime.GetAudienceScore() << "%"; | 43 << anime.GetAudienceScore() << "%"; |
49 _details->GetParagraph()->SetText(details_data); | 44 _details.GetData()->setText(details_data); |
50 | 45 |
51 _synopsis->GetParagraph()->SetText(Strings::ToQString(anime.GetSynopsis())); | 46 _synopsis.GetParagraph()->SetText(Strings::ToQString(anime.GetSynopsis())); |
52 | 47 |
53 updateGeometry(); | 48 updateGeometry(); |
54 } | 49 } |