Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
347:a0aa8c8c4307 | 348:6b0768158dcd |
---|---|
17 | 17 |
18 Default::Default(QWidget* parent) : QWidget(parent) { | 18 Default::Default(QWidget* parent) : QWidget(parent) { |
19 QVBoxLayout* layout = new QVBoxLayout(this); | 19 QVBoxLayout* layout = new QVBoxLayout(this); |
20 layout->setContentsMargins(0, 0, 0, 0); | 20 layout->setContentsMargins(0, 0, 0, 0); |
21 | 21 |
22 TextWidgets::Title* title = new TextWidgets::Title(tr("Now Playing"), this); | 22 title_.SetText(Strings::Translate("Now Playing")); |
23 layout->addWidget(title); | 23 layout->addWidget(&title_); |
24 | 24 |
25 layout->addStretch(); | 25 layout->addStretch(); |
26 } | 26 } |
27 | 27 |
28 Playing::Playing(QWidget* parent) : QWidget(parent) { | 28 Playing::Playing(QWidget* parent) : QWidget(parent) { |
29 QHBoxLayout* layout = new QHBoxLayout(this); | 29 QHBoxLayout* layout = new QHBoxLayout(this); |
30 | 30 |
31 _main.reset(new QWidget(this)); | 31 _main.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
32 _main->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
33 | 32 |
34 QVBoxLayout* main_layout = new QVBoxLayout(_main.get()); | 33 QVBoxLayout* main_layout = new QVBoxLayout(&_main); |
35 main_layout->setContentsMargins(0, 0, 0, 0); | 34 main_layout->setContentsMargins(0, 0, 0, 0); |
36 | 35 |
37 _title.reset(new TextWidgets::Title("", _main.get())); | 36 main_layout->addWidget(&_title); |
38 main_layout->addWidget(_title.get()); | |
39 | 37 |
40 _info.reset(new AnimeInfoWidget(_main.get())); | 38 _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
41 _info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | 39 _info.layout()->setContentsMargins(0, 0, 0, 0); |
42 _info->layout()->setContentsMargins(0, 0, 0, 0); | 40 main_layout->addWidget(&_info); |
43 main_layout->addWidget(_info.get()); | |
44 | 41 |
45 /* "sidebar", includes... just the anime image :) */ | 42 /* "sidebar", includes... just the anime image :) */ |
46 _sidebar.reset(new QWidget(this)); | 43 QVBoxLayout* sidebar_layout = new QVBoxLayout(&_sidebar); |
47 QVBoxLayout* sidebar_layout = new QVBoxLayout(_sidebar.get()); | |
48 sidebar_layout->setContentsMargins(0, 0, 0, 0); | 44 sidebar_layout->setContentsMargins(0, 0, 0, 0); |
49 | 45 |
50 _poster.reset(new Poster(_sidebar.get())); | 46 sidebar_layout->addWidget(&_poster); |
51 sidebar_layout->addWidget(_poster.get()); | |
52 | 47 |
53 sidebar_layout->addStretch(); | 48 sidebar_layout->addStretch(); |
54 | 49 |
55 layout->addWidget(_sidebar.get()); | 50 layout->addWidget(&_sidebar); |
56 layout->addWidget(_main.get()); | 51 layout->addWidget(&_main); |
57 layout->setSpacing(10); | 52 layout->setSpacing(10); |
58 layout->setContentsMargins(0, 0, 0, 0); | 53 layout->setContentsMargins(0, 0, 0, 0); |
59 } | 54 } |
60 | 55 |
61 int Playing::GetPlayingAnime() { | 56 int Playing::GetPlayingAnime() { |
66 if (_id == anime.GetId() | 61 if (_id == anime.GetId() |
67 && _episode == Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber)))) | 62 && _episode == Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber)))) |
68 return; | 63 return; |
69 _id = anime.GetId(); | 64 _id = anime.GetId(); |
70 _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))); | 65 _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))); |
71 _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle())); | 66 _title.SetText(anime.GetUserPreferredTitle()); |
72 _info->SetAnime(anime); | 67 _info.SetAnime(anime); |
73 _poster->SetAnime(anime); | 68 _poster.SetAnime(anime); |
74 | 69 |
75 updateGeometry(); | 70 updateGeometry(); |
76 } | 71 } |
77 | 72 |
78 } // namespace NowPlayingPages | 73 } // namespace NowPlayingPages |
83 | 78 |
84 setFrameShape(QFrame::Box); | 79 setFrameShape(QFrame::Box); |
85 setFrameShadow(QFrame::Sunken); | 80 setFrameShadow(QFrame::Sunken); |
86 setAutoFillBackground(true); | 81 setAutoFillBackground(true); |
87 | 82 |
88 stack = new QStackedWidget(this); | 83 stack_.addWidget(&default_); |
89 stack->addWidget(new NowPlayingPages::Default(stack)); | 84 stack_.addWidget(&playing_); |
90 stack->addWidget(new NowPlayingPages::Playing(stack)); | 85 layout->addWidget(&stack_); |
91 layout->addWidget(stack); | |
92 | 86 |
93 SetDefault(); | 87 SetDefault(); |
94 } | 88 } |
95 | 89 |
96 void NowPlayingPage::SetDefault() { | 90 void NowPlayingPage::SetDefault() { |
97 stack->setCurrentIndex(0); | 91 stack_.setCurrentIndex(static_cast<int>(Subpages::Default)); |
98 } | 92 } |
99 | 93 |
100 int NowPlayingPage::GetPlayingId() { | 94 int NowPlayingPage::GetPlayingId() { |
101 return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); | 95 return playing_.GetPlayingAnime(); |
102 } | 96 } |
103 | 97 |
104 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) { | 98 void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) { |
105 reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(anime, info); | 99 playing_.SetPlayingAnime(anime, info); |
106 stack->setCurrentIndex(1); | 100 stack_.setCurrentIndex(static_cast<int>(Subpages::Playing)); |
107 updateGeometry(); | 101 updateGeometry(); |
108 } | 102 } |