Mercurial > minori
annotate src/gui/pages/now_playing.cc @ 154:d43d68408d3c
dep/animia: fix XnuFdTools
also we use anitomy directly now.
HG Enter commit message. Lines beginning with 'HG:' are removed.
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 15 Nov 2023 14:14:17 -0500 |
parents | 6d8da6e64d61 |
children | bc8d2ccff09c |
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" |
64 | 7 #include <QLabel> |
8 #include <QStackedWidget> | |
83 | 9 #include <QHBoxLayout> |
64 | 10 #include <QVBoxLayout> |
11 #include <QWidget> | |
12 | |
154 | 13 #include "anitomy/anitomy.h" |
14 | |
64 | 15 namespace NowPlayingPages { |
16 | |
17 class Default : public QWidget { | |
18 Q_OBJECT | |
19 | |
20 public: | |
21 Default(QWidget* parent = nullptr); | |
22 }; | |
23 | |
24 class Playing : public QWidget { | |
25 Q_OBJECT | |
26 | |
27 public: | |
28 Playing(QWidget* parent = nullptr); | |
154 | 29 void SetPlayingAnime(const Anime::Anime& anime, const anitomy::Elements& info); |
69 | 30 int GetPlayingAnime(); |
64 | 31 |
32 private: | |
69 | 33 int _id = 0; |
79 | 34 int _episode = 0; |
83 | 35 std::unique_ptr<QWidget> _main = nullptr; |
80 | 36 std::unique_ptr<TextWidgets::Title> _title = nullptr; |
37 std::unique_ptr<AnimeInfoWidget> _info = nullptr; | |
83 | 38 std::unique_ptr<QWidget> _sidebar = nullptr; |
39 std::unique_ptr<Poster> _poster = nullptr; | |
64 | 40 }; |
41 | |
42 Default::Default(QWidget* parent) : QWidget(parent) { | |
43 QVBoxLayout* layout = new QVBoxLayout(this); | |
44 layout->setContentsMargins(0, 0, 0, 0); | |
2 | 45 |
80 | 46 TextWidgets::Title* title = new TextWidgets::Title(tr("Now Playing"), this); |
47 layout->addWidget(title); | |
48 | |
64 | 49 layout->addStretch(); |
50 } | |
51 | |
52 Playing::Playing(QWidget* parent) : QWidget(parent) { | |
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
53 QHBoxLayout* layout = new QHBoxLayout(this); |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
54 |
83 | 55 _main.reset(new QWidget(this)); |
56 _main->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
57 | |
58 QVBoxLayout* main_layout = new QVBoxLayout(_main.get()); | |
59 main_layout->setContentsMargins(0, 0, 0, 0); | |
60 | |
61 _title.reset(new TextWidgets::Title("", _main.get())); | |
62 main_layout->addWidget(_title.get()); | |
63 | |
64 _info.reset(new AnimeInfoWidget(_main.get())); | |
65 _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
|
66 _info->layout()->setContentsMargins(0, 0, 0, 0); |
83 | 67 main_layout->addWidget(_info.get()); |
80 | 68 |
83 | 69 /* "sidebar", includes... just the anime image :) */ |
70 _sidebar.reset(new QWidget(this)); | |
71 QVBoxLayout* sidebar_layout = new QVBoxLayout(_sidebar.get()); | |
72 sidebar_layout->setContentsMargins(0, 0, 0, 0); | |
80 | 73 |
83 | 74 _poster.reset(new Poster(_sidebar.get())); |
75 sidebar_layout->addWidget(_poster.get()); | |
76 | |
77 sidebar_layout->addStretch(); | |
78 | |
79 layout->addWidget(_sidebar.get()); | |
80 layout->addWidget(_main.get()); | |
81 layout->setSpacing(10); | |
64 | 82 layout->setContentsMargins(0, 0, 0, 0); |
83 } | |
84 | |
69 | 85 int Playing::GetPlayingAnime() { |
86 return _id; | |
87 } | |
88 | |
154 | 89 void Playing::SetPlayingAnime(const Anime::Anime& anime, const anitomy::Elements& info) { |
90 if (_id == anime.GetId() && _episode == Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber)))) | |
79 | 91 return; |
83 | 92 _id = anime.GetId(); |
154 | 93 _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))); |
83 | 94 _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle())); |
95 _info->SetAnime(anime); | |
96 _poster->SetAnime(anime); | |
97 | |
98 updateGeometry(); | |
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
99 } |
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
100 |
64 | 101 } // namespace NowPlayingPages |
102 | |
103 NowPlayingPage::NowPlayingPage(QWidget* parent) : QFrame(parent) { | |
104 QVBoxLayout* layout = new QVBoxLayout(this); | |
105 | |
106 setFrameShape(QFrame::Box); | |
107 setFrameShadow(QFrame::Sunken); | |
108 setAutoFillBackground(true); | |
109 | |
110 stack = new QStackedWidget(this); | |
111 stack->addWidget(new NowPlayingPages::Default(stack)); | |
112 stack->addWidget(new NowPlayingPages::Playing(stack)); | |
113 layout->addWidget(stack); | |
114 | |
115 SetDefault(); | |
116 } | |
117 | |
118 void NowPlayingPage::SetDefault() { | |
119 stack->setCurrentIndex(0); | |
120 } | |
121 | |
69 | 122 int NowPlayingPage::GetPlayingId() { |
123 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); | |
124 } | |
125 | |
154 | 126 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) { |
83 | 127 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(anime, info); |
64 | 128 stack->setCurrentIndex(1); |
83 | 129 updateGeometry(); |
2 | 130 } |
7 | 131 |
46 | 132 #include "gui/pages/moc_now_playing.cpp" |
64 | 133 #include "now_playing.moc" |