Mercurial > minori
annotate include/gui/window.h @ 289:3dbf01233fec
autoconf: add a check for some weird Qt PIC requirements
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 08 May 2024 17:27:13 -0400 |
parents | f31305b9f60a |
children | 9a88e1725fd2 |
rev | line source |
---|---|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
1 #ifndef MINORI_WINDOW_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
2 #define MINORI_WINDOW_H_ |
9 | 3 #include "core/config.h" |
7 | 4 #include <QMainWindow> |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
5 #include <memory> |
79 | 6 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
7 /* *could* be forward-declared, but this causes |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
8 any file that #includes this to have to #include |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
9 these as well due to unique_ptr */ |
258 | 10 #include "gui/widgets/sidebar.h" |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
11 #include <QCloseEvent> |
258 | 12 #include <QStackedWidget> |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
13 #include <QThread> |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
14 #include <QTimer> |
258 | 15 #include <QWidget> |
2 | 16 |
250 | 17 class QMenu; |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
18 class AnimeListPage; |
250 | 19 |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
20 Q_DECLARE_METATYPE(std::vector<std::string>); |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
21 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
22 class MainWindowPlayingThread final : public QThread { |
258 | 23 Q_OBJECT |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
24 |
258 | 25 public: |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
26 MainWindowPlayingThread(QObject* object = nullptr) : QThread(object) {} |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
27 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
28 protected: |
258 | 29 void run() override; |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
30 |
258 | 31 signals: |
32 void Done(const std::vector<std::string>& files); | |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
33 }; |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
34 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
35 class MainWindowAsyncSynchronizeThread final : public QThread { |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
36 Q_OBJECT |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
37 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
38 public: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
39 MainWindowAsyncSynchronizeThread(QAction* action, AnimeListPage* page, QObject* object = nullptr); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
40 void SetAction(QAction* action); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
41 void SetPage(AnimeListPage* page); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
42 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
43 protected: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
44 void run() override; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
45 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
46 private: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
47 QAction* action_ = nullptr; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
48 AnimeListPage* page_ = nullptr; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
49 }; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
50 |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
79
diff
changeset
|
51 class MainWindow final : public QMainWindow { |
258 | 52 Q_OBJECT |
9 | 53 |
258 | 54 public: |
55 enum class Pages { | |
56 NOW_PLAYING, | |
250 | 57 |
258 | 58 ANIME_LIST, |
59 HISTORY, | |
60 STATISTICS, | |
250 | 61 |
258 | 62 SEARCH, |
63 SEASONS, | |
64 TORRENTS | |
65 }; | |
250 | 66 |
258 | 67 MainWindow(QWidget* parent = nullptr); |
68 void SetActivePage(QWidget* page); | |
69 void CreateBars(); | |
70 void AddMainWidgets(); | |
71 void RetranslateUI(); | |
72 void UpdateFolderMenu(); | |
73 void AsyncSynchronize(QAction* action, QStackedWidget* stack); | |
74 void changeEvent(QEvent* event) override; | |
75 void showEvent(QShowEvent* event) override; | |
76 void closeEvent(QCloseEvent* event) override; | |
2 | 77 |
258 | 78 private: |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
79 QWidget main_widget_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
80 QStackedWidget stack_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
81 SideBar sidebar_; |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
82 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
83 MainWindowPlayingThread playing_thread_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
84 QTimer playing_thread_timer_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
85 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
86 MainWindowAsyncSynchronizeThread async_synchronize_thread_; |
250 | 87 |
258 | 88 QMenu* folder_menu = nullptr; |
2 | 89 }; |
90 | |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
91 #endif // MINORI_WINDOW_H_ |