Mercurial > minori
annotate src/gui/widgets/anime_info.cc @ 295:b82841e76e79
*: better support on Windows
things now look much better in dark mode
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 12 May 2024 20:24:09 -0400 |
parents | 9a88e1725fd2 |
children | b1f625b0227c |
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 | |
291 | 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"), "") { | |
64 | 14 QVBoxLayout* layout = new QVBoxLayout(this); |
15 | |
291 | 16 layout->addWidget(&_title); |
17 layout->addWidget(&_details); | |
18 layout->addWidget(&_synopsis); | |
80 | 19 } |
20 | |
21 AnimeInfoWidget::AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent) : AnimeInfoWidget(parent) { | |
22 SetAnime(anime); | |
23 } | |
24 | |
82
8b65c417c225
*: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
25 void AnimeInfoWidget::SetAnime(const Anime::Anime& anime) { |
64 | 26 /* alt titles */ |
291 | 27 _title.GetLine()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); |
64 | 28 |
29 /* details */ | |
30 QString details_data; | |
31 QTextStream details_data_s(&details_data); | |
291 | 32 |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
33 /* we have to convert ALL of these strings to |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
34 * QString because QTextStream sucks and assumes |
291 | 35 * Latin1 (on Windows?) */ |
250 | 36 const auto genres = anime.GetGenres(); |
197 | 37 details_data_s << Strings::ToQString(Translate::ToLocalString(anime.GetFormat())) << "\n" |
64 | 38 << anime.GetEpisodes() << "\n" |
250 | 39 << Strings::ToQString(Translate::ToLocalString(anime.GetAiringStatus())) << "\n" |
197 | 40 << Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) << " " |
258 | 41 << anime.GetAirDate().GetYear().value_or(2000) << "\n" |
250 | 42 << Strings::ToQString((genres.size() > 1) ? Strings::Implode(genres, ", ") : "-") << "\n" |
64 | 43 << anime.GetAudienceScore() << "%"; |
291 | 44 _details.GetData()->setText(details_data); |
64 | 45 |
291 | 46 _synopsis.GetParagraph()->SetText(Strings::ToQString(anime.GetSynopsis())); |
83 | 47 |
48 updateGeometry(); | |
64 | 49 } |