changeset 73:f1fc8b04bc63

...: merge heads
author Paper <mrpapersonic@gmail.com>
date Tue, 03 Oct 2023 05:00:08 -0400
parents 893ad99b174d (current diff) 5f9bdcea3d01 (diff)
children 5ccb99bfa605
files
diffstat 13 files changed, 91 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/include/gui/dialog/settings.h	Tue Oct 03 04:58:38 2023 -0400
+++ b/include/gui/dialog/settings.h	Tue Oct 03 05:00:08 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
--- a/include/gui/pages/now_playing.h	Tue Oct 03 04:58:38 2023 -0400
+++ b/include/gui/pages/now_playing.h	Tue Oct 03 05:00:08 2023 -0400
@@ -11,6 +11,7 @@
 		NowPlayingPage(QWidget* parent = nullptr);
 		void SetDefault();
 		void SetPlaying(int id);
+		int GetPlayingId();
 
 	private:
 		QStackedWidget* stack;
--- a/include/gui/widgets/sidebar.h	Tue Oct 03 04:58:38 2023 -0400
+++ b/include/gui/widgets/sidebar.h	Tue Oct 03 05:00:08 2023 -0400
@@ -1,8 +1,10 @@
 #ifndef __gui__sidebar_h
 #define __gui__sidebar_h
+
 #include <QItemSelectionModel>
 #include <QListWidget>
 #include <QListWidgetItem>
+
 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
--- a/include/gui/widgets/text.h	Tue Oct 03 04:58:38 2023 -0400
+++ b/include/gui/widgets/text.h	Tue Oct 03 05:00:08 2023 -0400
@@ -1,12 +1,13 @@
 #ifndef __gui__ui_utils_h
 #define __gui__ui_utils_h
 
-#include <QFrame>
-#include <QLabel>
+#include <QWidget>
+#include <QString>
+#include <QSize>
 #include <QPlainTextEdit>
