annotate src/gui/pages/seasons.cc @ 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 2115488eb302
children 10096c5489e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/pages/seasons.h"
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
3 #include "core/anime_db.h"
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
4 #include "core/anime_season_db.h"
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
5 #include "core/strings.h"
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
6 #include "gui/widgets/anime_button.h"
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
7 #include "gui/translate/anime.h"
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
8 #include "services/services.h"
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
9
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
10 #include <QDate>
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
11 #include <QFrame>
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
12 #include <QListWidget>
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
13 #include <QListWidgetItem>
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
14 #include <QMenu>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
15 #include <QToolBar>
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
16 #include <QToolButton>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
17 #include <QVBoxLayout>
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
18
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
19 SeasonsPageSearchThread::SeasonsPageSearchThread(QObject* parent) : QThread(parent) {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
20 }
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
21
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
22 void SeasonsPageSearchThread::AddToQueue(Anime::SeriesSeason season, Date::Year year) {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
23 queue_mutex_.lock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
24 queue_.push({season, year});
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
25 queue_mutex_.unlock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
26 }
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
27
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
28 void SeasonsPageSearchThread::run() {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
29 queue_mutex_.lock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
30
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
31 while (!queue_.empty() && !isInterruptionRequested()) {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
32 Season season = queue_.front();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
33
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
34 /* unlock the mutex for a long blocking operation, so items
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
35 * can be added without worry */
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
36 queue_mutex_.unlock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
37
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
38 if (Services::GetSeason(season.season, season.year))
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
39 emit ReceivedSeason(season.season, season.year);
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
40
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
41 queue_mutex_.lock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
42
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
43 queue_.pop();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
44 }
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
45
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
46 queue_mutex_.unlock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
47 }
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
48
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
49 static SeasonsPageSearchThread search_thread_;
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
50
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
51 /* ------------------------------------------------------------------------------------- */
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
52
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
53 static constexpr Date::Year GetClosestDecade(Date::Year year) {
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
54 return year - (year % 10);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
55 }
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
56
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
57 void SeasonsPage::Refresh() {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
58 setUpdatesEnabled(false);
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
59
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
60 if (!buttons || !season_button)
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
61 return;
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
62
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
63 buttons->clear();
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
64
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
65 for (const auto& id : Anime::Season::GetAllAnimeForSeason(season_, year_)) {
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
66 QListWidgetItem* item = new QListWidgetItem;
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
67 AnimeButton* button = new AnimeButton(this);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
68 button->SetAnime(Anime::db.items[id]);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
69 item->setSizeHint(button->sizeHint());
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
70 buttons->addItem(item);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
71 buttons->setItemWidget(item, button);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
72 }
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
73
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
74 season_button->setText(Strings::ToQString(Translate::ToLocalString(season_)) + " " + QString::number(year_));
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
75
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
76 setUpdatesEnabled(true);
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
77 }
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
78
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
79 void SeasonsPage::SetSeason(Anime::SeriesSeason season, Date::Year year) {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
80 season_ = season;
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
81 year_ = year;
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
82
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
83 Refresh();
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
84 }
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
85
295
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
86 SeasonsPage::SeasonsPage(QWidget* parent) : QFrame(parent) {
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
87 setBackgroundRole(QPalette::Base);
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
88 setFrameShape(QFrame::Box);
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
89 setFrameShadow(QFrame::Sunken);
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
90
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
91 QVBoxLayout* full_layout = new QVBoxLayout(this);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
92
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
93 {
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
94 /* Toolbar */
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
95 QToolBar* toolbar = new QToolBar(this);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
96 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
97 toolbar->setIconSize(QSize(16, 16));
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
98 toolbar->setMovable(false);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
99
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
100 {
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
101 static constexpr Date::Year last_year = 1960;
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
102
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
103 auto create_year_menu = [this](QWidget* parent, QMenu* parent_menu, Date::Year year){
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
104 const QString year_s = QString::number(year);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
105
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
106 QMenu* menu = new QMenu(year_s, parent);
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
107 for (const auto& season : Anime::SeriesSeasons) {
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
108 QAction* action = menu->addAction(Strings::ToQString(Translate::ToLocalString(season)) + " " + year_s);
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
109 connect(action, &QAction::triggered, this, [this, season, year] {
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
110 SetSeason(season, year);
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
111 });
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
112 }
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
113 parent_menu->addMenu(menu);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
114 };
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
115
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
116 auto create_decade_menu = [create_year_menu](QWidget* parent, QMenu* parent_menu, Date::Year decade) {
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
117 QMenu* menu = new QMenu(QString::number(decade) + "s", parent);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
118 for (int i = 9; i >= 0; i--)
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
119 create_year_menu(parent, menu, decade + i);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
120 parent_menu->addMenu(menu);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
121 };
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
122
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
123 /* we'll be extinct by the time this code breaks, so I guess it's fine :) */
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
124 const Date::Year current_year = static_cast<Date::Year>(QDate::currentDate().year());
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
125 const Date::Year year_before_collapse = GetClosestDecade(current_year) - 10;
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
126 season_button = new QToolButton(toolbar);
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
127 QMenu* full_season_menu = new QMenu(season_button);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
128
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
129 for (Date::Year c = current_year; c >= year_before_collapse; c--)
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
130 create_year_menu(season_button, full_season_menu, c);
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
131
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
132 full_season_menu->addSeparator();
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
133
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
134 for (Date::Year c = year_before_collapse - 10; c >= last_year; c -= 10)
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
135 create_decade_menu(season_button, full_season_menu, c);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
136
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
137 season_button->setMenu(full_season_menu);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
138 season_button->setPopupMode(QToolButton::InstantPopup);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
139
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
140 toolbar->addWidget(season_button);
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
141 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
142
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
143 toolbar->addSeparator();
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
144
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
145 {
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
146 toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("Refresh data"), [this]{
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
147 search_thread_.AddToQueue(season_, year_);
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
148 if (!search_thread_.isRunning())
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
149 search_thread_.start();
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
150 });
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
151 }
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
152
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
153 toolbar->addSeparator();
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
154
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
155 {
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
156 QToolButton* button = new QToolButton(toolbar);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
157
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
158 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
159 /* links */
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
160 QMenu* menu = new QMenu(button);
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
161 menu->addAction(tr("Airing status"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
162 menu->addAction(tr("List status"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
163 menu->addAction(tr("Type"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
164 button->setMenu(menu);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
165 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
166
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
167 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
168 button->setIcon(QIcon(":/icons/16x16/category.png"));
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
169 button->setText(tr("Group by:"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
170 button->setPopupMode(QToolButton::InstantPopup);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
171 toolbar->addWidget(button);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
172 }
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
173
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
174 {
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
175 QToolButton* button = new QToolButton(toolbar);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
176
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
177 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
178 /* links */
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
179 QMenu* menu = new QMenu(button);
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
180 menu->addAction(tr("Airing date"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
181 menu->addAction(tr("Episodes"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
182 menu->addAction(tr("Popularity"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
183 menu->addAction(tr("Score"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
184 menu->addAction(tr("Title"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
185 button->setMenu(menu);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
186 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
187
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
188 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
189 button->setIcon(QIcon(":/icons/16x16/sort-quantity-descending.png"));
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
190 button->setText(tr("Sort by:"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
191 button->setPopupMode(QToolButton::InstantPopup);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
192 toolbar->addWidget(button);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
193 }
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
194
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
195 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
196 QToolButton* button = new QToolButton(toolbar);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
197
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
198 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
199 /* links */
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
200 QMenu* menu = new QMenu(button);
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
201 menu->addAction(tr("Images"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
202 menu->addAction(tr("Details"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
203 button->setMenu(menu);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
204 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
205
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
206 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
207 button->setIcon(QIcon(":/icons/16x16/ui-scroll-pane-detail.png"));
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
208 button->setText(tr("View:"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
209 button->setPopupMode(QToolButton::InstantPopup);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
210 toolbar->addWidget(button);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
211 }
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
212
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
213 full_layout->addWidget(toolbar);
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
214 }
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
215
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
216 {
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
217 QFrame* line = new QFrame(this);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
218 line->setFrameShape(QFrame::HLine);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
219 line->setFrameShadow(QFrame::Sunken);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
220 line->setLineWidth(1);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
221 full_layout->addWidget(line);
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
222 }
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
223
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
224 {
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
225 buttons = new QListWidget(this);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
226 buttons->setFlow(QListView::LeftToRight);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
227 buttons->setWrapping(true);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
228 buttons->setContentsMargins(4, 4, 4, 4);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
229 buttons->setSpacing(2);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
230 buttons->setResizeMode(QListView::Adjust);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
231
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
232 full_layout->addWidget(buttons);
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
233 }
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
234
295
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
235 full_layout->setContentsMargins(0, 0, 0, 0);
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
236 full_layout->setSpacing(0);
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
237
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
238 connect(&search_thread_, &SeasonsPageSearchThread::ReceivedSeason, this, [this](Anime::SeriesSeason season, Date::Year year) {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
239 if (season == season_ && year == year_)
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
240 Refresh();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
241 });
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
242
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
243 /* Do NOT move this up in this function, buttons HAS to be initialized */
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
244 SetSeason(Anime::SeriesSeason::Summer, 2011U);
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
245 }