Mercurial > minori
annotate src/gui/pages/now_playing.cc @ 255:fe702c8f161f
*: whatever
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 07 Feb 2024 17:04:06 -0500 |
parents | 4d461ef7d424 |
children | 862d0d8619f6 |
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" |
5 #include "gui/widgets/text.h" | |
83 | 6 #include "gui/widgets/poster.h" |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
154
diff
changeset
|
7 |
64 | 8 #include <QLabel> |
9 #include <QStackedWidget> | |
83 | 10 #include <QHBoxLayout> |
64 | 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) { |
66 if (_id == anime.GetId() && _episode == Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber)))) | |
79 | 67 return; |
83 | 68 _id = anime.GetId(); |
154 | 69 _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))); |
83 | 70 _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle())); |
71 _info->SetAnime(anime); | |
72 _poster->SetAnime(anime); | |
73 | |
74 updateGeometry(); | |
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
75 } |
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
76 |
64 | 77 } // namespace NowPlayingPages |
78 | |
79 NowPlayingPage::NowPlayingPage(QWidget* parent) : QFrame(parent) { | |
80 QVBoxLayout* layout = new QVBoxLayout(this); | |
81 | |
82 setFrameShape(QFrame::Box); | |
83 setFrameShadow(QFrame::Sunken); | |
84 setAutoFillBackground(true); | |
85 | |
86 stack = new QStackedWidget(this); | |
87 stack->addWidget(new NowPlayingPages::Default(stack)); | |
88 stack->addWidget(new NowPlayingPages::Playing(stack)); | |
89 layout->addWidget(stack); | |
90 | |
91 SetDefault(); | |
92 } | |
93 | |
94 void NowPlayingPage::SetDefault() { | |
95 stack->setCurrentIndex(0); | |
96 } | |
97 | |
69 | 98 int NowPlayingPage::GetPlayingId() { |
99 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); | |
100 } | |
101 | |
154 | 102 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) { |
83 | 103 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(anime, info); |
64 | 104 stack->setCurrentIndex(1); |
83 | 105 updateGeometry(); |
2 | 106 } |