changeset 149:e41505d24733

players: filter out web browsers, they aren't even supported in animia yet
author Paper <mrpapersonic@gmail.com>
date Tue, 14 Nov 2023 13:40:11 -0500
parents aa4df5a84338
children ffa535b6d630
files include/core/config.h src/core/config.cc src/gui/dialog/settings/recognition.cc src/track/media.cc
diffstat 4 files changed, 29 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/include/core/config.h	Tue Nov 14 13:27:13 2023 -0500
+++ b/include/core/config.h	Tue Nov 14 13:40:11 2023 -0500
@@ -44,6 +44,8 @@
 		struct {
 			public:
 				bool detect_media_players;
+				/* preferably web browsers would be in a separate vector,
+				   but whatever :/ */
 				std::vector<std::pair<bool, animia::Player>> players;
 		} recognition;
 
--- a/src/core/config.cc	Tue Nov 14 13:27:13 2023 -0500
+++ b/src/core/config.cc	Tue Nov 14 13:40:11 2023 -0500
@@ -68,8 +68,17 @@
 			recognition.players.push_back({true, player});
 	}
 
-	for (auto& player : recognition.players)
-		player.first = INI::GetIniValue<bool>(ini, "Recognition/Players", player.second.name, true);
+	for (auto& [enabled, player] : recognition.players) {
+		switch (player.type) {
+			default:
+			case animia::PlayerType::Default:
+				enabled = INI::GetIniValue<bool>(ini, "Recognition/Players", player.name, true);
+				break;
+			case animia::PlayerType::WebBrowser:
+				enabled = INI::GetIniValue<bool>(ini, "Recognition/Browsers", player.name, true);
+				break;
+		}
+	}
 
 	/* ew */
 	locale.SetActiveLocale(QLocale(Strings::ToQString(INI::GetIniValue<std::string>(ini, "General", "Locale", "en_US"))));
@@ -104,8 +113,17 @@
 
 	INI::SetIniValue(ini, "Recognition", "Detect media players", recognition.detect_media_players);
 
-	for (const auto& player : recognition.players)
-		INI::SetIniValue(ini, "Recognition/Players", player.second.name, player.first);
+	for (const auto& [enabled, player] : recognition.players) {
+		switch (player.type) {
+			default:
+			case animia::PlayerType::Default:
+				INI::SetIniValue(ini, "Recognition/Players", player.name, enabled);
+				break;
+			case animia::PlayerType::WebBrowser:
+				INI::SetIniValue(ini, "Recognition/Browsers", player.name, enabled);
+				break;
+		}
+	}
 
 	file.write(ini);
 
--- a/src/gui/dialog/settings/recognition.cc	Tue Nov 14 13:27:13 2023 -0500
+++ b/src/gui/dialog/settings/recognition.cc	Tue Nov 14 13:40:11 2023 -0500
@@ -37,11 +37,11 @@
 		{
 			QListWidget* listwidget = new QListWidget(widget);
 			for (size_t i = 0; i < players.size(); i++) {
-				const auto& player = players[i];
-				{
+				const auto& [enabled, player] = players[i];
+				if (player.type == animia::PlayerType::Default) {
 					QListWidgetItem* item = new QListWidgetItem(listwidget);
-					item->setCheckState(player.first ? Qt::Checked : Qt::Unchecked);
-					item->setText(Strings::ToQString(player.second.name));
+					item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked);
+					item->setText(Strings::ToQString(player.name));
 					item->setData(Qt::UserRole, QVariant::fromValue(i));
 				}
 			}
--- a/src/track/media.cc	Tue Nov 14 13:27:13 2023 -0500
+++ b/src/track/media.cc	Tue Nov 14 13:40:11 2023 -0500
@@ -20,7 +20,7 @@
 
 	players.reserve(session.config.recognition.players.size());
 	for (const auto& [enabled, player] : session.config.recognition.players)
-		if (enabled)
+		if (enabled && player.type == animia::PlayerType::Default)
 			players.push_back(player);
 
 	if (!animia::GetResults(players, results))