Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/src/gui/pages/now_playing.cc Sun Jun 23 10:32:09 2024 -0400 +++ b/src/gui/pages/now_playing.cc Tue Jun 25 11:19:54 2024 -0400 @@ -19,8 +19,8 @@ QVBoxLayout* layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); - TextWidgets::Title* title = new TextWidgets::Title(tr("Now Playing"), this); - layout->addWidget(title); + title_.SetText(Strings::Translate("Now Playing")); + layout->addWidget(&title_); layout->addStretch(); } @@ -28,32 +28,27 @@ Playing::Playing(QWidget* parent) : QWidget(parent) { QHBoxLayout* layout = new QHBoxLayout(this); - _main.reset(new QWidget(this)); - _main->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + _main.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - QVBoxLayout* main_layout = new QVBoxLayout(_main.get()); + QVBoxLayout* main_layout = new QVBoxLayout(&_main); main_layout->setContentsMargins(0, 0, 0, 0); - _title.reset(new TextWidgets::Title("", _main.get())); - main_layout->addWidget(_title.get()); + main_layout->addWidget(&_title); - _info.reset(new AnimeInfoWidget(_main.get())); - _info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - _info->layout()->setContentsMargins(0, 0, 0, 0); - main_layout->addWidget(_info.get()); + _info.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + _info.layout()->setContentsMargins(0, 0, 0, 0); + main_layout->addWidget(&_info); /* "sidebar", includes... just the anime image :) */ - _sidebar.reset(new QWidget(this)); - QVBoxLayout* sidebar_layout = new QVBoxLayout(_sidebar.get()); + QVBoxLayout* sidebar_layout = new QVBoxLayout(&_sidebar); sidebar_layout->setContentsMargins(0, 0, 0, 0); - _poster.reset(new Poster(_sidebar.get())); - sidebar_layout->addWidget(_poster.get()); + sidebar_layout->addWidget(&_poster); sidebar_layout->addStretch(); - layout->addWidget(_sidebar.get()); - layout->addWidget(_main.get()); + layout->addWidget(&_sidebar); + layout->addWidget(&_main); layout->setSpacing(10); layout->setContentsMargins(0, 0, 0, 0); } @@ -68,9 +63,9 @@ return; _id = anime.GetId(); _episode = Strings::ToInt(Strings::ToUtf8String(info.get(anitomy::kElementEpisodeNumber))); - _title->SetText(Strings::ToQString(anime.GetUserPreferredTitle())); - _info->SetAnime(anime); - _poster->SetAnime(anime); + _title.SetText(anime.GetUserPreferredTitle()); + _info.SetAnime(anime); + _poster.SetAnime(anime); updateGeometry(); } @@ -85,24 +80,23 @@ setFrameShadow(QFrame::Sunken); setAutoFillBackground(true); - stack = new QStackedWidget(this); - stack->addWidget(new NowPlayingPages::Default(stack)); - stack->addWidget(new NowPlayingPages::Playing(stack)); - layout->addWidget(stack); + stack_.addWidget(&default_); + stack_.addWidget(&playing_); + layout->addWidget(&stack_); SetDefault(); } void NowPlayingPage::SetDefault() { - stack->setCurrentIndex(0); + stack_.setCurrentIndex(static_cast<int>(Subpages::Default)); } int NowPlayingPage::GetPlayingId() { - return reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime(); + return playing_.GetPlayingAnime(); } void NowPlayingPage::SetPlaying(const Anime::Anime& anime, const anitomy::Elements& info) { - reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(anime, info); - stack->setCurrentIndex(1); + playing_.SetPlayingAnime(anime, info); + stack_.setCurrentIndex(static_cast<int>(Subpages::Playing)); updateGeometry(); }