Mercurial > minori
annotate src/gui/widgets/anime_info.cc @ 288:8b9db17d1e5f
autoconf: don't need Qt5Svg
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 08 May 2024 16:47:25 -0400 |
parents | 862d0d8619f6 |
children | 9a88e1725fd2 |
rev | line source |
---|---|
64 | 1 #include "gui/widgets/anime_info.h" |
2 #include "core/anime.h" | |
3 #include "core/strings.h" | |
4 #include "gui/translate/anime.h" | |
5 #include "gui/widgets/text.h" | |
6 #include <QHBoxLayout> | |
7 #include <QTextStream> | |
8 | |
80 | 9 AnimeInfoWidget::AnimeInfoWidget(QWidget* parent) : QWidget(parent) { |
64 | 10 QVBoxLayout* layout = new QVBoxLayout(this); |
11 | |
80 | 12 _title.reset(new TextWidgets::OneLineSection(tr("Alternative titles"), "", this)); |
13 layout->addWidget(_title.get()); | |
14 | |
258 | 15 _details.reset(new TextWidgets::LabelledSection( |
16 tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), "", this)); | |
80 | 17 layout->addWidget(_details.get()); |
18 | |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
19 _synopsis.reset(new TextWidgets::SelectableSection(tr("Synopsis"), "", this)); |
253 | 20 _synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); |
80 | 21 layout->addWidget(_synopsis.get()); |
253 | 22 |
23 layout->addStretch(); | |
80 | 24 } |
25 | |
26 AnimeInfoWidget::AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent) : AnimeInfoWidget(parent) { | |
27 SetAnime(anime); | |
28 } | |
29 | |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
30 void AnimeInfoWidget::SetAnime(const Anime::Anime& anime) { |
64 | 31 /* alt titles */ |
83 | 32 _title->GetLine()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); |
64 | 33 |
34 /* details */ | |
35 QString details_data; | |
36 QTextStream details_data_s(&details_data); | |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
37 /* we have to convert ALL of these strings to |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
38 * QString because QTextStream sucks and assumes |
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
39 * Latin1 (on Windows?) |
258 | 40 */ |
250 | 41 const auto genres = anime.GetGenres(); |
197 | 42 details_data_s << Strings::ToQString(Translate::ToLocalString(anime.GetFormat())) << "\n" |
64 | 43 << anime.GetEpisodes() << "\n" |
250 | 44 << Strings::ToQString(Translate::ToLocalString(anime.GetAiringStatus())) << "\n" |
197 | 45 << Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) << " " |
258 | 46 << anime.GetAirDate().GetYear().value_or(2000) << "\n" |
250 | 47 << Strings::ToQString((genres.size() > 1) ? Strings::Implode(genres, ", ") : "-") << "\n" |
64 | 48 << anime.GetAudienceScore() << "%"; |
83 | 49 _details->GetParagraph()->SetText(details_data); |
64 | 50 |
83 | 51 _synopsis->GetParagraph()->SetText(Strings::ToQString(anime.GetSynopsis())); |
52 | |
53 updateGeometry(); | |
64 | 54 } |