1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Add an option to delete files when removing a game install

Otherwise your game install folder ends up littered with junk, like
mine!
This commit is contained in:
Joshua Goins 2025-03-17 19:33:28 -04:00
parent c3acd8f44c
commit 0b00a49402
3 changed files with 17 additions and 4 deletions

View file

@ -35,7 +35,7 @@ public:
int getProfileIndex(const QString &name); int getProfileIndex(const QString &name);
Q_INVOKABLE Profile *addProfile(); Q_INVOKABLE Profile *addProfile();
Q_INVOKABLE void deleteProfile(Profile *profile); Q_INVOKABLE void deleteProfile(Profile *profile, bool deleteFiles);
[[nodiscard]] QList<Profile *> profiles() const; [[nodiscard]] QList<Profile *> profiles() const;
[[nodiscard]] int numProfiles() const; [[nodiscard]] int numProfiles() const;

View file

@ -51,12 +51,17 @@ Profile *ProfileManager::addProfile()
return newProfile; return newProfile;
} }
void ProfileManager::deleteProfile(Profile *profile) void ProfileManager::deleteProfile(Profile *profile, const bool deleteFiles)
{ {
auto config = KSharedConfig::openStateConfig(); auto config = KSharedConfig::openStateConfig();
config->deleteGroup(QStringLiteral("profile-%1").arg(profile->uuid())); config->deleteGroup(QStringLiteral("profile-%1").arg(profile->uuid()));
config->sync(); config->sync();
// delete files if requested
if (deleteFiles) {
QDir(profile->config()->gamePath()).removeRecursively();
}
const int row = static_cast<int>(m_profiles.indexOf(profile)); const int row = static_cast<int>(m_profiles.indexOf(profile));
beginRemoveRows(QModelIndex(), row, row); beginRemoveRows(QModelIndex(), row, row);
m_profiles.removeAll(profile); m_profiles.removeAll(profile);

View file

@ -327,8 +327,16 @@ FormCard.FormCardPage {
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
showCloseButton: false showCloseButton: false
QQC2.Switch {
id: deleteFilesSwitch
checked: true
text: i18n("Delete Files")
}
onAccepted: { onAccepted: {
LauncherCore.profileManager.deleteProfile(page.profile); LauncherCore.profileManager.deleteProfile(page.profile, deleteFilesSwitch.checked);
page.Window.window.pageStack.layers.pop(); page.Window.window.pageStack.layers.pop();
} }
} }