-#include <QSize>
-#include <QString>
-#include <QWidget>
+
+class QFrame;
+class QLabel;
 
 namespace TextWidgets {
 
--- a/rc/icons.qrc	Tue Oct 03 04:58:38 2023 -0400
+++ b/rc/icons.qrc	Tue Oct 03 05:00:08 2023 -0400
@@ -7,6 +7,7 @@
 		<file>icons/16x16/feed.png</file>
 		<file>icons/16x16/film.png</file>
 		<file>icons/16x16/magnifier.png</file>
+		<file>icons/24x24/application-export.png</file>
 		<file>icons/24x24/application-sidebar-list.png</file>
 		<file>icons/24x24/arrow-circle-double-135.png</file>
 		<file>icons/24x24/feed.png</file>
Binary file rc/icons/24x24/application-export.png has changed
--- a/src/gui/dialog/information.cpp	Tue Oct 03 04:58:38 2023 -0400
+++ b/src/gui/dialog/information.cpp	Tue Oct 03 05:00:08 2023 -0400
@@ -18,6 +18,7 @@
 #include <QLineEdit>
 #include <QPlainTextEdit>
 #include <QSpinBox>
+#include <QLabel>
 #include <QStringList>
 #include <QTextStream>
 #include <QVBoxLayout>
@@ -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` */
--- a/src/gui/dialog/settings.cpp	Tue Oct 03 04:58:38 2023 -0400
+++ b/src/gui/dialog/settings.cpp	Tue Oct 03 05:00:08 2023 -0400
@@ -6,6 +6,7 @@
 #include <QVBoxLayout>
 #include <QHBoxLayout>
 #include <QWidget>
+#include <QLabel>
 
 SettingsPage::SettingsPage(QWidget* parent, QString title) : QWidget(parent) {
 	setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
@@ -51,7 +52,6 @@
 }
 
 void SettingsDialog::OnOK() {
-	QStackedWidget* stacked = reinterpret_cast<QStackedWidget*>(layout()->itemAt(1)->widget());
 	for (int i = 0; i < stacked->count(); i++) {
 		reinterpret_cast<SettingsPage*>(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);
--- a/src/gui/pages/anime_list.cpp	Tue Oct 03 04:58:38 2023 -0400
+++ b/src/gui/pages/anime_list.cpp	Tue Oct 03 05:00:08 2023 -0400
@@ -475,6 +475,7 @@
 			tree_view->setModel(sort_models[index]);
 	});
 
+	SetColumnDefaults();
 	setFocusPolicy(Qt::TabFocus);
 	setFocusProxy(tab_bar);
 }
--- a/src/gui/pages/now_playing.cpp	Tue Oct 03 04:58:38 2023 -0400
+++ b/src/gui/pages/now_playing.cpp	Tue Oct 03 05:00:08 2023 -0400
@@ -22,8 +22,10 @@
 	public:
 		Playing(QWidget* parent = nullptr);
 		void SetPlayingAnime(int id);
+		int GetPlayingAnime();
 
 	private:
+		int _id = 0;
 		std::unique_ptr<AnimeInfoWidget> 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<NowPlayingPages::Playing*>(stack->widget(1))->GetPlayingAnime();
+}
+
 void NowPlayingPage::SetPlaying(int id) {
 	reinterpret_cast<NowPlayingPages::Playing*>(stack->widget(1))->SetPlayingAnime(id);
 	stack->setCurrentIndex(1);
--- a/src/gui/widgets/sidebar.cpp	Tue Oct 03 04:58:38 2023 -0400
+++ b/src/gui/widgets/sidebar.cpp	Tue Oct 03 05:00:08 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,13 @@
 	setCurrentRow(AddSeparatorsToIndex(index));
 }
 
+void SideBar::SetBackgroundColor(QColor color) {
+	viewport()->setAutoFillBackground(color != Qt::transparent);
+	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);
--- a/src/gui/window.cpp	Tue Oct 03 04:58:38 2023 -0400
+++ b/src/gui/window.cpp	Tue Oct 03 05:00:08 2023 -0400
@@ -20,15 +20,16 @@
 #include <QApplication>
 #include <QDebug>
 #include <QFile>
+#include <QHBoxLayout>
 #include <QMainWindow>
 #include <QMenuBar>
-#include <QToolBar>
 #include <QMessageBox>
 #include <QPlainTextEdit>
 #include <QStackedWidget>
 #include <QTextStream>
 #include <QTimer>
-#include <QHBoxLayout>
+#include <QToolBar>
+#include <QToolButton>
 #if MACOSX
 #	include "sys/osx/dark_theme.h"
 #elif defined(WIN32)
@@ -203,7 +204,29 @@
 		reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(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);
--- a/src/services/anilist.cpp	Tue Oct 03 04:58:38 2023 -0400
+++ b/src/services/anilist.cpp	Tue Oct 03 05:00:08 2023 -0400
@@ -98,20 +98,22 @@
 }
 
 std::string ListStatusToString(const Anime::Anime& anime) {
-	std::unordered_map<Anime::ListStatus, std::string> map = {
-	    {Anime::ListStatus::CURRENT,   "CURRENT"  },
-	    {Anime::ListStatus::PLANNING,  "PLANNING" },
-	    {Anime::ListStatus::COMPLETED, "COMPLETED"},
-	    {Anime::ListStatus::DROPPED,   "DROPPED"  },
-	    {Anime::ListStatus::PAUSED,    "PAUSED"   }
-    };
-
 	if (anime.GetUserIsRewatching())
 		return "REWATCHING";
 
-	if (map.find(anime.GetUserStatus()) == map.end())
-		return "CURRENT";
-	return map[anime.GetUserStatus()];
+	switch (anime.GetUserStatus()) {
+		case Anime::ListStatus::PLANNING:
+			return "PLANNING";
+		case Anime::ListStatus::COMPLETED:
+			return "COMPLETED";
+		case Anime::ListStatus::DROPPED:
+			return "DROPPED";
+		case Anime::ListStatus::PAUSED:
+			return "PAUSED";
+		default:
+			break;
+	}
+	return "CURRENT";
 }
 
 Date ParseDate(const nlohmann::json& json) {