annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/widgets/anime_info.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/anime.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include "core/strings.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include "gui/translate/anime.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include "gui/widgets/text.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QHBoxLayout>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QTextStream>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
9 AnimeInfoWidget::AnimeInfoWidget(QWidget* parent)
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
10 : QWidget(parent)
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
11 , _title(tr("Alternative titles"), "")
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
12 , _details(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), "")
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
13 , _synopsis(tr("Synopsis"), "") {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 QVBoxLayout* layout = new QVBoxLayout(this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
16 layout->addWidget(&_title);
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
17 layout->addWidget(&_details);
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
18 layout->addWidget(&_synopsis);
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
19 }
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
20
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
21 AnimeInfoWidget::AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent) : AnimeInfoWidget(parent) {
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
22 SetAnime(anime);
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
23 }
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 /* alt titles */
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
27 _title.GetLine()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", ")));
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 /* details */
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 QString details_data;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 QTextStream details_data_s(&details_data);
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
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
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
35 * Latin1 (on Windows?) */
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
36 const auto genres = anime.GetGenres();
197
c4ca035c565d *: misc. patches
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
37 details_data_s << Strings::ToQString(Translate::ToLocalString(anime.GetFormat())) << "\n"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 << anime.GetEpisodes() << "\n"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
39 << Strings::ToQString(Translate::ToLocalString(anime.GetAiringStatus())) << "\n"
197
c4ca035c565d *: misc. patches
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
40 << Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) << " "
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
41 << anime.GetAirDate().GetYear().value_or(2000) << "\n"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
42 << Strings::ToQString((genres.size() > 1) ? Strings::Implode(genres, ", ") : "-") << "\n"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 << anime.GetAudienceScore() << "%";
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
44 _details.GetData()->setText(details_data);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
46 _synopsis.GetParagraph()->SetText(Strings::ToQString(anime.GetSynopsis()));
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
47
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
48 updateGeometry();
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 }