aboutsummaryrefslogtreecommitdiff
path: root/lib/web/profilemanager.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-09-29 12:17:35 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-09-29 12:40:10 +0200
commit91f9a68249d33dba25a2763ea89e73a219f8ad67 (patch)
tree768c1ba57dd38cd7ce0fc067b83e5b3847fd0a97 /lib/web/profilemanager.h
parentTurn Session class into namespace (diff)
downloadsmolbote-91f9a68249d33dba25a2763ea89e73a219f8ad67.tar.xz
ProfileEditor plugin: fix delete button
Diffstat (limited to 'lib/web/profilemanager.h')
-rw-r--r--lib/web/profilemanager.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/web/profilemanager.h b/lib/web/profilemanager.h
index 500f090..7e987a8 100644
--- a/lib/web/profilemanager.h
+++ b/lib/web/profilemanager.h
@@ -9,13 +9,16 @@
#ifndef SMOLBOTE_PROFILEMANAGER_H
#define SMOLBOTE_PROFILEMANAGER_H
-#include <QObject>
+#include "webprofile.h"
+#include <QDir>
+#include <QFile>
#include <QMap>
+#include <QMenu>
+#include <QObject>
#include <QSettings>
+#include <functional>
#include <map>
#include <memory>
-#include <functional>
-#include <QMenu>
#define profileManager ProfileManager::instance()
@@ -30,26 +33,36 @@ public:
static ProfileManager *instance();
WebProfile *loadProfile(const QString &path);
+ void deleteProfile(const QString &id);
QMenu *createProfileMenu(std::function<void(WebProfile *)> callback, QWidget *parent = nullptr) const;
const QStringList idList() const;
- const QString id(WebProfile *profile) const;
+ const QString id(const WebProfile *profile) const;
WebProfile *profile(const QString &id) const;
const QString configurationPath(const QString &id) const;
private:
- struct ProfileData
- {
- ProfileData(const QString &path = QString()) : settings(path, QSettings::IniFormat) {
+ struct ProfileData {
+ explicit ProfileData(const QString &path = QString())
+ : settings(path, QSettings::IniFormat)
+ {
this->path = path;
}
- ~ProfileData() {
- this->settings.sync();
+ ~ProfileData()
+ {
+ if(!deleteSelf)
+ this->settings.sync();
+ else {
+ QFile(path).remove();
+ QDir(profile->persistentStoragePath()).removeRecursively();
+ QDir(profile->cachePath()).removeRecursively();
+ }
}
WebProfile *profile = nullptr;
+ bool deleteSelf = false;
QSettings settings;
QString path;
};