aboutsummaryrefslogtreecommitdiff
path: root/lib/web
diff options
context:
space:
mode:
Diffstat (limited to 'lib/web')
-rw-r--r--lib/web/CMakeLists.txt4
-rw-r--r--lib/web/profilemanager.cpp13
-rw-r--r--lib/web/profilemanager.h1
-rw-r--r--lib/web/webprofile.cpp4
-rw-r--r--lib/web/webprofile.h31
5 files changed, 22 insertions, 31 deletions
diff --git a/lib/web/CMakeLists.txt b/lib/web/CMakeLists.txt
index 86f7f1c..12b4080 100644
--- a/lib/web/CMakeLists.txt
+++ b/lib/web/CMakeLists.txt
@@ -11,4 +11,8 @@ add_library(web
webprofile.h
)
+target_include_directories(web
+ PRIVATE ${PROJECT_SOURCE_DIR}/include
+)
+
target_link_libraries(web Qt5::WebEngineWidgets)
diff --git a/lib/web/profilemanager.cpp b/lib/web/profilemanager.cpp
index 17435e8..14795cd 100644
--- a/lib/web/profilemanager.cpp
+++ b/lib/web/profilemanager.cpp
@@ -17,6 +17,19 @@ ProfileManager::ProfileManager(const QHash<QString, QString> &profileSection, QO
{
}
+WebProfile *ProfileManager::createProfile(const QString& id, bool isOffTheRecord)
+{
+ QDir profileDir(defaults.value("profile.path"));
+ const QString path = profileDir.absoluteFilePath(id + ".profile");
+ {
+ QSettings init(path, QSettings::IniFormat);
+ init.setValue("name", id);
+ init.setValue("otr", isOffTheRecord);
+ init.sync();
+ }
+ return loadProfile(path);
+}
+
WebProfile *ProfileManager::loadProfile(const QString &path)
{
std::unique_ptr<ProfileData> ptr = std::make_unique<ProfileData>(path);
diff --git a/lib/web/profilemanager.h b/lib/web/profilemanager.h
index c7ed660..f5e33b9 100644
--- a/lib/web/profilemanager.h
+++ b/lib/web/profilemanager.h
@@ -27,6 +27,7 @@ class ProfileManager : public QObject
public:
explicit ProfileManager(const QHash<QString, QString> &profileSection, QObject *parent);
+ WebProfile *createProfile(const QString &id, bool isOffTheRecord);
WebProfile *loadProfile(const QString &path);
void deleteProfile(const QString &id);
diff --git a/lib/web/webprofile.cpp b/lib/web/webprofile.cpp
index 16c12b7..38aa7f0 100644
--- a/lib/web/webprofile.cpp
+++ b/lib/web/webprofile.cpp
@@ -15,7 +15,7 @@
WebProfile *WebProfile::profile = nullptr;
WebProfile::WebProfile(const QString &name, QObject *parent)
- : QWebEngineProfile(parent)
+ : Profile(parent)
{
m_name = name;
@@ -32,7 +32,7 @@ WebProfile::WebProfile(const QString &name, QObject *parent)
}
WebProfile::WebProfile(const QString &storageName, const QString &name, QObject *parent)
- : QWebEngineProfile(storageName, parent)
+ : Profile(storageName, parent)
{
m_name = name;
diff --git a/lib/web/webprofile.h b/lib/web/webprofile.h
index 269989b..a3b5b12 100644
--- a/lib/web/webprofile.h
+++ b/lib/web/webprofile.h
@@ -17,28 +17,12 @@
#include <QNetworkCookie>
#include <QMap>
#include <QWebEngineSettings>
+#include <profileinterface.h>
-class WebProfile : public QWebEngineProfile
+class WebProfile : public Profile
{
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString search READ search WRITE setSearch NOTIFY searchChanged)
- Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
- Q_PROPERTY(QUrl newtab READ newtab WRITE setNewtab NOTIFY newtabChanged)
-
- // QWebEngineProfile should-be properties
- Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY propertyChanged)
- Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY propertyChanged)
- Q_PROPERTY(int persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY propertyChanged)
-
- Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY propertyChanged)
- Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY propertyChanged)
- Q_PROPERTY(int httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY propertyChanged)
- Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY propertyChanged)
-
- Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY propertyChanged)
-
public:
// off-the-record constructor
explicit WebProfile(const QString &name, QObject *parent = nullptr);
@@ -95,17 +79,6 @@ public:
void setSpellCheckEnabled(bool enable);
-signals:
- void nameChanged(const QString &name);
- void searchChanged(const QString &url);
- void homepageChanged(const QUrl &url);
- void newtabChanged(const QUrl &url);
-
- void propertyChanged(const QString &name, const QVariant &value);
- void attributeChanged(const QWebEngineSettings::WebAttribute attribute, const bool value);
- void headerChanged(const QString &name, const QString &value);
- void headerRemoved(const QString &name);
-
private:
static WebProfile *profile;