diff --git a/launcher/include/profilemanager.h b/launcher/include/profilemanager.h index 64b6d7c..df7762d 100644 --- a/launcher/include/profilemanager.h +++ b/launcher/include/profilemanager.h @@ -35,7 +35,7 @@ public: int getProfileIndex(const QString &name); Q_INVOKABLE Profile *addProfile(); - Q_INVOKABLE void deleteProfile(Profile *profile); + Q_INVOKABLE void deleteProfile(Profile *profile, bool deleteFiles); [[nodiscard]] QList profiles() const; [[nodiscard]] int numProfiles() const; @@ -54,4 +54,4 @@ private: void insertProfile(Profile *profile); QList m_profiles; -}; \ No newline at end of file +}; diff --git a/launcher/src/profilemanager.cpp b/launcher/src/profilemanager.cpp index 2717328..fd331fe 100644 --- a/launcher/src/profilemanager.cpp +++ b/launcher/src/profilemanager.cpp @@ -51,12 +51,17 @@ Profile *ProfileManager::addProfile() return newProfile; } -void ProfileManager::deleteProfile(Profile *profile) +void ProfileManager::deleteProfile(Profile *profile, const bool deleteFiles) { auto config = KSharedConfig::openStateConfig(); config->deleteGroup(QStringLiteral("profile-%1").arg(profile->uuid())); config->sync(); + // delete files if requested + if (deleteFiles) { + QDir(profile->config()->gamePath()).removeRecursively(); + } + const int row = static_cast(m_profiles.indexOf(profile)); beginRemoveRows(QModelIndex(), row, row); m_profiles.removeAll(profile); diff --git a/launcher/ui/Settings/ProfileSettings.qml b/launcher/ui/Settings/ProfileSettings.qml index 7d50556..2bf8f45 100644 --- a/launcher/ui/Settings/ProfileSettings.qml +++ b/launcher/ui/Settings/ProfileSettings.qml @@ -327,8 +327,16 @@ FormCard.FormCardPage { standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel showCloseButton: false + QQC2.Switch { + id: deleteFilesSwitch + + checked: true + + text: i18n("Delete Files") + } + onAccepted: { - LauncherCore.profileManager.deleteProfile(page.profile); + LauncherCore.profileManager.deleteProfile(page.profile, deleteFilesSwitch.checked); page.Window.window.pageStack.layers.pop(); } }