annotate src/gui/pages/now_playing.cc @ 348:6b0768158dcd

text: redesign almost every widget i.e. Paragraph is now a QLabel, etc etc, some things will probably break, idc
author Paper <paper@paper.us.eu.org>
date Tue, 25 Jun 2024 11:19:54 -0400
parents b82841e76e79
children
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"
82
8b65c417c225 *: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
3 #include "core/strings.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
4 #include "gui/widgets/anime_info.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
5 #include "gui/widgets/poster.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
6 #include "gui/widgets/text.h"
178
bc8d2ccff09c win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents: 154
diff changeset
7
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
8 #include <QHBoxLayout>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
9 #include <QLabel>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
10 #include <QStackedWidget>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
11 #include <QVBoxLayout>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
12 #include <QWidget>
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
13
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
14 #include "anitomy/anitomy.h"
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
15
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
16 namespace NowPlayingPages {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
17
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
18 Default::Default(QWidget* parent) : QWidget(parent) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
19 QVBoxLayout* layout = new QVBoxLayout(this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
20 layout->setContentsMargins(0, 0, 0, 0);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
21
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
22 title_.SetText(Strings::Translate("Now Playing"));
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
23 layout->addWidget(&title_);
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
24
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
25 layout->addStretch();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
26 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
27
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
28 Playing::Playing(QWidget* parent) : QWidget(parent) {
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
29 QHBoxLayout* layout = new QHBoxLayout(this);
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
30
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
31 _main.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
32
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
33 QVBoxLayout* main_layout = new QVBoxLayout(&_main);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
34 main_layout->setContentsMargins(0, 0, 0, 0);
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
35
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
36 main_layout->addWidget(&_title);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
37
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
38 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
39 _info.layout()->setContentsMargins(0, 0, 0, 0);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
40 main_layout->addWidget(&_info);
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
41
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
42 /* "sidebar", includes... just the anime image :) */
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
43 QVBoxLayout* sidebar_layout = new QVBoxLayout(&_sidebar);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
44 sidebar_layout->setContentsMargins(0, 0, 0, 0);
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
45
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
46 sidebar_layout->addWidget(&_poster);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
47
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
48 sidebar_layout->addStretch();
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
49
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
50 layout->addWidget(&_sidebar);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
51 layout->addWidget(&_main);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
52 layout->setSpacing(10);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
53 layout->setContentsMargins(0, 0, 0, 0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
54 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
55
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
56 int Playing::GetPlayingAnime() {
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
57 return _id;
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
58 }
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
59
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
60 void Playing::SetPlayingAnime(const Anime::Anime& anime, const anitomy::Elements& info) {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
61 if (_id == anime.GetId()
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
62 && _episode == Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))))
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
63 return;
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
64 _id = anime.GetId();
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
65 _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber)));
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
66 _title.SetText(anime.GetUserPreferredTitle());
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
67 _info.SetAnime(anime);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
68 _poster.SetAnime(anime);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
69
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
70 updateGeometry();
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
71 }
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
72
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
73 } // namespace NowPlayingPages
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
74
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
75 NowPlayingPage::NowPlayingPage(QWidget* parent) : QFrame(parent) {
295
b82841e76e79 *: better support on Windows
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
76 setBackgroundRole(QPalette::Base);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
77 QVBoxLayout* layout = new QVBoxLayout(this);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
78
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
79 setFrameShape(QFrame::Box);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
80 setFrameShadow(QFrame::Sunken);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
81 setAutoFillBackground(true);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
82
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
83 stack_.addWidget(&default_);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
84 stack_.addWidget(&playing_);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
85 layout->addWidget(&stack_);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
86
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
87 SetDefault();
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
88 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
89
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
90 void NowPlayingPage::SetDefault() {
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
91 stack_.setCurrentIndex(static_cast<int>(Subpages::Default));
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
92 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
93
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
94 int NowPlayingPage::GetPlayingId() {
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
95 return playing_.GetPlayingAnime();
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
96 }
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
97
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
98 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) {
348
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
99 playing_.SetPlayingAnime(anime, info);
6b0768158dcd text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents: 295
diff changeset
100 stack_.setCurrentIndex(static_cast<int>(Subpages::Playing));
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
101 updateGeometry();
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
102 }