Mercurial > minori
annotate src/gui/pages/now_playing.cc @ 337:a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
1: animone now has its own syntax divergent from anisthesia,
making different platforms actually have their own sections
2: process names in animone are now called `comm' (this will
probably break things). this is what its called in bsd/linux
so I'm just going to use it everywhere
3: the X11 code now checks for the existence of a UTF-8 window title
and passes it if available
4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK!
I still actually need to test the bsd code. to be honest I'm probably
going to move all of the bsds into separate files because they're
all essentially different operating systems at this point
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 19 Jun 2024 12:51:15 -0400 |
parents | b82841e76e79 |
children | 6b0768158dcd |
rev | line source |
---|---|
9 | 1 #include "gui/pages/now_playing.h" |
64 | 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 | 4 #include "gui/widgets/anime_info.h" |
258 | 5 #include "gui/widgets/poster.h" |
64 | 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 | 8 #include <QHBoxLayout> |
64 | 9 #include <QLabel> |
10 #include <QStackedWidget> | |
11 #include <QVBoxLayout> | |
12 #include <QWidget> | |
13 | |
154 | 14 #include "anitomy/anitomy.h" |
15 | |
64 | 16 namespace NowPlayingPages { |
17 | |
18 Default::Default(QWidget* parent) : QWidget(parent) { | |
19 QVBoxLayout* layout = new QVBoxLayout(this); | |
20 layout->setContentsMargins(0, 0, 0, 0); | |
2 | 21 |
80 | 22 TextWidgets::Title* title = new TextWidgets::Title(tr("Now Playing"), this); |
23 layout->addWidget(title); | |
24 | |
64 | 25 layout->addStretch(); |
26 } | |
27 | |
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 |
83 | 31 _main.reset(new QWidget(this)); |
32 _main->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
33 | |
34 QVBoxLayout* main_layout = new QVBoxLayout(_main.get()); | |
35 main_layout->setContentsMargins(0, 0, 0, 0); | |
36 | |
37 _title.reset(new TextWidgets::Title("", _main.get())); | |
38 main_layout->addWidget(_title.get()); | |
39 | |
40 _info.reset(new AnimeInfoWidget(_main.get())); | |
41 _info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
97
18979b066284
animia/unix: fix a bunch of stuff that breaks OS X things
Paper <mrpapersonic@gmail.com>
parents:
92
diff
changeset
|
42 _info->layout()->setContentsMargins(0, 0, 0, 0); |
83 | 43 main_layout->addWidget(_info.get()); |
80 | 44 |
83 | 45 /* "sidebar", includes... just the anime image :) */ |
46 _sidebar.reset(new QWidget(this)); | |
47 QVBoxLayout* sidebar_layout = new QVBoxLayout(_sidebar.get()); | |
48 sidebar_layout->setContentsMargins(0, 0, 0, 0); | |
80 | 49 |
83 | 50 _poster.reset(new Poster(_sidebar.get())); |
51 sidebar_layout->addWidget(_poster.get()); | |
52 | |
53 sidebar_layout->addStretch(); | |
54 | |
55 layout->addWidget(_sidebar.get()); | |
56 layout->addWidget(_main.get()); | |
57 layout->setSpacing(10); | |
64 | 58 layout->setContentsMargins(0, 0, 0, 0); |
59 } | |
60 | |
69 | 61 int Playing::GetPlayingAnime() { |
62 return _id; | |
63 } | |
64 | |
154 | 65 void Playing::SetPlayingAnime(const Anime::Anime& anime, const anitomy::Elements& info) { |
258 | 66 if (_id == anime.GetId() |
67 && _episode == Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber)))) | |
79 | 68 return; |
83 | 69 _id = anime.GetId(); |
154 | 70 _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))); |
83 | 71 _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle())); |
72 _info->SetAnime(anime); | |
73 _poster->SetAnime(anime); | |
74 | |
75 updateGeometry(); | |
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
76 } |
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
77 |
64 | 78 } // namespace NowPlayingPages |
79 | |
80 NowPlayingPage::NowPlayingPage(QWidget* parent) : QFrame(parent) { | |
295 | 81 setBackgroundRole(QPalette::Base); |
64 | 82 QVBoxLayout* layout = new QVBoxLayout(this); |
83 | |
84 setFrameShape(QFrame::Box); | |
85 setFrameShadow(QFrame::Sunken); | |
86 setAutoFillBackground(true); | |
87 | |
88 stack = new QStackedWidget(this); | |
89 stack->addWidget(new NowPlayingPages::Default(stack)); | |
90 stack->addWidget(new NowPlayingPages::Playing(stack)); | |
91 layout->addWidget(stack); | |
92 | |
93 SetDefault(); | |
94 } | |
95 | |
96 void NowPlayingPage::SetDefault() { | |
97 stack->setCurrentIndex(0); | |
98 } | |
99 | |
69 | 100 int NowPlayingPage::GetPlayingId() { |
101 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); | |
102 } | |
103 | |
154 | 104 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) { |
83 | 105 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(anime, info); |
64 | 106 stack->setCurrentIndex(1); |
83 | 107 updateGeometry(); |
2 | 108 } |