9
|
1 #include "gui/pages/now_playing.h"
|
64
|
2 #include "core/anime_db.h"
|
|
3 #include "gui/widgets/anime_info.h"
|
|
4 #include "gui/widgets/text.h"
|
|
5 #include <QLabel>
|
|
6 #include <QStackedWidget>
|
|
7 #include <QVBoxLayout>
|
|
8 #include <QWidget>
|
|
9
|
|
10 namespace NowPlayingPages {
|
|
11
|
|
12 class Default : public QWidget {
|
|
13 Q_OBJECT
|
|
14
|
|
15 public:
|
|
16 Default(QWidget* parent = nullptr);
|
|
17 };
|
|
18
|
|
19 class Playing : public QWidget {
|
|
20 Q_OBJECT
|
|
21
|
|
22 public:
|
|
23 Playing(QWidget* parent = nullptr);
|
|
24
|
|
25 void SetPlayingAnime(int id) {
|
|
26 if (info.get())
|
|
27 layout()->removeWidget(info.get());
|
|
28 info.reset(new AnimeInfoWidget(Anime::db.items[id]));
|
|
29 layout()->addWidget(info.get());
|
|
30 }
|
|
31
|
|
32 private:
|
|
33 std::unique_ptr<AnimeInfoWidget> info = nullptr;
|
|
34 };
|
|
35
|
|
36 Default::Default(QWidget* parent) : QWidget(parent) {
|
|
37 QVBoxLayout* layout = new QVBoxLayout(this);
|
|
38 layout->setContentsMargins(0, 0, 0, 0);
|
2
|
39
|
64
|
40 layout->addStretch();
|
|
41 }
|
|
42
|
|
43 Playing::Playing(QWidget* parent) : QWidget(parent) {
|
|
44 QVBoxLayout* layout = new QVBoxLayout(this);
|
|
45 layout->setContentsMargins(0, 0, 0, 0);
|
|
46 }
|
|
47
|
|
48 } // namespace NowPlayingPages
|
|
49
|
|
50 NowPlayingPage::NowPlayingPage(QWidget* parent) : QFrame(parent) {
|
|
51 QVBoxLayout* layout = new QVBoxLayout(this);
|
|
52
|
|
53 setFrameShape(QFrame::Box);
|
|
54 setFrameShadow(QFrame::Sunken);
|
|
55
|
|
56 QPalette pal = QPalette();
|
|
57 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
|
|
58 setPalette(pal);
|
|
59 setAutoFillBackground(true);
|
|
60
|
|
61 TextWidgets::Title* title = new TextWidgets::Title(tr("Now Playing"), this);
|
|
62 layout->addWidget(title);
|
|
63
|
|
64 stack = new QStackedWidget(this);
|
|
65 stack->addWidget(new NowPlayingPages::Default(stack));
|
|
66 stack->addWidget(new NowPlayingPages::Playing(stack));
|
|
67 layout->addWidget(stack);
|
|
68
|
|
69 layout->addStretch();
|
|
70 SetDefault();
|
|
71 }
|
|
72
|
|
73 void NowPlayingPage::SetDefault() {
|
|
74 stack->setCurrentIndex(0);
|
|
75 }
|
|
76
|
|
77 void NowPlayingPage::SetPlaying(int id) {
|
|
78 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(id);
|
|
79 stack->setCurrentIndex(1);
|
2
|
80 }
|
7
|
81
|
46
|
82 #include "gui/pages/moc_now_playing.cpp"
|
64
|
83 #include "now_playing.moc"
|