# HG changeset patch # User Paper # Date 1696318705 14400 # Node ID 27a19dd6cba19178e6bf592fee276bad3fd1ad14 # Parent 2417121d894ecb26eb6aaf366dd3e2444caac97b *: fix up some stuff settings: due to my own incompetence OnOK caused the entire program to crash, now that's fixed :) diff -r 2417121d894e -r 27a19dd6cba1 include/gui/dialog/settings.h --- a/include/gui/dialog/settings.h Mon Oct 02 21:33:25 2023 -0400 +++ b/include/gui/dialog/settings.h Tue Oct 03 03:38:25 2023 -0400 @@ -6,6 +6,7 @@ class QLabel; class QTabWidget; +class QStackedWidget; class SideBar; class SettingsPage : public QWidget { @@ -58,5 +59,6 @@ private: SideBar* sidebar; + QStackedWidget* stacked; }; #endif // __gui__dialog__settings_h diff -r 2417121d894e -r 27a19dd6cba1 include/gui/pages/now_playing.h --- a/include/gui/pages/now_playing.h Mon Oct 02 21:33:25 2023 -0400 +++ b/include/gui/pages/now_playing.h Tue Oct 03 03:38:25 2023 -0400 @@ -11,6 +11,7 @@ NowPlayingPage(QWidget* parent = nullptr); void SetDefault(); void SetPlaying(int id); + int GetPlayingId(); private: QStackedWidget* stack; diff -r 2417121d894e -r 27a19dd6cba1 include/gui/widgets/sidebar.h --- a/include/gui/widgets/sidebar.h Mon Oct 02 21:33:25 2023 -0400 +++ b/include/gui/widgets/sidebar.h Tue Oct 03 03:38:25 2023 -0400 @@ -1,8 +1,10 @@ #ifndef __gui__sidebar_h #define __gui__sidebar_h + #include #include #include + class SideBar : public QListWidget { Q_OBJECT @@ -12,6 +14,7 @@ QListWidgetItem* AddSeparator(); bool IndexIsSeparator(QModelIndex index) const; static QIcon CreateIcon(const char* file); + void SetBackgroundColor(QColor color); signals: void CurrentItemChanged(int index); @@ -26,4 +29,5 @@ int RemoveSeparatorsFromIndex(int index); int AddSeparatorsToIndex(int index); }; + #endif // __gui__sidebar_h diff -r 2417121d894e -r 27a19dd6cba1 include/gui/widgets/text.h --- a/include/gui/widgets/text.h Mon Oct 02 21:33:25 2023 -0400 +++ b/include/gui/widgets/text.h Tue Oct 03 03:38:25 2023 -0400 @@ -1,12 +1,13 @@ #ifndef __gui__ui_utils_h #define __gui__ui_utils_h -#include -#include +#include +#include +#include #include -#include -#include -#include + +class QFrame; +class QLabel; namespace TextWidgets { diff -r 2417121d894e -r 27a19dd6cba1 rc/icons.qrc --- a/rc/icons.qrc Mon Oct 02 21:33:25 2023 -0400 +++ b/rc/icons.qrc Tue Oct 03 03:38:25 2023 -0400 @@ -7,6 +7,7 @@ icons/16x16/feed.png icons/16x16/film.png icons/16x16/magnifier.png + icons/24x24/application-export.png icons/24x24/application-sidebar-list.png icons/24x24/arrow-circle-double-135.png icons/24x24/feed.png diff -r 2417121d894e -r 27a19dd6cba1 rc/icons/24x24/application-export.png Binary file rc/icons/24x24/application-export.png has changed diff -r 2417121d894e -r 27a19dd6cba1 src/gui/dialog/information.cpp --- a/src/gui/dialog/information.cpp Mon Oct 02 21:33:25 2023 -0400 +++ b/src/gui/dialog/information.cpp Tue Oct 03 03:38:25 2023 -0400 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -43,8 +44,8 @@ setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); { - QPalette pal; - pal.setColor(QPalette::Window, Qt::white); + QPalette pal(palette()); + pal.setColor(QPalette::Window, pal.color(QPalette::Base)); setPalette(pal); } @@ -61,12 +62,6 @@ /* main widget */ QWidget* main_widget = new QWidget(widget); - { - QPalette pal; - pal.setColor(QPalette::Window, Qt::white); - main_widget->setPalette(pal); - } - main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); id = anime.GetId(); @@ -81,6 +76,12 @@ /* main info tab */ AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(anime, tabbed_widget); + { + QPalette pal(main_information_widget->palette()); + pal.setColor(QPalette::Base, pal.color(QPalette::Window)); + main_information_widget->setPalette(pal); + } + QWidget* settings_widget = new QWidget(tabbed_widget); settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); @@ -105,7 +106,7 @@ subsection_layout->setSpacing(LAYOUT_VERT_SPACING); \ subsection_layout->setContentsMargins(0, 0, 0, 0); \ x; \ - layout->addWidget(subsection); \ + layout->addWidget(subsection, 0, Qt::AlignBottom); \ } /* Creates a section in the parent `a` */ diff -r 2417121d894e -r 27a19dd6cba1 src/gui/dialog/settings.cpp --- a/src/gui/dialog/settings.cpp Mon Oct 02 21:33:25 2023 -0400 +++ b/src/gui/dialog/settings.cpp Tue Oct 03 03:38:25 2023 -0400 @@ -6,6 +6,7 @@ #include #include #include +#include SettingsPage::SettingsPage(QWidget* parent, QString title) : QWidget(parent) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); @@ -51,7 +52,6 @@ } void SettingsDialog::OnOK() { - QStackedWidget* stacked = reinterpret_cast(layout()->itemAt(1)->widget()); for (int i = 0; i < stacked->count(); i++) { reinterpret_cast(stacked->widget(i))->SaveInfo(); } @@ -80,13 +80,12 @@ sidebar->setFont(font); QPalette pal(sidebar->palette()); - pal.setColor(QPalette::Base, pal.color(QPalette::Window)); - sidebar->setPalette(pal); + sidebar->SetBackgroundColor(pal.color(QPalette::Base)); sidebar->setFixedWidth(158); sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - QStackedWidget* stacked = new QStackedWidget(this); + stacked = new QStackedWidget(this); stacked->addWidget(new SettingsPageServices(stacked)); stacked->addWidget(new SettingsPageApplication(stacked)); stacked->setCurrentIndex(0); diff -r 2417121d894e -r 27a19dd6cba1 src/gui/pages/anime_list.cpp --- a/src/gui/pages/anime_list.cpp Mon Oct 02 21:33:25 2023 -0400 +++ b/src/gui/pages/anime_list.cpp Tue Oct 03 03:38:25 2023 -0400 @@ -475,6 +475,7 @@ tree_view->setModel(sort_models[index]); }); + SetColumnDefaults(); setFocusPolicy(Qt::TabFocus); setFocusProxy(tab_bar); } diff -r 2417121d894e -r 27a19dd6cba1 src/gui/pages/now_playing.cpp --- a/src/gui/pages/now_playing.cpp Mon Oct 02 21:33:25 2023 -0400 +++ b/src/gui/pages/now_playing.cpp Tue Oct 03 03:38:25 2023 -0400 @@ -22,8 +22,10 @@ public: Playing(QWidget* parent = nullptr); void SetPlayingAnime(int id); + int GetPlayingAnime(); private: + int _id = 0; std::unique_ptr info = nullptr; }; @@ -40,11 +42,17 @@ layout->setContentsMargins(0, 0, 0, 0); } +int Playing::GetPlayingAnime() { + return _id; +} + void Playing::SetPlayingAnime(int id) { if (info.get()) layout()->removeWidget(info.get()); - info.reset(new AnimeInfoWidget(Anime::db.items[id])); - layout()->addWidget(info.get()); + if (Anime::db.items.find(id) != Anime::db.items.end()) { + info.reset(new AnimeInfoWidget(Anime::db.items[_id = id])); + layout()->addWidget(info.get()); + } } } // namespace NowPlayingPages @@ -75,6 +83,10 @@ stack->setCurrentIndex(0); } +int NowPlayingPage::GetPlayingId() { + return reinterpret_cast(stack->widget(1))->GetPlayingAnime(); +} + void NowPlayingPage::SetPlaying(int id) { reinterpret_cast(stack->widget(1))->SetPlayingAnime(id); stack->setCurrentIndex(1); diff -r 2417121d894e -r 27a19dd6cba1 src/gui/widgets/sidebar.cpp --- a/src/gui/widgets/sidebar.cpp Mon Oct 02 21:33:25 2023 -0400 +++ b/src/gui/widgets/sidebar.cpp Tue Oct 03 03:38:25 2023 -0400 @@ -15,7 +15,8 @@ setMouseTracking(true); /* FIXME: is there an easy way to do this with palettes? */ setStyleSheet("QListWidget::item:disabled { background: transparent }"); - viewport()->setAutoFillBackground(false); + + SetBackgroundColor(Qt::transparent); QFont font; font.setPointSize(9); @@ -29,6 +30,12 @@ setCurrentRow(AddSeparatorsToIndex(index)); } +void SideBar::SetBackgroundColor(QColor color) { + QPalette pal(palette()); + pal.setColor(QPalette::Window, color); + setPalette(pal); +} + QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) { QListWidgetItem* item = new QListWidgetItem(this); item->setText(name); diff -r 2417121d894e -r 27a19dd6cba1 src/gui/window.cpp --- a/src/gui/window.cpp Mon Oct 02 21:33:25 2023 -0400 +++ b/src/gui/window.cpp Tue Oct 03 03:38:25 2023 -0400 @@ -20,15 +20,16 @@ #include #include #include +#include #include #include -#include #include #include #include #include #include -#include +#include +#include #if MACOSX # include "sys/osx/dark_theme.h" #elif defined(WIN32) @@ -203,7 +204,29 @@ reinterpret_cast(stack->widget(static_cast(Pages::ANIME_LIST)))->Refresh(); }); toolbar->addSeparator(); - toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this]{ + + QToolButton* button = new QToolButton(toolbar); + + menu = new QMenu(button); + action = menu->addAction(tr("Add new folder...")); + + button->setMenu(menu); + button->setIcon(QIcon(":/icons/24x24/folder-open.png")); + button->setPopupMode(QToolButton::InstantPopup); + toolbar->addWidget(button); + + button = new QToolButton(toolbar); + + menu = new QMenu(button); + action = menu->addAction(tr("Placeholder")); + + button->setMenu(menu); + button->setIcon(QIcon(":/icons/24x24/application-export.png")); + button->setPopupMode(QToolButton::InstantPopup); + toolbar->addWidget(button); + + toolbar->addSeparator(); + toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this] { SettingsDialog dialog(this); dialog.exec(); }); @@ -225,7 +248,7 @@ page->SetDefault(); return; } - + page->SetPlaying(id); }); timer->start(5000);