aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-24 17:27:44 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-24 17:27:44 +0200
commite81526f15e8c1e9c82b27009dbe512f78cf1dc0f (patch)
treeea9a140347b6077d0521f85da4f9d881185fbb90 /lib
parentSplit shortcuts into new tab (diff)
downloadsmolbote-e81526f15e8c1e9c82b27009dbe512f78cf1dc0f.tar.xz
Add Session class
Diffstat (limited to 'lib')
-rw-r--r--lib/web/webprofile.cpp9
-rw-r--r--lib/web/webprofile.h11
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/web/webprofile.cpp b/lib/web/webprofile.cpp
index 1124261..1613e52 100644
--- a/lib/web/webprofile.cpp
+++ b/lib/web/webprofile.cpp
@@ -13,8 +13,9 @@
#include <QWebEngineSettings>
WebProfile *WebProfile::profile = nullptr;
+QMap<QString, WebProfile *> WebProfile::profiles;
-WebProfile* loadProfile(const QString &name, const QHash<QString, QString> &defaults, const QString &path, QObject *parent)
+WebProfile* WebProfile::loadProfile(const QString &name, const QHash<QString, QString> &defaults, const QString &path, QObject *parent)
{
WebProfile *profile = nullptr;
#ifdef QT_DEBUG
@@ -36,6 +37,7 @@ WebProfile* loadProfile(const QString &name, const QHash<QString, QString> &defa
}
Q_CHECK_PTR(profile);
+ profiles.insert(name, profile);
profile->setSearch(config.value("search", defaults.value("profile.search")).toString());
profile->setHomepage(config.value("homepage", defaults.value("profile.homepage")).toUrl());
@@ -73,6 +75,10 @@ WebProfile* loadProfile(const QString &name, const QHash<QString, QString> &defa
WebProfile::WebProfile(const QString &name, const QString &configPath, QObject *parent)
: QWebEngineProfile(parent)
{
+ if(configPath.isEmpty())
+ m_id = configPath;
+ else
+ m_id = QFileInfo(configPath).baseName();
m_name = name;
m_configPath = configPath;
@@ -91,6 +97,7 @@ WebProfile::WebProfile(const QString &name, const QString &configPath, QObject *
WebProfile::WebProfile(const QString &storageName, const QString &name, const QString &configPath, QObject *parent)
: QWebEngineProfile(storageName, parent)
{
+ m_id = QFileInfo(configPath).baseName();
m_name = name;
m_configPath = configPath;
diff --git a/lib/web/webprofile.h b/lib/web/webprofile.h
index 279e6bf..d41625c 100644
--- a/lib/web/webprofile.h
+++ b/lib/web/webprofile.h
@@ -15,6 +15,7 @@
#include <QWebEngineProfile>
#include <QVector>
#include <QNetworkCookie>
+#include <QMap>
class WebProfile : public QWebEngineProfile
{
@@ -53,6 +54,13 @@ public:
return WebProfile::profile;
}
+ static WebProfile* loadProfile(const QString &name, const QHash<QString, QString> &defaults, const QString &path = QString(), QObject *parent = nullptr);
+
+ const QString id() const
+ {
+ return profiles.key(const_cast<WebProfile*>(this), "");
+ }
+
QString name() const
{
return m_name;
@@ -104,7 +112,9 @@ signals:
private:
static WebProfile *profile;
+ static QMap<QString, WebProfile *> profiles;
+ QString m_id;
QString m_configPath;
QString m_name;
QString m_search = QString("about:blank");
@@ -114,7 +124,6 @@ private:
QVector<QNetworkCookie> m_cookies;
};
-WebProfile* loadProfile(const QString &name, const QHash<QString, QString> &defaults, const QString &path = QString(), QObject *parent = nullptr);
//WebProfile *saveProfile(WebProfile *profile, const QString &path);
#endif // SMOLBOTE_WEBENGINEPROFILE_H