changeset 119:4eae379cb1ff

settings: add a very early recognition tab for configuring players and extensions
author Paper <mrpapersonic@gmail.com>
date Wed, 08 Nov 2023 13:50:00 -0500
parents 39521c47c7a3
children 275da698697d
files CMakeLists.txt include/gui/dialog/settings.h rc/icons.qrc rc/icons/16x16/plus-button.png src/gui/dialog/settings.cc src/gui/dialog/settings/recognition.cc src/gui/dialog/settings/torrents.cc
diffstat 7 files changed, 87 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Tue Nov 07 23:40:54 2023 -0500
+++ b/CMakeLists.txt	Wed Nov 08 13:50:00 2023 -0500
@@ -92,6 +92,7 @@
 	src/gui/dialog/settings/application.cc
 	src/gui/dialog/settings/services.cc
 	src/gui/dialog/settings/torrents.cc
+	src/gui/dialog/settings/recognition.cc
 
 	# Translate
 	src/gui/translate/anime.cc
--- a/include/gui/dialog/settings.h	Tue Nov 07 23:40:54 2023 -0500
+++ b/include/gui/dialog/settings.h	Wed Nov 08 13:50:00 2023 -0500
@@ -71,6 +71,18 @@
 		decltype(session.config.torrents.feed_link) feed_link;
 };
 
+class SettingsPageRecognition final : public SettingsPage {
+		Q_OBJECT
+
+	public:
+		SettingsPageRecognition(QWidget* parent = nullptr);
+		void SaveInfo() override;
+
+	private:
+		QWidget* CreatePlayersWidget();
+		decltype(session.recognition.players) players;
+};
+
 class SettingsDialog final : public QDialog {
 		Q_OBJECT
 
--- a/rc/icons.qrc	Tue Nov 07 23:40:54 2023 -0500
+++ b/rc/icons.qrc	Wed Nov 08 13:50:00 2023 -0500
@@ -12,6 +12,7 @@
 		<file>icons/16x16/gear.png</file>
 		<file>icons/16x16/magnifier.png</file>
 		<file>icons/16x16/navigation-270-button.png</file>
+		<file>icons/16x16/plus-button.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>
Binary file rc/icons/16x16/plus-button.png has changed
--- a/src/gui/dialog/settings.cc	Tue Nov 07 23:40:54 2023 -0500
+++ b/src/gui/dialog/settings.cc	Wed Nov 08 13:50:00 2023 -0500
@@ -90,7 +90,7 @@
 			sidebar->setCurrentItem(sidebar->AddItem(tr("Services"), SideBar::CreateIcon(":/icons/24x24/globe.png")));
 			// sidebar->AddItem(tr("Library"), SideBar::CreateIcon(":/icons/24x24/inbox-film.png"));
 			sidebar->AddItem(tr("Application"), SideBar::CreateIcon(":/icons/24x24/application-sidebar-list.png"));
-			// sidebar->AddItem(tr("Recognition"), SideBar::CreateIcon(":/icons/24x24/question.png"));
+			sidebar->AddItem(tr("Recognition"), SideBar::CreateIcon(":/icons/24x24/question.png"));
 			// sidebar->AddItem(tr("Sharing"), SideBar::CreateIcon(":/icons/24x24/megaphone.png"));
 			sidebar->AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/24x24/feed.png"));
 			// sidebar->AddItem(tr("Advanced"), SideBar::CreateIcon(":/icons/24x24/gear.png"));
@@ -110,6 +110,7 @@
 			stacked = new QStackedWidget(widget);
 			stacked->addWidget(new SettingsPageServices(stacked));
 			stacked->addWidget(new SettingsPageApplication(stacked));
+			stacked->addWidget(new SettingsPageRecognition(stacked));
 			stacked->addWidget(new SettingsPageTorrents(stacked));
 			stacked->setCurrentIndex(0);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gui/dialog/settings/recognition.cc	Wed Nov 08 13:50:00 2023 -0500
@@ -0,0 +1,70 @@
+#include "core/session.h"
+#include "core/strings.h"
+#include "gui/dialog/settings.h"
+#include "track/types.h"
+#include <QListWidget>
+#include <QListWidgetItem>
+#include <QGroupBox>
+#include <QLabel>
+#include <QSizePolicy>
+#include <QVBoxLayout>
+#include <algorithm>
+
+Q_DECLARE_METATYPE(Track::Types::MediaPlayer);
+
+QWidget* SettingsPageRecognition::CreatePlayersWidget() {
+	QWidget* result = new QWidget(this);
+	result->setAutoFillBackground(true);
+	result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
+
+	QVBoxLayout* full_layout = new QVBoxLayout(result);
+
+	{
+		/* URLs */
+		QGroupBox* group = new QGroupBox(tr("URLs"), result);
+		group->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
+
+		QVBoxLayout* group_layout = new QVBoxLayout(group);
+
+		{
+			/* Feed link */
+			QWidget* widget = new QWidget(group);
+			QVBoxLayout* widget_layout = new QVBoxLayout(widget);
+
+			{
+				QLabel* label = new QLabel(tr("Allowed media players:"), widget);
+				widget_layout->addWidget(label);
+			}
+
+			{
+				QListWidget* listwidget = new QListWidget(widget);
+				for (const auto& player : session.recognition.players) {
+					QListWidgetItem* item = new QListWidgetItem(listwidget);
+					item->setCheckState(player.GetEnabled() ? Qt::Checked : Qt::Unchecked);
+					item->setText(Strings::ToQString(player.GetName() + " (" + player.GetExecutable() + ")"));
+					{
+						QVariant v(QVariant::fromValue(player));
+						item->setData(Qt::UserRole, v);
+					}
+				}
+				widget_layout->addWidget(listwidget);
+			}
+
+			group_layout->addWidget(widget);
+		}
+
+		full_layout->addWidget(group);
+	}
+
+	full_layout->setSpacing(10);
+	full_layout->addStretch();
+
+	return result;
+}
+
+void SettingsPageRecognition::SaveInfo() {
+}
+
+SettingsPageRecognition::SettingsPageRecognition(QWidget* parent) : SettingsPage(parent, tr("Recognition")) {
+	AddTab(CreatePlayersWidget(), tr("Players"));
+}
--- a/src/gui/dialog/settings/torrents.cc	Tue Nov 07 23:40:54 2023 -0500
+++ b/src/gui/dialog/settings/torrents.cc	Wed Nov 08 13:50:00 2023 -0500
@@ -56,7 +56,7 @@
 	session.config.torrents.feed_link = feed_link;
 }
 
-SettingsPageTorrents::SettingsPageTorrents(QWidget* parent) : SettingsPage(parent, tr("Application")) {
+SettingsPageTorrents::SettingsPageTorrents(QWidget* parent) : SettingsPage(parent, tr("Torrents")) {
 	feed_link = session.config.torrents.feed_link;
 	AddTab(CreateGeneralWidget(), tr("General"));
 }