Mercurial > minori
annotate include/gui/pages/seasons.h @ 325:78929794e7d8
pages/seasons: run seasons search in a separate thread
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 00:36:41 -0400 |
parents | b82841e76e79 |
children | b5d6c27c308f |
rev | line source |
---|---|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
1 #ifndef MINORI_GUI_PAGES_SEASONS_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
2 #define MINORI_GUI_PAGES_SEASONS_H_ |
85 | 3 |
295 | 4 #include <QFrame> |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
5 #include <QThread> |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
6 |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
255
diff
changeset
|
7 #include "core/anime.h" |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
255
diff
changeset
|
8 #include "core/date.h" |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
255
diff
changeset
|
9 |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
10 #include <utility> |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
11 #include <queue> |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
12 |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
95
diff
changeset
|
13 class QListWidget; |
263
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
14 class QToolButton; |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
95
diff
changeset
|
15 |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
16 Q_DECLARE_METATYPE(Anime::SeriesSeason); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
17 Q_DECLARE_METATYPE(Date::Year); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
18 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
19 class SeasonsPageSearchThread : public QThread { |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
20 Q_OBJECT |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
21 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
22 public: |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
23 SeasonsPageSearchThread(QObject* parent = nullptr); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
24 void AddToQueue(Anime::SeriesSeason season, Date::Year year); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
25 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
26 protected: |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
27 void run() override; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
28 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
29 private: |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
30 struct Season { |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
31 Anime::SeriesSeason season; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
32 Date::Year year; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
33 }; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
34 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
35 std::queue<Season> queue_; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
36 std::mutex queue_mutex_; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
37 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
38 signals: |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
39 void ReceivedSeason(Anime::SeriesSeason season, Date::Year year); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
40 }; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
41 |
295 | 42 class SeasonsPage final : public QFrame { |
255 | 43 Q_OBJECT |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
44 |
255 | 45 public: |
46 SeasonsPage(QWidget* parent = nullptr); | |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
255
diff
changeset
|
47 void SetSeason(Anime::SeriesSeason season, Date::Year year); |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
48 void Refresh(); |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
95
diff
changeset
|
49 |
255 | 50 protected: |
51 QListWidget* buttons = nullptr; | |
263
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
52 QToolButton* season_button = nullptr; |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
53 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
54 Anime::SeriesSeason season_; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
55 Date::Year year_; |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
56 }; |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
57 |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
58 #endif // MINORI_GUI_PAGES_SEASONS_H_ |