Mercurial > minori
annotate src/gui/pages/seasons.cc @ 355:83e6ba09338f
gui/pages/seasons: fix function disambiguation on win32
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 14 Jul 2024 23:46:18 -0400 |
parents | 6b0768158dcd |
children | f81bed4e04ac |
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 | 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 | 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 | 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 | 13 #include <QMenu> |
258 | 14 #include <QToolBar> |
255 | 15 #include <QToolButton> |
258 | 16 #include <QVBoxLayout> |
253 | 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 | 86 SeasonsPage::SeasonsPage(QWidget* parent) : QFrame(parent) { |
87 setBackgroundRole(QPalette::Base); | |
88 setFrameShape(QFrame::Box); | |
89 setFrameShadow(QFrame::Sunken); | |
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 | 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 | 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 | 145 } |
146 | |
147 toolbar->addSeparator(); | |
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 | 160 QToolButton* button = new QToolButton(toolbar); |
161 | |
162 { | |
163 /* links */ | |
164 QMenu* menu = new QMenu(button); | |
291 | 165 menu->addAction(tr("Airing status")); |
166 menu->addAction(tr("List status")); | |
167 menu->addAction(tr("Type")); | |
255 | 168 button->setMenu(menu); |
169 } | |
170 | |
171 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
172 button->setIcon(QIcon(":/icons/16x16/category.png")); | |
291 | 173 button->setText(tr("Group by:")); |
255 | 174 button->setPopupMode(QToolButton::InstantPopup); |
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 | 179 QToolButton* button = new QToolButton(toolbar); |
180 | |
181 { | |
182 /* links */ | |
183 QMenu* menu = new QMenu(button); | |
291 | 184 menu->addAction(tr("Airing date")); |
185 menu->addAction(tr("Episodes")); | |
186 menu->addAction(tr("Popularity")); | |
187 menu->addAction(tr("Score")); | |
188 menu->addAction(tr("Title")); | |
255 | 189 button->setMenu(menu); |
190 } | |
191 | |
192 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
193 button->setIcon(QIcon(":/icons/16x16/sort-quantity-descending.png")); | |
291 | 194 button->setText(tr("Sort by:")); |
255 | 195 button->setPopupMode(QToolButton::InstantPopup); |
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 | 199 { |
200 QToolButton* button = new QToolButton(toolbar); | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
201 |
255 | 202 { |
203 /* links */ | |
204 QMenu* menu = new QMenu(button); | |
291 | 205 menu->addAction(tr("Images")); |
206 menu->addAction(tr("Details")); | |
255 | 207 button->setMenu(menu); |
208 } | |
209 | |
210 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
211 button->setIcon(QIcon(":/icons/16x16/ui-scroll-pane-detail.png")); | |
291 | 212 button->setText(tr("View:")); |
255 | 213 button->setPopupMode(QToolButton::InstantPopup); |
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 | 218 } |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
219 |
253 | 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 | 226 } |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
227 |
253 | 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 | 237 } |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
238 |
295 | 239 full_layout->setContentsMargins(0, 0, 0, 0); |
240 full_layout->setSpacing(0); | |
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 } |