Mercurial > minori
comparison src/gui/pages/now_playing.cpp @ 79:c489dd4434af
*: what did I do again?
I really forgot what I did here :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 12 Oct 2023 11:31:39 -0400 |
parents | 27a19dd6cba1 |
children | 825506f0e221 |
comparison
equal
deleted
inserted
replaced
78:1ce00c1c8ddc | 79:c489dd4434af |
---|---|
19 class Playing : public QWidget { | 19 class Playing : public QWidget { |
20 Q_OBJECT | 20 Q_OBJECT |
21 | 21 |
22 public: | 22 public: |
23 Playing(QWidget* parent = nullptr); | 23 Playing(QWidget* parent = nullptr); |
24 void SetPlayingAnime(int id); | 24 void SetPlayingAnime(int id, int episode); |
25 int GetPlayingAnime(); | 25 int GetPlayingAnime(); |
26 | 26 |
27 private: | 27 private: |
28 int _id = 0; | 28 int _id = 0; |
29 int _episode = 0; | |
29 std::unique_ptr<AnimeInfoWidget> info = nullptr; | 30 std::unique_ptr<AnimeInfoWidget> info = nullptr; |
30 }; | 31 }; |
31 | 32 |
32 Default::Default(QWidget* parent) : QWidget(parent) { | 33 Default::Default(QWidget* parent) : QWidget(parent) { |
33 QVBoxLayout* layout = new QVBoxLayout(this); | 34 QVBoxLayout* layout = new QVBoxLayout(this); |
44 | 45 |
45 int Playing::GetPlayingAnime() { | 46 int Playing::GetPlayingAnime() { |
46 return _id; | 47 return _id; |
47 } | 48 } |
48 | 49 |
49 void Playing::SetPlayingAnime(int id) { | 50 void Playing::SetPlayingAnime(int id, int episodes) { |
51 if (id == _id) | |
52 return; | |
50 if (info.get()) | 53 if (info.get()) |
51 layout()->removeWidget(info.get()); | 54 layout()->removeWidget(info.get()); |
52 if (Anime::db.items.find(id) != Anime::db.items.end()) { | 55 if (Anime::db.items.find(id) != Anime::db.items.end()) { |
53 info.reset(new AnimeInfoWidget(Anime::db.items[_id = id])); | 56 info.reset(new AnimeInfoWidget(Anime::db.items[_id = id])); |
54 layout()->addWidget(info.get()); | 57 layout()->addWidget(info.get()); |
85 | 88 |
86 int NowPlayingPage::GetPlayingId() { | 89 int NowPlayingPage::GetPlayingId() { |
87 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); | 90 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); |
88 } | 91 } |
89 | 92 |
90 void NowPlayingPage::SetPlaying(int id) { | 93 void NowPlayingPage::SetPlaying(int id, int episodes) { |
91 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(id); | 94 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(id, episodes); |
92 stack->setCurrentIndex(1); | 95 stack->setCurrentIndex(1); |
93 } | 96 } |
94 | 97 |
95 #include "gui/pages/moc_now_playing.cpp" | 98 #include "gui/pages/moc_now_playing.cpp" |
96 #include "now_playing.moc" | 99 #include "now_playing.moc" |