changeset 228:d030b30526d5

config: remove unused username parameter from anilist auth
author Paper <mrpapersonic@gmail.com>
date Tue, 09 Jan 2024 08:05:36 -0500
parents c4f03f83b252
children 69f4768a820c
files include/core/config.h src/core/config.cc src/gui/dialog/settings/library.cc src/gui/window.cc src/library/library.cc src/services/anilist.cc src/track/media.cc
diffstat 7 files changed, 12 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/include/core/config.h	Mon Jan 08 21:30:18 2024 -0500
+++ b/include/core/config.h	Tue Jan 09 08:05:36 2024 -0500
@@ -35,12 +35,9 @@
 			bool highlighted_anime_above_others;
 		} anime_list;
 
-		/* these should preferably be in an
-		   "auth" struct... */
 		struct {
 			struct {
 				std::string auth_token;
-				std::string username;
 				int user_id;
 			} anilist;
 		} auth;
--- a/src/core/config.cc	Mon Jan 08 21:30:18 2024 -0500
+++ b/src/core/config.cc	Tue Jan 09 08:05:36 2024 -0500
@@ -33,7 +33,7 @@
 int Config::Load() {
 	std::filesystem::path cfg_path = Filesystem::GetConfigPath();
 
-	mINI::INIFile file(cfg_path.string());
+	mINI::INIFile file(cfg_path.u8string());
 	mINI::INIStructure ini;
 	file.read(ini);
 
--- a/src/gui/dialog/settings/library.cc	Mon Jan 08 21:30:18 2024 -0500
+++ b/src/gui/dialog/settings/library.cc	Tue Jan 09 08:05:36 2024 -0500
@@ -49,7 +49,7 @@
 }
 
 void DroppableListWidget::dropEvent(QDropEvent* event) {
-	const QMimeData *mime_data = event->mimeData();
+	const QMimeData* mime_data = event->mimeData();
 
 	if (!mime_data->hasUrls())
 		return;
--- a/src/gui/window.cc	Mon Jan 08 21:30:18 2024 -0500
+++ b/src/gui/window.cc	Tue Jan 09 08:05:36 2024 -0500
@@ -175,9 +175,11 @@
 					QDesktopServices::openUrl(QUrl::fromLocalFile(folder));
 				});
 				if (i < 9)
-					action->setShortcut(QKeySequence(Qt::ALT | (Qt::Key_1 + i++)));
+					action->setShortcut(QKeySequence(Qt::ALT | static_cast<Qt::Modifier>(Qt::Key_1 + i)));
 				else if (i == 9)
 					action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_0));
+				/* don't bother with a shortcut in case of more... */
+				i++;
 			}
 
 			folder_menu->addSeparator();
--- a/src/library/library.cc	Mon Jan 08 21:30:18 2024 -0500
+++ b/src/library/library.cc	Tue Jan 09 08:05:36 2024 -0500
@@ -19,13 +19,13 @@
 void SearchLibraryFolders() {
 	library.clear();
 
-	for (const auto& spath : session.config.library.paths) {
-		const std::filesystem::path path(spath);
-		for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) {
-			if (!std::filesystem::is_regular_file(entry.path()))
+	for (const auto& folder : session.config.library.paths) {
+		for (const auto& entry : std::filesystem::recursive_directory_iterator(folder)) {
+			const std::filesystem::path path = entry.path();
+			if (!std::filesystem::is_regular_file(path))
 				continue;
 
-			const std::string basename = entry.path().filename().string();
+			const std::string basename = path.filename().u8string();
 
 			anitomy::Anitomy anitomy;
 			anitomy.Parse(Strings::ToWstring(basename));
@@ -41,7 +41,7 @@
 			const int episode = Strings::ToInt(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)));
 
 			// we have an ID now!
-			library[id][episode] = entry.path();
+			library[id][episode] = path.u8string();
 		}
 	}
 }
--- a/src/services/anilist.cc	Mon Jan 08 21:30:18 2024 -0500
+++ b/src/services/anilist.cc	Tue Jan 09 08:05:36 2024 -0500
@@ -30,9 +30,6 @@
 
 class Account {
 	public:
-		std::string Username() const { return session.config.auth.anilist.username; }
-		void SetUsername(std::string const& username) { session.config.auth.anilist.username = username; }
-
 		int UserId() const { return session.config.auth.anilist.user_id; }
 		void SetUserId(const int id) { session.config.auth.anilist.user_id = id; }
 
@@ -300,7 +297,6 @@
 }
 
 int ParseUser(const nlohmann::json& json) {
-	account.SetUsername(JSON::GetString<std::string>(json, "/name"_json_pointer, ""));
 	account.SetUserId(JSON::GetNumber(json, "/id"_json_pointer, 0));
 	return account.UserId();
 }
--- a/src/track/media.cc	Mon Jan 08 21:30:18 2024 -0500
+++ b/src/track/media.cc	Tue Jan 09 08:05:36 2024 -0500
@@ -45,7 +45,7 @@
 				switch (info.type) {
 					case animia::MediaInfoType::File:
 					case animia::MediaInfoType::Title:
-						vec.push_back(std::filesystem::path(info.value).filename().string());
+						vec.push_back(std::filesystem::path(info.value).filename().u8string());
 						success |= true;
 					default:
 						break;