From 3639d5789259561c531a3481d7061a0cb492c644 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 9 Oct 2018 12:05:28 +0200 Subject: Unlink plugins from lib/ libraries --- lib/web/CMakeLists.txt | 4 ++++ lib/web/profilemanager.cpp | 13 +++++++++++++ lib/web/profilemanager.h | 1 + lib/web/webprofile.cpp | 4 ++-- lib/web/webprofile.h | 31 ++----------------------------- 5 files changed, 22 insertions(+), 31 deletions(-) (limited to 'lib') 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 &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 ptr = std::make_unique(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 &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 #include #include +#include -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; -- cgit v1.2.1