annotate src/gui/widgets/anime_info.cpp @ 75:d3e9310598b1

*: refactor some stuff text: "TextParagraph"s are now called sections, because that's the actual word for it :P text: new classes: Line and OneLineSection, solves many problems with paragraphs that are only one line long (ex. going out of bounds) http: reworked http stuff to allow threaded get requests, also moved it to its own file to (hopefully) remove clutter eventually I'll make a threaded post request method and use that in the "basic" function
author Paper <mrpapersonic@gmail.com>
date Wed, 04 Oct 2023 01:42:30 -0400
parents fe719c109dbc
children 825506f0e221
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 AnimeInfoWidget::AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent) : QWidget(parent) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 QVBoxLayout* layout = new QVBoxLayout(this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 /* alt titles */
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
13 TextWidgets::OneLineSection* title = new TextWidgets::OneLineSection(
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
14 tr("Alternative titles"), Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", ").c_str()), this);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 layout->addWidget(title);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 /* details */
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 QString details_data;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 QTextStream details_data_s(&details_data);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 details_data_s << Translate::ToString(anime.GetFormat()).c_str() << "\n"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 << anime.GetEpisodes() << "\n"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 << Translate::ToString(anime.GetUserStatus()).c_str() << "\n"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear() << "\n"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 << anime.GetAudienceScore() << "%";
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
26 layout->addWidget(new TextWidgets::LabelledSection(
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), details_data, this));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 /* synopsis */
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
30 TextWidgets::SelectableSection* synopsis =
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
31 new TextWidgets::SelectableSection(tr("Synopsis"), QString::fromUtf8(anime.GetSynopsis().c_str()), this);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33 synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 layout->addWidget(synopsis);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 #include "gui/widgets/moc_anime_info.cpp"