From bc1b6fe2c87d0804f0a037b95a89e1ed53fb1247 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 8 Oct 2023 13:22:49 -0400 Subject: [PATCH] Add button to clear lodestone avatar cache --- launcher/include/launchercore.h | 2 ++ launcher/src/launchercore.cpp | 9 +++++++++ launcher/ui/Settings/GeneralSettings.qml | 14 ++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 4c2680b..a226613 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -175,6 +175,8 @@ public: [[nodiscard]] Profile *currentProfile() const; void setCurrentProfile(Profile *profile); + Q_INVOKABLE void clearAvatarCache(); + signals: void loadingFinished(); void gameInstallationChanged(); diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index d58d267..a6c3b2b 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -824,3 +824,12 @@ void LauncherCore::setCurrentProfile(Profile *profile) Q_EMIT currentProfileChanged(); } } + +void LauncherCore::clearAvatarCache() +{ + const auto cacheLocation = QStandardPaths::standardLocations(QStandardPaths::CacheLocation)[0] + QStringLiteral("/avatars"); + qInfo() << cacheLocation; + if (QDir(cacheLocation).exists()) { + QDir(cacheLocation).removeRecursively(); + } +} diff --git a/launcher/ui/Settings/GeneralSettings.qml b/launcher/ui/Settings/GeneralSettings.qml index d41bb10..df56732 100644 --- a/launcher/ui/Settings/GeneralSettings.qml +++ b/launcher/ui/Settings/GeneralSettings.qml @@ -87,4 +87,18 @@ FormCard.FormCardPage { onCheckedChanged: LauncherCore.showDevTools = checked } } + + + FormCard.FormCard { + Layout.topMargin: Kirigami.Units.largeSpacing + Layout.fillWidth: true + + FormCard.FormButtonDelegate { + text: i18n("Clear Lodestone Avatar Cache") + description: i18n("Refreshes the avatars for all accounts, and requires Astra to restart to take effect.") + icon.name: "delete" + + onClicked: LauncherCore.clearAvatarCache() + } + } } \ No newline at end of file