comparison include/gui/window.h @ 170:c8375765f0fc

window: make threading somewhat sane
author Paper <mrpapersonic@gmail.com>
date Tue, 21 Nov 2023 11:04:13 -0500
parents ab191e28e69d
children 4d461ef7d424
comparison
equal deleted inserted replaced
169:e44b7c428d7c 170:c8375765f0fc
8 any file that #includes this to have to #include 8 any file that #includes this to have to #include
9 these as well due to unique_ptr */ 9 these as well due to unique_ptr */
10 #include <QWidget> 10 #include <QWidget>
11 #include <QStackedWidget> 11 #include <QStackedWidget>
12 #include <QCloseEvent> 12 #include <QCloseEvent>
13 #include <QThread>
13 #include "gui/widgets/sidebar.h" 14 #include "gui/widgets/sidebar.h"
15
16 Q_DECLARE_METATYPE(std::vector<std::string>);
17
18 class PlayingThread : public QThread {
19 Q_OBJECT
20
21 public:
22 PlayingThread(QObject* object = nullptr) : QThread(object) {}
23
24 private:
25 void run() override;
26
27 signals:
28 void Done(const std::vector<std::string>& files);
29 };
14 30
15 class MainWindow final : public QMainWindow { 31 class MainWindow final : public QMainWindow {
16 Q_OBJECT 32 Q_OBJECT
17 33
18 public: 34 public:
28 44
29 private: 45 private:
30 std::unique_ptr<QWidget> main_widget = nullptr; 46 std::unique_ptr<QWidget> main_widget = nullptr;
31 std::unique_ptr<QStackedWidget> stack = nullptr; 47 std::unique_ptr<QStackedWidget> stack = nullptr;
32 std::unique_ptr<SideBar> sidebar = nullptr; 48 std::unique_ptr<SideBar> sidebar = nullptr;
49
50 std::unique_ptr<PlayingThread> thread = nullptr;
33 }; 51 };
34 52
35 #endif // __window_h 53 #endif // __window_h