Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
324:5d3c9b31aa6e | 325:78929794e7d8 |
---|---|
1 #ifndef MINORI_GUI_PAGES_SEASONS_H_ | 1 #ifndef MINORI_GUI_PAGES_SEASONS_H_ |
2 #define MINORI_GUI_PAGES_SEASONS_H_ | 2 #define MINORI_GUI_PAGES_SEASONS_H_ |
3 | 3 |
4 #include <QFrame> | 4 #include <QFrame> |
5 #include <QThread> | |
5 | 6 |
6 #include "core/anime.h" | 7 #include "core/anime.h" |
7 #include "core/date.h" | 8 #include "core/date.h" |
8 | 9 |
10 #include <utility> | |
11 #include <queue> | |
12 | |
9 class QListWidget; | 13 class QListWidget; |
10 class QToolButton; | 14 class QToolButton; |
15 | |
16 Q_DECLARE_METATYPE(Anime::SeriesSeason); | |
17 Q_DECLARE_METATYPE(Date::Year); | |
18 | |
19 class SeasonsPageSearchThread : public QThread { | |
20 Q_OBJECT | |
21 | |
22 public: | |
23 SeasonsPageSearchThread(QObject* parent = nullptr); | |
24 void AddToQueue(Anime::SeriesSeason season, Date::Year year); | |
25 | |
26 protected: | |
27 void run() override; | |
28 | |
29 private: | |
30 struct Season { | |
31 Anime::SeriesSeason season; | |
32 Date::Year year; | |
33 }; | |
34 | |
35 std::queue<Season> queue_; | |
36 std::mutex queue_mutex_; | |
37 | |
38 signals: | |
39 void ReceivedSeason(Anime::SeriesSeason season, Date::Year year); | |
40 }; | |
11 | 41 |
12 class SeasonsPage final : public QFrame { | 42 class SeasonsPage final : public QFrame { |
13 Q_OBJECT | 43 Q_OBJECT |
14 | 44 |
15 public: | 45 public: |
16 SeasonsPage(QWidget* parent = nullptr); | 46 SeasonsPage(QWidget* parent = nullptr); |
17 void SetSeason(Anime::SeriesSeason season, Date::Year year); | 47 void SetSeason(Anime::SeriesSeason season, Date::Year year); |
48 void Refresh(); | |
18 | 49 |
19 protected: | 50 protected: |
20 QListWidget* buttons = nullptr; | 51 QListWidget* buttons = nullptr; |
21 QToolButton* season_button = nullptr; | 52 QToolButton* season_button = nullptr; |
53 | |
54 Anime::SeriesSeason season_; | |
55 Date::Year year_; | |
22 }; | 56 }; |
23 | 57 |
24 #endif // MINORI_GUI_PAGES_SEASONS_H_ | 58 #endif // MINORI_GUI_PAGES_SEASONS_H_ |