annotate src/gui/pages/seasons.cc @ 359:4e0e17d3c67a

CI/linux: ignore linuxdeployqt silently failing
author Paper <paper@paper.us.eu.org>
date Mon, 15 Jul 2024 01:06:39 -0400
parents 83e6ba09338f
children f81bed4e04ac
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/strings.h"
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
5 #include "gui/widgets/anime_button.h"
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
6 #include "gui/translate/anime.h"
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
7 #include "services/services.h"
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
8
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
9 #include <QDate>
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
10 #include <QFrame>
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
11 #include <QListWidget>
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
12 #include <QListWidgetItem>
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
13 #include <QMenu>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
14 #include <QToolBar>
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
15 #include <QToolButton>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
16 #include <QVBoxLayout>
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
17
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
18 #include <iostream>
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
19
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
20 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
21 }
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
22
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
23 void SeasonsPageSearchThread::AddToQueue(Anime::Season season) {
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
24 queue_mutex_.lock();
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
25 queue_.push(season);
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
26 queue_mutex_.unlock();
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
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
29 void SeasonsPageSearchThread::run() {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
30 queue_mutex_.lock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
31
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
32 while (!queue_.empty() && !isInterruptionRequested()) {
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
33 Anime::Season season = queue_.front();
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
34
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
35 /* 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
36 * 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
37 queue_mutex_.unlock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
38
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
39 if (Services::GetSeason(season))
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
40 emit ReceivedSeason(season);
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
41
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
42 queue_mutex_.lock();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
43
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
44 queue_.pop();
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
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
47 queue_mutex_.unlock();
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
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
50 static SeasonsPageSearchThread search_thread_;
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 /* ------------------------------------------------------------------------------------- */
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
53
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
54 static constexpr Date::Year GetClosestDecade(Date::Year year) {
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
55 return year - (year % 10);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
56 }
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
57
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
58 void SeasonsPage::Refresh() {
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
59 setUpdatesEnabled(false);
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
60
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
61 if (!buttons)
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
62 return;
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
63
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
64 buttons->clear();
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
65
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
66 for (const auto& id : Anime::db.GetAllAnimeForSeason(season_)) {
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
67 QListWidgetItem* item = new QListWidgetItem;
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
68 AnimeButton* button = new AnimeButton(this);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
69 button->SetAnime(Anime::db.items[id]);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
70 item->setSizeHint(button->sizeHint());
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
71 buttons->addItem(item);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
72 buttons->setItemWidget(item, button);
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
73 }
263
96416310ea14 pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents: 260
diff changeset
74
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
75 season_button.setText(Strings::ToQString(Translate::ToLocalString(season_)));
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
76
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
77 setUpdatesEnabled(true);
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
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
80 void SeasonsPage::SetSeason(Anime::Season season) {
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
81 season_ = season;
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 {
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
101 /* XXX this last year probably shouldn't be hardcoded */
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
102 static const Anime::Season last_season(Anime::Season::Name::Winter, 1960);
355
83e6ba09338f gui/pages/seasons: fix function disambiguation on win32
Paper <paper@paper.us.eu.org>
parents: 348
diff changeset
103 Anime::Season current_season((Date(QDate::currentDate())));
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
104 const Date::Year year_before_collapse = GetClosestDecade(current_season.year) - 10;
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
105
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
106 /* year -> menu for that year */
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
107 std::map<Date::Year, QMenu*> menu_map;
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
108
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
109 auto create_season_menu = [&](QWidget* parent, Anime::Season season){
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
110 QMenu*& menu = menu_map[season.year];
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
111 if (!menu)
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
112 menu = new QMenu(QString::number(season.year), parent);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
113
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
114 QAction* action = menu->addAction(Strings::ToQString(Translate::ToLocalString(season)));
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
115 connect(action, &QAction::triggered, this, [this, season] {
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
116 SetSeason(season);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
117 });
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
118 };
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
119
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
120 for (Anime::Season s = current_season; s >= last_season; --s)
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
121 create_season_menu(&season_button, s);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
122
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
123 /* ------------------------------------------------------- */
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
124 /* now actually generate the full menu */
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
125
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
126 QMenu* full_menu = new QMenu(&season_button);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
127
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
128 for (Date::Year c = current_season.year; c >= year_before_collapse; c--)
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
129 full_menu->addMenu(menu_map[c]);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
130
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
131 full_menu->addSeparator();
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
132
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
133 /* collapse each menu into a decade */
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
134 for (Date::Year c = year_before_collapse - 10; c >= last_season.year; c -= 10) {
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
135 QMenu* decade_menu = new QMenu(tr("%1s").arg(QString::number(c)), parent);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
136 for (Date::Year i = c + 9; i >= c; i--)
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
137 decade_menu->addMenu(menu_map[i]);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
138 full_menu->addMenu(decade_menu);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
139 }
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
140
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
141 season_button.setMenu(full_menu);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
142 season_button.setPopupMode(QToolButton::InstantPopup);
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
143
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 327
diff changeset
144 toolbar->addWidget(&season_button);
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
145 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
146
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
147 toolbar->addSeparator();
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
148
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
149 {
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
150 toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("Refresh data"), [this]{
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
151 search_thread_.AddToQueue(season_);
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
152 if (!search_thread_.isRunning())
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
153 search_thread_.start();
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
154 });
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
155 }
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
156
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
157 toolbar->addSeparator();
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
158
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
159 {
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
160 QToolButton* button = new QToolButton(toolbar);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
161
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
162 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
163 /* links */
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
164 QMenu* menu = new QMenu(button);
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
165 menu->addAction(tr("Airing status"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
166 menu->addAction(tr("List status"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
167 menu->addAction(tr("Type"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
168 button->setMenu(menu);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
169 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
170
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
171 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
172 button->setIcon(QIcon(":/icons/16x16/category.png"));
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
173 button->setText(tr("Group by:"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
174 button->setPopupMode(QToolButton::InstantPopup);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
175 toolbar->addWidget(button);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
176 }
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
177
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
178 {
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
179 QToolButton* button = new QToolButton(toolbar);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
180
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
181 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
182 /* links */
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
183 QMenu* menu = new QMenu(button);
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
184 menu->addAction(tr("Airing date"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
185 menu->addAction(tr("Episodes"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
186 menu->addAction(tr("Popularity"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
187 menu->addAction(tr("Score"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
188 menu->addAction(tr("Title"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
189 button->setMenu(menu);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
190 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
191
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
192 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
193 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
194 button->setText(tr("Sort by:"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
195 button->setPopupMode(QToolButton::InstantPopup);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
196 toolbar->addWidget(button);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
197 }
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
198
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
199 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
200 QToolButton* button = new QToolButton(toolbar);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
201
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
202 {
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
203 /* links */
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
204 QMenu* menu = new QMenu(button);
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
205 menu->addAction(tr("Images"));
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
206 menu->addAction(tr("Details"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
207 button->setMenu(menu);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
208 }
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
209
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
210 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
211 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
212 button->setText(tr("View:"));
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
213 button->setPopupMode(QToolButton::InstantPopup);
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 254
diff changeset
214 toolbar->addWidget(button);
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
215 }
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
216
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
217 full_layout->addWidget(toolbar);
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
218 }
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
219
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
220 {
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
221 QFrame* line = new QFrame(this);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
222 line->setFrameShape(QFrame::HLine);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
223 line->setFrameShadow(QFrame::Sunken);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
224 line->setLineWidth(1);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
225 full_layout->addWidget(line);
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
226 }
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
227
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
228 {
254
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
229 buttons = new QListWidget(this);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
230 buttons->setFlow(QListView::LeftToRight);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
231 buttons->setWrapping(true);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
232 buttons->setContentsMargins(4, 4, 4, 4);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
233 buttons->setSpacing(2);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
234 buttons->setResizeMode(QListView::Adjust);
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
235
d14f8e0e40c3 [UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents: 253
diff changeset
236 full_layout->addWidget(buttons);
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
237 }
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
238
295
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
239 full_layout->setContentsMargins(0, 0, 0, 0);
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
240 full_layout->setSpacing(0);
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
241
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
242 connect(&search_thread_, &SeasonsPageSearchThread::ReceivedSeason, this, [this](Anime::Season season) {
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
243 if (season == season_)
325
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
244 Refresh();
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
245 });
78929794e7d8 pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
246
260
dd211ff68b36 pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
247 /* Do NOT move this up in this function, buttons HAS to be initialized */
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 326
diff changeset
248 SetSeason({Anime::Season::Name::Summer, 2011U});
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
249 }