Mercurial > minori
annotate include/gui/window.h @ 333:5980a960f3e1
translate/anime: use fmt for translating anime seasons
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 17 Jun 2024 20:03:58 -0400 |
parents | 34347fd2a2de |
children |
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_ |
291 | 3 |
9 | 4 #include "core/config.h" |
291 | 5 #include "gui/widgets/sidebar.h" |
79 | 6 |
291 | 7 /* pages; these should really be in a namespace */ |
8 #include "gui/pages/anime_list.h" | |
9 #include "gui/pages/history.h" | |
10 #include "gui/pages/now_playing.h" | |
11 #include "gui/pages/search.h" | |
12 #include "gui/pages/seasons.h" | |
13 #include "gui/pages/statistics.h" | |
14 #include "gui/pages/torrents.h" | |
15 | |
16 #include <QMainWindow> | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
17 #include <QCloseEvent> |
258 | 18 #include <QStackedWidget> |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
19 #include <QThread> |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
20 #include <QTimer> |
258 | 21 #include <QWidget> |
2 | 22 |
291 | 23 #include <memory> |
24 | |
250 | 25 class QMenu; |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
26 class AnimeListPage; |
250 | 27 |
291 | 28 /* ... :) */ |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
29 Q_DECLARE_METATYPE(std::vector<std::string>); |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
30 Q_DECLARE_METATYPE(std::string); |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
31 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
32 class MainWindowPlayingThread final : public QThread { |
258 | 33 Q_OBJECT |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
34 |
258 | 35 public: |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
36 MainWindowPlayingThread(QObject* object = nullptr) : QThread(object) {} |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
37 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
38 protected: |
258 | 39 void run() override; |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
40 |
258 | 41 signals: |
42 void Done(const std::vector<std::string>& files); | |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
43 }; |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
44 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
45 class MainWindowAsyncSynchronizeThread final : public QThread { |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
46 Q_OBJECT |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
47 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
48 public: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
49 MainWindowAsyncSynchronizeThread(QAction* action, AnimeListPage* page, QObject* object = nullptr); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
50 void SetAction(QAction* action); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
51 void SetPage(AnimeListPage* page); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
52 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
53 protected: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
54 void run() override; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
55 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
56 private: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
57 QAction* action_ = nullptr; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
58 AnimeListPage* page_ = nullptr; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
59 }; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
60 |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
79
diff
changeset
|
61 class MainWindow final : public QMainWindow { |
258 | 62 Q_OBJECT |
9 | 63 |
258 | 64 public: |
65 enum class Pages { | |
66 NOW_PLAYING, | |
250 | 67 |
258 | 68 ANIME_LIST, |
69 HISTORY, | |
70 STATISTICS, | |
250 | 71 |
258 | 72 SEARCH, |
73 SEASONS, | |
74 TORRENTS | |
75 }; | |
250 | 76 |
258 | 77 MainWindow(QWidget* parent = nullptr); |
78 void SetActivePage(QWidget* page); | |
79 void CreateBars(); | |
80 void AddMainWidgets(); | |
81 void RetranslateUI(); | |
82 void UpdateFolderMenu(); | |
83 void AsyncSynchronize(QAction* action, QStackedWidget* stack); | |
84 void changeEvent(QEvent* event) override; | |
85 void showEvent(QShowEvent* event) override; | |
86 void closeEvent(QCloseEvent* event) override; | |
2 | 87 |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
88 public slots: |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
89 void SetStatusMessage(const std::string& message); |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
90 |
258 | 91 private: |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
92 QWidget main_widget_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
93 QStackedWidget stack_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
94 SideBar sidebar_; |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
95 |
291 | 96 AnimeListPage anime_list_page_; |
97 HistoryPage history_page_; | |
98 NowPlayingPage now_playing_page_; | |
99 SearchPage search_page_; | |
100 SeasonsPage seasons_page_; | |
101 StatisticsPage statistics_page_; | |
102 TorrentsPage torrents_page_; | |
103 | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
104 MainWindowPlayingThread playing_thread_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
105 QTimer playing_thread_timer_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
106 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
107 MainWindowAsyncSynchronizeThread async_synchronize_thread_; |
250 | 108 |
258 | 109 QMenu* folder_menu = nullptr; |
2 | 110 }; |
111 | |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
112 #endif // MINORI_WINDOW_H_ |