Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 272:5437009cb10e | 273:f31305b9f60a |
|---|---|
| 9 these as well due to unique_ptr */ | 9 these as well due to unique_ptr */ |
| 10 #include "gui/widgets/sidebar.h" | 10 #include "gui/widgets/sidebar.h" |
| 11 #include <QCloseEvent> | 11 #include <QCloseEvent> |
| 12 #include <QStackedWidget> | 12 #include <QStackedWidget> |
| 13 #include <QThread> | 13 #include <QThread> |
| 14 #include <QTimer> | |
| 14 #include <QWidget> | 15 #include <QWidget> |
| 15 | 16 |
| 16 class QMenu; | 17 class QMenu; |
| 18 class AnimeListPage; | |
| 17 | 19 |
| 18 Q_DECLARE_METATYPE(std::vector<std::string>); | 20 Q_DECLARE_METATYPE(std::vector<std::string>); |
| 19 | 21 |
| 20 class PlayingThread : public QThread { | 22 class MainWindowPlayingThread final : public QThread { |
| 21 Q_OBJECT | 23 Q_OBJECT |
| 22 | 24 |
| 23 public: | 25 public: |
| 24 PlayingThread(QObject* object = nullptr) : QThread(object) {} | 26 MainWindowPlayingThread(QObject* object = nullptr) : QThread(object) {} |
| 25 | 27 |
| 26 private: | 28 protected: |
| 27 void run() override; | 29 void run() override; |
| 28 | 30 |
| 29 signals: | 31 signals: |
| 30 void Done(const std::vector<std::string>& files); | 32 void Done(const std::vector<std::string>& files); |
| 33 }; | |
| 34 | |
| 35 class MainWindowAsyncSynchronizeThread final : public QThread { | |
| 36 Q_OBJECT | |
| 37 | |
| 38 public: | |
| 39 MainWindowAsyncSynchronizeThread(QAction* action, AnimeListPage* page, QObject* object = nullptr); | |
| 40 void SetAction(QAction* action); | |
| 41 void SetPage(AnimeListPage* page); | |
| 42 | |
| 43 protected: | |
| 44 void run() override; | |
| 45 | |
| 46 private: | |
| 47 QAction* action_ = nullptr; | |
| 48 AnimeListPage* page_ = nullptr; | |
| 31 }; | 49 }; |
| 32 | 50 |
| 33 class MainWindow final : public QMainWindow { | 51 class MainWindow final : public QMainWindow { |
| 34 Q_OBJECT | 52 Q_OBJECT |
| 35 | 53 |
| 56 void changeEvent(QEvent* event) override; | 74 void changeEvent(QEvent* event) override; |
| 57 void showEvent(QShowEvent* event) override; | 75 void showEvent(QShowEvent* event) override; |
| 58 void closeEvent(QCloseEvent* event) override; | 76 void closeEvent(QCloseEvent* event) override; |
| 59 | 77 |
| 60 private: | 78 private: |
| 61 std::unique_ptr<QWidget> main_widget = nullptr; | 79 QWidget main_widget_; |
| 62 std::unique_ptr<QStackedWidget> stack = nullptr; | 80 QStackedWidget stack_; |
| 63 std::unique_ptr<SideBar> sidebar = nullptr; | 81 SideBar sidebar_; |
| 64 | 82 |
| 65 std::unique_ptr<PlayingThread> thread = nullptr; | 83 MainWindowPlayingThread playing_thread_; |
| 84 QTimer playing_thread_timer_; | |
| 85 | |
| 86 MainWindowAsyncSynchronizeThread async_synchronize_thread_; | |
| 66 | 87 |
| 67 QMenu* folder_menu = nullptr; | 88 QMenu* folder_menu = nullptr; |
| 68 }; | 89 }; |
| 69 | 90 |
| 70 #endif // MINORI_WINDOW_H_ | 91 #endif // MINORI_WINDOW_H_ |
