diff include/gui/window.h @ 273:f31305b9f60a

*: various code safety changes this also makes the code build on Qt 5.7. I can't test it though because I don't have it working... FAIL!
author Paper <paper@paper.us.eu.org>
date Thu, 18 Apr 2024 16:53:17 -0400
parents 3ec7804abf17
children 9a88e1725fd2
line wrap: on
line diff
--- a/include/gui/window.h	Thu Apr 18 16:51:35 2024 -0400
+++ b/include/gui/window.h	Thu Apr 18 16:53:17 2024 -0400
@@ -11,25 +11,43 @@
 #include <QCloseEvent>
 #include <QStackedWidget>
 #include <QThread>
+#include <QTimer>
 #include <QWidget>
 
 class QMenu;
+class AnimeListPage;
 
 Q_DECLARE_METATYPE(std::vector<std::string>);
 
-class PlayingThread : public QThread {
+class MainWindowPlayingThread final : public QThread {
 	Q_OBJECT
 
 public:
-	PlayingThread(QObject* object = nullptr) : QThread(object) {}
+	MainWindowPlayingThread(QObject* object = nullptr) : QThread(object) {}
 
-private:
+protected:
 	void run() override;
 
 signals:
 	void Done(const std::vector<std::string>& files);
 };
 
+class MainWindowAsyncSynchronizeThread final : public QThread {
+	Q_OBJECT
+
+public:
+	MainWindowAsyncSynchronizeThread(QAction* action, AnimeListPage* page, QObject* object = nullptr);
+	void SetAction(QAction* action);
+	void SetPage(AnimeListPage* page);
+
+protected:
+	void run() override;
+
+private:
+	QAction* action_ = nullptr;
+	AnimeListPage* page_ = nullptr;
+};
+
 class MainWindow final : public QMainWindow {
 	Q_OBJECT
 
@@ -58,11 +76,14 @@
 	void closeEvent(QCloseEvent* event) override;
 
 private:
-	std::unique_ptr<QWidget> main_widget = nullptr;
-	std::unique_ptr<QStackedWidget> stack = nullptr;
-	std::unique_ptr<SideBar> sidebar = nullptr;
+	QWidget main_widget_;
+	QStackedWidget stack_;
+	SideBar sidebar_;
 
-	std::unique_ptr<PlayingThread> thread = nullptr;
+	MainWindowPlayingThread playing_thread_;
+	QTimer playing_thread_timer_;
+
+	MainWindowAsyncSynchronizeThread async_synchronize_thread_;
 
 	QMenu* folder_menu = nullptr;
 };