diff src/gui/pages/now_playing.cpp @ 69:27a19dd6cba1

*: fix up some stuff settings: due to my own incompetence OnOK caused the entire program to crash, now that's fixed :)
author Paper <mrpapersonic@gmail.com>
date Tue, 03 Oct 2023 03:38:25 -0400
parents 2417121d894e
children c489dd4434af
line wrap: on
line diff
--- a/src/gui/pages/now_playing.cpp	Mon Oct 02 21:33:25 2023 -0400
+++ b/src/gui/pages/now_playing.cpp	Tue Oct 03 03:38:25 2023 -0400
@@ -22,8 +22,10 @@
 	public:
 		Playing(QWidget* parent = nullptr);
 		void SetPlayingAnime(int id);
+		int GetPlayingAnime();
 
 	private:
+		int _id = 0;
 		std::unique_ptr<AnimeInfoWidget> info = nullptr;
 };
 
@@ -40,11 +42,17 @@
 	layout->setContentsMargins(0, 0, 0, 0);
 }
 
+int Playing::GetPlayingAnime() {
+	return _id;
+}
+
 void Playing::SetPlayingAnime(int id) {
 	if (info.get())
 		layout()->removeWidget(info.get());
-	info.reset(new AnimeInfoWidget(Anime::db.items[id]));
-	layout()->addWidget(info.get());
+	if (Anime::db.items.find(id) != Anime::db.items.end()) {
+		info.reset(new AnimeInfoWidget(Anime::db.items[_id = id]));
+		layout()->addWidget(info.get());
+	}
 }
 
 } // namespace NowPlayingPages
@@ -75,6 +83,10 @@
 	stack->setCurrentIndex(0);
 }
 
+int NowPlayingPage::GetPlayingId() {
+	return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime();
+}
+
 void NowPlayingPage::SetPlaying(int id) {
 	reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(id);
 	stack->setCurrentIndex(1);