comparison 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
comparison
equal deleted inserted replaced
347:a0aa8c8c4307 348:6b0768158dcd
34 } 34 }
35 35
36 /* all widgets share this thread */ 36 /* all widgets share this thread */
37 static AnimeInfoWidgetGetMetadataThread get_metadata_thread; 37 static AnimeInfoWidgetGetMetadataThread get_metadata_thread;
38 38
39 AnimeInfoWidget::AnimeInfoWidget(QWidget* parent) 39 AnimeInfoWidget::AnimeInfoWidget(QWidget* parent) : QWidget(parent) {
40 : QWidget(parent)
41 , _title(tr("Alternative titles"), "")
42 , _details(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nProducers:\nScore:"), "")
43 , _synopsis(tr("Synopsis"), "") {
44 QVBoxLayout* layout = new QVBoxLayout(this); 40 QVBoxLayout* layout = new QVBoxLayout(this);
45 41
42 _title.GetHeader().SetText(Strings::Translate("Alternative titles"));
46 layout->addWidget(&_title); 43 layout->addWidget(&_title);
44
45 _details.GetHeader().SetText(Strings::Translate("Details"));
46
47 const std::vector<std::pair<std::string, std::string>> items = {
48 {Strings::Translate("Type:"), ""},
49 {Strings::Translate("Episodes:"), ""},
50 {Strings::Translate("Status:"), ""},
51 {Strings::Translate("Season:"), ""},
52 {Strings::Translate("Genres:"), ""},
53 {Strings::Translate("Producers:"), ""},
54 {Strings::Translate("Score:"), ""},
55 };
56
57 _details.GetContent().SetData(items);
58
47 layout->addWidget(&_details); 59 layout->addWidget(&_details);
60
61 _synopsis.GetHeader().SetText(Strings::Translate("Synopsis"));
48 layout->addWidget(&_synopsis); 62 layout->addWidget(&_synopsis);
63
64 layout->addStretch();
49 65
50 /* ... */ 66 /* ... */
51 connect(&get_metadata_thread, &AnimeInfoWidgetGetMetadataThread::NeedRefresh, this, [this](int id) { 67 connect(&get_metadata_thread, &AnimeInfoWidgetGetMetadataThread::NeedRefresh, this, [this](int id) {
52 setUpdatesEnabled(false); 68 setUpdatesEnabled(false);
53 69
70 get_metadata_thread.AddToQueue(id_); 86 get_metadata_thread.AddToQueue(id_);
71 if (!get_metadata_thread.isRunning()) 87 if (!get_metadata_thread.isRunning())
72 get_metadata_thread.start(); 88 get_metadata_thread.start();
73 89
74 /* alt titles */ 90 /* alt titles */
75 _title.GetLine()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); 91 _title.GetContent().SetText(Strings::Implode(anime.GetTitleSynonyms(), ", "));
76 92
77 RefreshGenres(anime); 93 RefreshGenres(anime);
78 94
79 _synopsis.GetParagraph()->SetText(Strings::ToQString(anime.GetSynopsis())); 95 _synopsis.GetContent().SetText(anime.GetSynopsis());
80 96
81 setUpdatesEnabled(true); 97 setUpdatesEnabled(true);
82 98
83 updateGeometry(); 99 updateGeometry();
84 } 100 }
85 101
86 void AnimeInfoWidget::RefreshGenres(const Anime::Anime& anime) { 102 void AnimeInfoWidget::RefreshGenres(const Anime::Anime& anime) {
87 /* details */
88 QString details_data;
89 QTextStream details_data_s(&details_data);
90
91 /* we have to convert ALL of these strings to 103 /* we have to convert ALL of these strings to
92 * QString because QTextStream sucks and assumes 104 * QString because QTextStream sucks and assumes
93 * Latin-1 (on Windows?) */ 105 * Latin-1 (on Windows?) */
94 const auto genres = anime.GetGenres(); 106 const auto genres = anime.GetGenres();
95 const auto producers = anime.GetProducers(); 107 const auto producers = anime.GetProducers();
96 108
97 details_data_s << Strings::ToQString(Translate::ToLocalString(anime.GetFormat())) << "\n" 109 const std::vector<std::pair<std::string, std::string>> items = {
98 << anime.GetEpisodes() << "\n" 110 {Strings::Translate("Type:"), Translate::ToLocalString(anime.GetFormat())},
99 << Strings::ToQString(Translate::ToLocalString(anime.GetAiringStatus())) << "\n" 111 {Strings::Translate("Episodes:"), Strings::ToUtf8String(anime.GetEpisodes())},
100 << Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) << "\n" 112 {Strings::Translate("Status:"), Translate::ToLocalString(anime.GetAiringStatus())},
101 << Strings::ToQString((genres.size() > 1) ? Strings::Implode(genres, ", ") : "-") << "\n" 113 {Strings::Translate("Season:"), Translate::ToLocalString(anime.GetSeason())},
102 << Strings::ToQString((producers.size() > 1) ? Strings::Implode(producers, ", ") : "-") << "\n" 114 {Strings::Translate("Genres:"), (genres.size() > 1) ? Strings::Implode(genres, ", ") : "-"},
103 << anime.GetAudienceScore() << "%"; 115 {Strings::Translate("Producers:"), (producers.size() > 1) ? Strings::Implode(producers, ", ") : "-"},
116 {Strings::Translate("Score:"), Strings::ToUtf8String(anime.GetAudienceScore()) + "%"},
117 };
104 118
105 _details.GetData()->setText(details_data); 119 _details.GetContent().SetData(items);
106 } 120 }