annotate src/gui/pages/now_playing.cpp @ 66:6481c5aed3e1

posters: add poster widget... why does AniList call these cover images? they're posters...
author Paper <mrpapersonic@gmail.com>
date Mon, 02 Oct 2023 05:56:32 -0400
parents fe719c109dbc
children 2417121d894e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
1 #include "gui/pages/now_playing.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
2 #include "core/anime_db.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
3 #include "gui/widgets/anime_info.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
4 #include "gui/widgets/text.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
5 #include <QLabel>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
6 #include <QStackedWidget>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
7 #include <QVBoxLayout>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
8 #include <QWidget>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
9
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
10 namespace NowPlayingPages {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
11
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
12 class Default : public QWidget {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
13 Q_OBJECT
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
14
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
15 public:
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
16 Default(QWidget* parent = nullptr);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
17 };
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
18
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
19 class Playing : public QWidget {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
20 Q_OBJECT
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
21
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
22 public:
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
23 Playing(QWidget* parent = nullptr);
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
24 void SetPlayingAnime(int id);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
25
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
26 private:
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
27 std::unique_ptr<AnimeInfoWidget> info = nullptr;
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
28 };
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
29
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
30 Default::Default(QWidget* parent) : QWidget(parent) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
31 QVBoxLayout* layout = new QVBoxLayout(this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
32 layout->setContentsMargins(0, 0, 0, 0);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
33
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
34 layout->addStretch();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
35 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
36
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
37 Playing::Playing(QWidget* parent) : QWidget(parent) {
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
38 QHBoxLayout* layout = new QHBoxLayout(this);
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
39
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
40 layout->setContentsMargins(0, 0, 0, 0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
41 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
42
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
43 void Playing::SetPlayingAnime(int id) {
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
44 if (info.get())
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
45 layout()->removeWidget(info.get());
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
46 info.reset(new AnimeInfoWidget(Anime::db.items[id]));
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
47 layout()->addWidget(info.get());
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
48 }
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
49
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
50 } // namespace NowPlayingPages
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
51
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
52 NowPlayingPage::NowPlayingPage(QWidget* parent) : QFrame(parent) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
53 QVBoxLayout* layout = new QVBoxLayout(this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
54
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
55 setFrameShape(QFrame::Box);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
56 setFrameShadow(QFrame::Sunken);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
57
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
58 QPalette pal = QPalette();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
59 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
60 setPalette(pal);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
61 setAutoFillBackground(true);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
62
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
63 TextWidgets::Title* title = new TextWidgets::Title(tr("Now Playing"), this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
64 layout->addWidget(title);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
65
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
66 stack = new QStackedWidget(this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
67 stack->addWidget(new NowPlayingPages::Default(stack));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
68 stack->addWidget(new NowPlayingPages::Playing(stack));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
69 layout->addWidget(stack);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
70
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
71 layout->addStretch();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
72 SetDefault();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
73 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
74
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
75 void NowPlayingPage::SetDefault() {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
76 stack->setCurrentIndex(0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
77 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
78
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
79 void NowPlayingPage::SetPlaying(int id) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
80 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(id);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
81 stack->setCurrentIndex(1);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
82 }
7
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
83
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
84 #include "gui/pages/moc_now_playing.cpp"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
85 #include "now_playing.moc"