Mercurial > minori
comparison src/gui/pages/now_playing.cc @ 154:d43d68408d3c
dep/animia: fix XnuFdTools
also we use anitomy directly now.
HG Enter commit message. Lines beginning with 'HG:' are removed.
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Wed, 15 Nov 2023 14:14:17 -0500 |
| parents | 6d8da6e64d61 |
| children | bc8d2ccff09c |
comparison
equal
deleted
inserted
replaced
| 153:bd439dd6ffc5 | 154:d43d68408d3c |
|---|---|
| 8 #include <QStackedWidget> | 8 #include <QStackedWidget> |
| 9 #include <QHBoxLayout> | 9 #include <QHBoxLayout> |
| 10 #include <QVBoxLayout> | 10 #include <QVBoxLayout> |
| 11 #include <QWidget> | 11 #include <QWidget> |
| 12 | 12 |
| 13 /* WARNING: HACKY STUFF HERE | 13 #include "anitomy/anitomy.h" |
| 14 | 14 |
| 15 The Now Playing page is designed to "switch" between these two sub-pages, | |
| 16 using a QStackedWidget. This *could* be the best way to do this, but this | |
| 17 feels very very stupid and I really don't like it */ | |
| 18 namespace NowPlayingPages { | 15 namespace NowPlayingPages { |
| 19 | 16 |
| 20 class Default : public QWidget { | 17 class Default : public QWidget { |
| 21 Q_OBJECT | 18 Q_OBJECT |
| 22 | 19 |
| 27 class Playing : public QWidget { | 24 class Playing : public QWidget { |
| 28 Q_OBJECT | 25 Q_OBJECT |
| 29 | 26 |
| 30 public: | 27 public: |
| 31 Playing(QWidget* parent = nullptr); | 28 Playing(QWidget* parent = nullptr); |
| 32 void SetPlayingAnime(const Anime::Anime& anime, const std::unordered_map<std::string, std::string>& info); | 29 void SetPlayingAnime(const Anime::Anime& anime, const anitomy::Elements& info); |
| 33 int GetPlayingAnime(); | 30 int GetPlayingAnime(); |
| 34 | 31 |
| 35 private: | 32 private: |
| 36 int _id = 0; | 33 int _id = 0; |
| 37 int _episode = 0; | 34 int _episode = 0; |
| 87 | 84 |
| 88 int Playing::GetPlayingAnime() { | 85 int Playing::GetPlayingAnime() { |
| 89 return _id; | 86 return _id; |
| 90 } | 87 } |
| 91 | 88 |
| 92 void Playing::SetPlayingAnime(const Anime::Anime& anime, const std::unordered_map<std::string, std::string>& info) { | 89 void Playing::SetPlayingAnime(const Anime::Anime& anime, const anitomy::Elements& info) { |
| 93 if (_id == anime.GetId() && std::to_string(_episode) == info.at("episode")) | 90 if (_id == anime.GetId() && _episode == Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber)))) |
| 94 return; | 91 return; |
| 95 _id = anime.GetId(); | 92 _id = anime.GetId(); |
| 96 _episode = Strings::ToInt(info.at("episode")); | 93 _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))); |
| 97 _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle())); | 94 _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle())); |
| 98 _info->SetAnime(anime); | 95 _info->SetAnime(anime); |
| 99 _poster->SetAnime(anime); | 96 _poster->SetAnime(anime); |
| 100 | 97 |
| 101 updateGeometry(); | 98 updateGeometry(); |
| 124 | 121 |
| 125 int NowPlayingPage::GetPlayingId() { | 122 int NowPlayingPage::GetPlayingId() { |
| 126 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); | 123 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); |
| 127 } | 124 } |
| 128 | 125 |
| 129 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const std::unordered_map<std::string, std::string>& info) { | 126 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) { |
| 130 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(anime, info); | 127 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(anime, info); |
| 131 stack->setCurrentIndex(1); | 128 stack->setCurrentIndex(1); |
| 132 updateGeometry(); | 129 updateGeometry(); |
| 133 } | 130 } |
| 134 | 131 |
