Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/include/gui/pages/seasons.h Wed Jun 12 23:03:22 2024 -0400 +++ b/include/gui/pages/seasons.h Thu Jun 13 00:36:41 2024 -0400 @@ -2,23 +2,57 @@ #define MINORI_GUI_PAGES_SEASONS_H_ #include <QFrame> +#include <QThread> #include "core/anime.h" #include "core/date.h" +#include <utility> +#include <queue> + class QListWidget; class QToolButton; +Q_DECLARE_METATYPE(Anime::SeriesSeason); +Q_DECLARE_METATYPE(Date::Year); + +class SeasonsPageSearchThread : public QThread { + Q_OBJECT + +public: + SeasonsPageSearchThread(QObject* parent = nullptr); + void AddToQueue(Anime::SeriesSeason season, Date::Year year); + +protected: + void run() override; + +private: + struct Season { + Anime::SeriesSeason season; + Date::Year year; + }; + + std::queue<Season> queue_; + std::mutex queue_mutex_; + +signals: + void ReceivedSeason(Anime::SeriesSeason season, Date::Year year); +}; + class SeasonsPage final : public QFrame { Q_OBJECT public: SeasonsPage(QWidget* parent = nullptr); void SetSeason(Anime::SeriesSeason season, Date::Year year); + void Refresh(); protected: QListWidget* buttons = nullptr; QToolButton* season_button = nullptr; + + Anime::SeriesSeason season_; + Date::Year year_; }; #endif // MINORI_GUI_PAGES_SEASONS_H_