aboutsummaryrefslogtreecommitdiff
path: root/lib/web/profilemanager.h
diff options
context:
space:
mode:
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;
};