aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webprofilemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/webprofilemanager.cpp')
-rw-r--r--src/webengine/webprofilemanager.cpp83
1 files changed, 0 insertions, 83 deletions
diff --git a/src/webengine/webprofilemanager.cpp b/src/webengine/webprofilemanager.cpp
deleted file mode 100644
index 5cc83f8..0000000
--- a/src/webengine/webprofilemanager.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "webprofilemanager.h"
-#include "webprofile.h"
-
-static WebProfileManager<false> *s_instance = nullptr;
-
-template <>
-void WebProfileManager<false>::make_global()
-{
- if(s_instance == nullptr) {
- s_instance = this;
- }
-}
-
-template <>
-WebProfileManager<true>::~WebProfileManager() = default;
-
-template <>
-WebProfileManager<false>::~WebProfileManager()
-{
- for(Profile p : qAsConst(profiles)) {
- if(p.selfDestruct && p.settings != nullptr) {
- if(!p.ptr->isOffTheRecord()) {
- if(!p.ptr->persistentStoragePath().isEmpty())
- QDir(p.ptr->persistentStoragePath()).removeRecursively();
- if(!p.ptr->cachePath().isEmpty())
- QDir(p.ptr->cachePath()).removeRecursively();
- }
- const QString filename = p.settings->fileName();
- delete p.settings;
- QFile::remove(filename);
- } else if(p.settings != nullptr) {
- p.settings->sync();
- delete p.settings;
- }
- }
-}
-
-template <>
-WebProfile *WebProfileManager<true>::profile(const QString &id) const
-{
- return s_instance->profile(id);
-}
-
-template <>
-QStringList WebProfileManager<true>::idList() const
-{
- return s_instance->idList();
-}
-
-template <>
-void WebProfileManager<false>::walk(std::function<void(const QString &id, WebProfile *profile, QSettings *settings)> f) const
-{
- for(auto iter = profiles.begin(); iter != profiles.end(); ++iter) {
- f(iter.key(), iter.value().ptr, iter.value().settings);
- }
-}
-
-template <>
-void WebProfileManager<true>::walk(std::function<void(const QString &id, WebProfile *profile, QSettings *settings)> f) const
-{
- s_instance->walk(f);
-}
-
-void profileMenu(QMenu *menu, const std::function<void(WebProfile *)> &callback, WebProfile *current, bool checkable)
-{
- auto *group = new QActionGroup(menu);
- QObject::connect(menu, &QMenu::aboutToHide, group, &QActionGroup::deleteLater);
-
- s_instance->walk([=](const QString &, WebProfile *profile, const QSettings *) {
- auto *action = menu->addAction(profile->name(), profile, [=]() { callback(profile); });
- action->setCheckable(checkable);
- action->setChecked(profile == current);
- group->addAction(action);
- });
-}