Mercurial > minori
annotate src/gui/pages/seasons.cc @ 327:b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
ToLocalString has also been altered to take in both season
and year because lots of locales actually treat formatting
seasons differently! most notably is Russian which adds a
suffix at the end to notate seasons(??)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 01:49:18 -0400 |
parents | 10096c5489e3 |
children | 6b0768158dcd |
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 |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
18 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
|
19 } |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
20 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
21 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
|
22 queue_mutex_.lock(); |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
23 queue_.push(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_.unlock(); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
25 } |
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 void SeasonsPageSearchThread::run() { |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
28 queue_mutex_.lock(); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
29 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
30 while (!queue_.empty() && !isInterruptionRequested()) { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
31 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
|
32 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
33 /* 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
|
34 * 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
|
35 queue_mutex_.unlock(); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
36 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
37 if (Services::GetSeason(season)) |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
38 emit ReceivedSeason(season); |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
39 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
40 queue_mutex_.lock(); |
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_.pop(); |
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 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
45 queue_mutex_.unlock(); |
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 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
48 static SeasonsPageSearchThread search_thread_; |
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 /* ------------------------------------------------------------------------------------- */ |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
51 |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
52 static constexpr Date::Year GetClosestDecade(Date::Year year) { |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
53 return year - (year % 10); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
54 } |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
55 |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
56 void SeasonsPage::Refresh() { |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
57 setUpdatesEnabled(false); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
58 |
263
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
59 if (!buttons || !season_button) |
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
60 return; |
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
61 |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
62 buttons->clear(); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
63 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
64 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
|
65 QListWidgetItem* item = new QListWidgetItem; |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
66 AnimeButton* button = new AnimeButton(this); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
67 button->SetAnime(Anime::db.items[id]); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
68 item->setSizeHint(button->sizeHint()); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
69 buttons->addItem(item); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
70 buttons->setItemWidget(item, button); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
71 } |
263
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
72 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
73 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
|
74 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
75 setUpdatesEnabled(true); |
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 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
78 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
|
79 season_ = season; |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
80 |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
81 Refresh(); |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
82 } |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
83 |
295 | 84 SeasonsPage::SeasonsPage(QWidget* parent) : QFrame(parent) { |
85 setBackgroundRole(QPalette::Base); | |
86 setFrameShape(QFrame::Box); | |
87 setFrameShadow(QFrame::Sunken); | |
88 | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
89 QVBoxLayout* full_layout = new QVBoxLayout(this); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
90 |
253 | 91 { |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
92 /* Toolbar */ |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
93 QToolBar* toolbar = new QToolBar(this); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
94 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
95 toolbar->setIconSize(QSize(16, 16)); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
96 toolbar->setMovable(false); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
97 |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
98 { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
99 /* currently this is VERY hardcoded to en_US */ |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
100 static constexpr Date::Year last_year = 1960; |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
101 |
263
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
102 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
|
103 const QString year_s = QString::number(year); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
104 |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
105 QMenu* menu = new QMenu(year_s, parent); |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
106 for (const auto& season : Anime::Season::Names) { |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
107 QAction* action = menu->addAction(Strings::ToQString(Translate::ToLocalString(Anime::Season(season, year)))); |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
108 connect(action, &QAction::triggered, this, [this, season, year] { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
109 SetSeason({season, year}); |
263
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
110 }); |
96416310ea14
pages/seasons: finish season menu implementation
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
111 } |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
112 parent_menu->addMenu(menu); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
113 }; |
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 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
|
116 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
|
117 for (int i = 9; i >= 0; i--) |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
118 create_year_menu(parent, menu, decade + i); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
119 parent_menu->addMenu(menu); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
120 }; |
255 | 121 |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
122 /* we'll be extinct by the time this code breaks, so I guess it's fine :) */ |
291 | 123 const Date::Year current_year = static_cast<Date::Year>(QDate::currentDate().year()); |
124 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
|
125 season_button = new QToolButton(toolbar); |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
126 QMenu* full_season_menu = new QMenu(season_button); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
127 |
291 | 128 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
|
129 create_year_menu(season_button, full_season_menu, c); |
255 | 130 |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
131 full_season_menu->addSeparator(); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
132 |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
133 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
|
134 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
|
135 |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
136 season_button->setMenu(full_season_menu); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
137 season_button->setPopupMode(QToolButton::InstantPopup); |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
138 |
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
139 toolbar->addWidget(season_button); |
255 | 140 } |
141 | |
142 toolbar->addSeparator(); | |
143 | |
304
2115488eb302
*: add very early season searcher
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
144 { |
2115488eb302
*: add very early season searcher
Paper <paper@paper.us.eu.org>
parents:
295
diff
changeset
|
145 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
|
146 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
|
147 if (!search_thread_.isRunning()) |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
148 search_thread_.start(); |
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 } |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
151 |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
152 toolbar->addSeparator(); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
153 |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
154 { |
255 | 155 QToolButton* button = new QToolButton(toolbar); |
156 | |
157 { | |
158 /* links */ | |
159 QMenu* menu = new QMenu(button); | |
291 | 160 menu->addAction(tr("Airing status")); |
161 menu->addAction(tr("List status")); | |
162 menu->addAction(tr("Type")); | |
255 | 163 button->setMenu(menu); |
164 } | |
165 | |
166 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
167 button->setIcon(QIcon(":/icons/16x16/category.png")); | |
291 | 168 button->setText(tr("Group by:")); |
255 | 169 button->setPopupMode(QToolButton::InstantPopup); |
170 toolbar->addWidget(button); | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
171 } |
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 { |
255 | 174 QToolButton* button = new QToolButton(toolbar); |
175 | |
176 { | |
177 /* links */ | |
178 QMenu* menu = new QMenu(button); | |
291 | 179 menu->addAction(tr("Airing date")); |
180 menu->addAction(tr("Episodes")); | |
181 menu->addAction(tr("Popularity")); | |
182 menu->addAction(tr("Score")); | |
183 menu->addAction(tr("Title")); | |
255 | 184 button->setMenu(menu); |
185 } | |
186 | |
187 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
188 button->setIcon(QIcon(":/icons/16x16/sort-quantity-descending.png")); | |
291 | 189 button->setText(tr("Sort by:")); |
255 | 190 button->setPopupMode(QToolButton::InstantPopup); |
191 toolbar->addWidget(button); | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
192 } |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
193 |
255 | 194 { |
195 QToolButton* button = new QToolButton(toolbar); | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
196 |
255 | 197 { |
198 /* links */ | |
199 QMenu* menu = new QMenu(button); | |
291 | 200 menu->addAction(tr("Images")); |
201 menu->addAction(tr("Details")); | |
255 | 202 button->setMenu(menu); |
203 } | |
204 | |
205 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
206 button->setIcon(QIcon(":/icons/16x16/ui-scroll-pane-detail.png")); | |
291 | 207 button->setText(tr("View:")); |
255 | 208 button->setPopupMode(QToolButton::InstantPopup); |
209 toolbar->addWidget(button); | |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
210 } |
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 full_layout->addWidget(toolbar); |
253 | 213 } |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
214 |
253 | 215 { |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
216 QFrame* line = new QFrame(this); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
217 line->setFrameShape(QFrame::HLine); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
218 line->setFrameShadow(QFrame::Sunken); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
219 line->setLineWidth(1); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
220 full_layout->addWidget(line); |
253 | 221 } |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
222 |
253 | 223 { |
254
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
224 buttons = new QListWidget(this); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
225 buttons->setFlow(QListView::LeftToRight); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
226 buttons->setWrapping(true); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
227 buttons->setContentsMargins(4, 4, 4, 4); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
228 buttons->setSpacing(2); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
229 buttons->setResizeMode(QListView::Adjust); |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
230 |
d14f8e0e40c3
[UNFINISHED] *: update anime button
Paper <paper@paper.us.eu.org>
parents:
253
diff
changeset
|
231 full_layout->addWidget(buttons); |
253 | 232 } |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
233 |
295 | 234 full_layout->setContentsMargins(0, 0, 0, 0); |
235 full_layout->setSpacing(0); | |
236 | |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
326
diff
changeset
|
237 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
|
238 if (season == season_) |
325
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
239 Refresh(); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
240 }); |
78929794e7d8
pages/seasons: run seasons search in a separate thread
Paper <paper@paper.us.eu.org>
parents:
304
diff
changeset
|
241 |
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
242 /* 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
|
243 SetSeason({Anime::Season::Name::Summer, 2011U}); |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
244 } |