Mercurial > minori
diff src/gui/widgets/anime_info.cc @ 348:6b0768158dcd
text: redesign almost every widget
i.e. Paragraph is now a QLabel, etc etc, some things will probably
break, idc
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Tue, 25 Jun 2024 11:19:54 -0400 |
parents | b5d6c27c308f |
children |
line wrap: on
line diff
--- a/src/gui/widgets/anime_info.cc Sun Jun 23 10:32:09 2024 -0400 +++ b/src/gui/widgets/anime_info.cc Tue Jun 25 11:19:54 2024 -0400 @@ -36,17 +36,33 @@ /* all widgets share this thread */ static AnimeInfoWidgetGetMetadataThread get_metadata_thread; -AnimeInfoWidget::AnimeInfoWidget(QWidget* parent) - : QWidget(parent) - , _title(tr("Alternative titles"), "") - , _details(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nProducers:\nScore:"), "") - , _synopsis(tr("Synopsis"), "") { +AnimeInfoWidget::AnimeInfoWidget(QWidget* parent) : QWidget(parent) { QVBoxLayout* layout = new QVBoxLayout(this); + _title.GetHeader().SetText(Strings::Translate("Alternative titles")); layout->addWidget(&_title); + + _details.GetHeader().SetText(Strings::Translate("Details")); + + const std::vector<std::pair<std::string, std::string>> items = { + {Strings::Translate("Type:"), ""}, + {Strings::Translate("Episodes:"), ""}, + {Strings::Translate("Status:"), ""}, + {Strings::Translate("Season:"), ""}, + {Strings::Translate("Genres:"), ""}, + {Strings::Translate("Producers:"), ""}, + {Strings::Translate("Score:"), ""}, + }; + + _details.GetContent().SetData(items); + layout->addWidget(&_details); + + _synopsis.GetHeader().SetText(Strings::Translate("Synopsis")); layout->addWidget(&_synopsis); + layout->addStretch(); + /* ... */ connect(&get_metadata_thread, &AnimeInfoWidgetGetMetadataThread::NeedRefresh, this, [this](int id) { setUpdatesEnabled(false); @@ -72,11 +88,11 @@ get_metadata_thread.start(); /* alt titles */ - _title.GetLine()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); + _title.GetContent().SetText(Strings::Implode(anime.GetTitleSynonyms(), ", ")); RefreshGenres(anime); - _synopsis.GetParagraph()->SetText(Strings::ToQString(anime.GetSynopsis())); + _synopsis.GetContent().SetText(anime.GetSynopsis()); setUpdatesEnabled(true); @@ -84,23 +100,21 @@ } void AnimeInfoWidget::RefreshGenres(const Anime::Anime& anime) { - /* details */ - QString details_data; - QTextStream details_data_s(&details_data); - /* we have to convert ALL of these strings to * QString because QTextStream sucks and assumes * Latin-1 (on Windows?) */ const auto genres = anime.GetGenres(); const auto producers = anime.GetProducers(); - details_data_s << Strings::ToQString(Translate::ToLocalString(anime.GetFormat())) << "\n" - << anime.GetEpisodes() << "\n" - << Strings::ToQString(Translate::ToLocalString(anime.GetAiringStatus())) << "\n" - << Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) << "\n" - << Strings::ToQString((genres.size() > 1) ? Strings::Implode(genres, ", ") : "-") << "\n" - << Strings::ToQString((producers.size() > 1) ? Strings::Implode(producers, ", ") : "-") << "\n" - << anime.GetAudienceScore() << "%"; + const std::vector<std::pair<std::string, std::string>> items = { + {Strings::Translate("Type:"), Translate::ToLocalString(anime.GetFormat())}, + {Strings::Translate("Episodes:"), Strings::ToUtf8String(anime.GetEpisodes())}, + {Strings::Translate("Status:"), Translate::ToLocalString(anime.GetAiringStatus())}, + {Strings::Translate("Season:"), Translate::ToLocalString(anime.GetSeason())}, + {Strings::Translate("Genres:"), (genres.size() > 1) ? Strings::Implode(genres, ", ") : "-"}, + {Strings::Translate("Producers:"), (producers.size() > 1) ? Strings::Implode(producers, ", ") : "-"}, + {Strings::Translate("Score:"), Strings::ToUtf8String(anime.GetAudienceScore()) + "%"}, + }; - _details.GetData()->setText(details_data); + _details.GetContent().SetData(items); }