aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/web/webprofile.cpp13
-rw-r--r--lib/web/webprofile.h4
-rw-r--r--plugins/ProfileEditor/CMakeLists.txt3
-rw-r--r--plugins/ProfileEditor/forms/profileview.cpp97
-rw-r--r--plugins/ProfileEditor/forms/profileview.h6
5 files changed, 60 insertions, 63 deletions
diff --git a/lib/web/webprofile.cpp b/lib/web/webprofile.cpp
index 4d31376..295f639 100644
--- a/lib/web/webprofile.cpp
+++ b/lib/web/webprofile.cpp
@@ -104,6 +104,12 @@ void WebProfile::setPersistentStoragePath(const QString &path)
emit propertyChanged("persistentStoragePath", path);
}
+void WebProfile::setPersistentCookiesPolicy(int policy)
+{
+ QWebEngineProfile::setPersistentCookiesPolicy(static_cast<QWebEngineProfile::PersistentCookiesPolicy>(policy));
+ emit propertyChanged("persistentCookiesPolicy", policy);
+}
+
void WebProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
{
QWebEngineProfile::setHttpAcceptLanguage(httpAcceptLanguage);
@@ -116,6 +122,13 @@ void WebProfile::setHttpCacheMaximumSize(int maxSize)
emit propertyChanged("httpCacheMaximumSize", maxSize);
}
+void WebProfile::setHttpCacheType(int type)
+{
+ qDebug("set httpCacheType to %i", type);
+ QWebEngineProfile::setHttpCacheType(static_cast<QWebEngineProfile::HttpCacheType>(type));
+ emit propertyChanged("httpCacheType", type);
+}
+
void WebProfile::setHttpUserAgent(const QString &userAgent)
{
QWebEngineProfile::setHttpUserAgent(userAgent);
diff --git a/lib/web/webprofile.h b/lib/web/webprofile.h
index 2282afe..32b5112 100644
--- a/lib/web/webprofile.h
+++ b/lib/web/webprofile.h
@@ -30,9 +30,11 @@ class WebProfile : public QWebEngineProfile
// 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)
@@ -78,9 +80,11 @@ public:
void setCachePath(const QString &path);
void setPersistentStoragePath(const QString &path);
+ void setPersistentCookiesPolicy(int policy);
void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
void setHttpCacheMaximumSize(int maxSize);
+ void setHttpCacheType(int type);
void setHttpUserAgent(const QString &userAgent);
void setSpellCheckEnabled(bool enable);
diff --git a/plugins/ProfileEditor/CMakeLists.txt b/plugins/ProfileEditor/CMakeLists.txt
index f294c30..6237785 100644
--- a/plugins/ProfileEditor/CMakeLists.txt
+++ b/plugins/ProfileEditor/CMakeLists.txt
@@ -2,6 +2,9 @@ find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5WebEngineWidgets REQUIRED)
+# Find includes in corresponding build directories
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp
index caa9723..f4750e1 100644
--- a/plugins/ProfileEditor/forms/profileview.cpp
+++ b/plugins/ProfileEditor/forms/profileview.cpp
@@ -14,13 +14,12 @@
#include <QWebEngineCookieStore>
#include <QDateTime>
-void ProfileView::connectSetting(QCheckBox *checkBox, QWebEngineSettings *settings, QWebEngineSettings::WebAttribute attr)
+inline void connectSetting(QCheckBox *checkBox, WebProfile *profile, QWebEngineSettings::WebAttribute attr)
{
- checkBox->setChecked(settings->testAttribute(attr));
- connect(checkBox, &QCheckBox::clicked, [this, settings, attr](bool checked) {
- this->m_isChanged = true;
- settings->setAttribute(attr, checked);
- emit m_profile->attributeChanged(attr, checked);
+ checkBox->setChecked(profile->settings()->testAttribute(attr));
+ QObject::connect(checkBox, &QCheckBox::clicked, [profile, attr](bool checked) {
+ profile->settings()->setAttribute(attr, checked);
+ emit profile->attributeChanged(attr, checked);
});
}
@@ -58,32 +57,27 @@ ProfileView::ProfileView(WebProfile *profile, QWidget *parent)
// http tab
ui->userAgent->setPlainText(m_profile->httpUserAgent());
connect(ui->userAgent, &QPlainTextEdit::textChanged, profile, [=]() {
- this->m_isChanged = true;
profile->setHttpUserAgent(ui->userAgent->toPlainText());
});
ui->acceptLanguage->setPlainText(m_profile->httpAcceptLanguage());
connect(ui->acceptLanguage, &QPlainTextEdit::textChanged, profile, [=]() {
- this->m_isChanged = true;
profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText());
});
ui->cacheType->setCurrentIndex(m_profile->httpCacheType());
connect(ui->cacheType, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) {
- this->m_isChanged = true;
- profile->setHttpCacheType(static_cast<QWebEngineProfile::HttpCacheType>(index));
+ profile->setHttpCacheType(index);
});
ui->cacheSize->setText(QString::number(m_profile->httpCacheMaximumSize()));
connect(ui->cacheSize, &QLineEdit::textChanged, profile, [=](const QString &text) {
- this->m_isChanged = true;
profile->setHttpCacheMaximumSize(text.toInt());
});
ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy());
connect(ui->cookiePolicy, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) {
- this->m_isChanged = true;
- profile->setPersistentCookiesPolicy(static_cast<QWebEngineProfile::PersistentCookiesPolicy>(index));
+ profile->setPersistentCookiesPolicy(index);
});
connect(ui->clearCache_pushButton, &QPushButton::clicked, profile, &QWebEngineProfile::clearHttpCache);
@@ -93,7 +87,39 @@ ProfileView::ProfileView(WebProfile *profile, QWidget *parent)
ui->cachePath_lineEdit->setText(m_profile->cachePath());
// settings tab
- loadSettings(profile->settings());
+ connectSetting(ui->autoloadImages, m_profile, QWebEngineSettings::AutoLoadImages);
+ connectSetting(ui->autoloadIcons, m_profile, QWebEngineSettings::AutoLoadIconsForPage);
+
+ connectSetting(ui->javascriptEnabled, m_profile, QWebEngineSettings::JavascriptEnabled);
+ connectSetting(ui->javascriptCanAccessClipboard, m_profile, QWebEngineSettings::JavascriptCanAccessClipboard);
+ connectSetting(ui->javascriptCanOpenWindows, m_profile, QWebEngineSettings::JavascriptCanOpenWindows);
+ connectSetting(ui->javascriptCanActivateWindows, m_profile, QWebEngineSettings::AllowWindowActivationFromJavaScript);
+
+ connectSetting(ui->linksIncludedInFocusChain, m_profile, QWebEngineSettings::LinksIncludedInFocusChain);
+ connectSetting(ui->spatialNavigationEnabled, m_profile, QWebEngineSettings::SpatialNavigationEnabled);
+ connectSetting(ui->focusOnNavigationEnabled, m_profile, QWebEngineSettings::FocusOnNavigationEnabled);
+ connectSetting(ui->touchIconsEnabled, m_profile, QWebEngineSettings::TouchIconsEnabled);
+
+ connectSetting(ui->showScrollBars, m_profile, QWebEngineSettings::ShowScrollBars);
+ connectSetting(ui->scrollAnimatorEnabled, m_profile, QWebEngineSettings::ScrollAnimatorEnabled);
+ connectSetting(ui->errorPagesEnabled, m_profile, QWebEngineSettings::ErrorPageEnabled);
+
+ connectSetting(ui->localContentCanAccessRemoteUrls, m_profile, QWebEngineSettings::LocalContentCanAccessRemoteUrls);
+ connectSetting(ui->localContentCanAccessFileUrls, m_profile, QWebEngineSettings::LocalContentCanAccessFileUrls);
+
+ connectSetting(ui->localStorageEnabled, m_profile, QWebEngineSettings::LocalStorageEnabled);
+ connectSetting(ui->webglEnabled, m_profile, QWebEngineSettings::WebGLEnabled);
+ connectSetting(ui->canvasEnabled, m_profile, QWebEngineSettings::Accelerated2dCanvasEnabled);
+
+ connectSetting(ui->xssAuditingEnabled, m_profile, QWebEngineSettings::XSSAuditingEnabled);
+ connectSetting(ui->hyperlinkAuditingEnabled, m_profile, QWebEngineSettings::HyperlinkAuditingEnabled);
+
+ connectSetting(ui->allowRunningInsecureContent, m_profile, QWebEngineSettings::AllowRunningInsecureContent);
+ connectSetting(ui->allowGeolocationOnInsecureContent, m_profile, QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
+ connectSetting(ui->ppapiPluginsEnabled, m_profile, QWebEngineSettings::PluginsEnabled);
+ connectSetting(ui->fullscreenSupportEnabled, m_profile, QWebEngineSettings::FullScreenSupportEnabled);
+ connectSetting(ui->screenCaptureEnabled, m_profile, QWebEngineSettings::ScreenCaptureEnabled);
+ connectSetting(ui->printElementBackgrounds, m_profile, QWebEngineSettings::PrintElementBackgrounds);
// cookies tab
loadCookies(profile->cookieStore());
@@ -107,49 +133,6 @@ ProfileView::~ProfileView()
delete ui;
}
-bool ProfileView::isChanged() const
-{
- return m_isChanged;
-}
-
-void ProfileView::loadSettings(QWebEngineSettings *settings)
-{
- // settings
- connectSetting(ui->autoloadImages, settings, QWebEngineSettings::AutoLoadImages);
- connectSetting(ui->autoloadIcons, settings, QWebEngineSettings::AutoLoadIconsForPage);
-
- connectSetting(ui->javascriptEnabled, settings, QWebEngineSettings::JavascriptEnabled);
- connectSetting(ui->javascriptCanAccessClipboard, settings, QWebEngineSettings::JavascriptCanAccessClipboard);
- connectSetting(ui->javascriptCanOpenWindows, settings, QWebEngineSettings::JavascriptCanOpenWindows);
- connectSetting(ui->javascriptCanActivateWindows, settings, QWebEngineSettings::AllowWindowActivationFromJavaScript);
-
- connectSetting(ui->linksIncludedInFocusChain, settings, QWebEngineSettings::LinksIncludedInFocusChain);
- connectSetting(ui->spatialNavigationEnabled, settings, QWebEngineSettings::SpatialNavigationEnabled);
- connectSetting(ui->focusOnNavigationEnabled, settings, QWebEngineSettings::FocusOnNavigationEnabled);
- connectSetting(ui->touchIconsEnabled, settings, QWebEngineSettings::TouchIconsEnabled);
-
- connectSetting(ui->showScrollBars, settings, QWebEngineSettings::ShowScrollBars);
- connectSetting(ui->scrollAnimatorEnabled, settings, QWebEngineSettings::ScrollAnimatorEnabled);
- connectSetting(ui->errorPagesEnabled, settings, QWebEngineSettings::ErrorPageEnabled);
-
- connectSetting(ui->localContentCanAccessRemoteUrls, settings, QWebEngineSettings::LocalContentCanAccessRemoteUrls);
- connectSetting(ui->localContentCanAccessFileUrls, settings, QWebEngineSettings::LocalContentCanAccessFileUrls);
-
- connectSetting(ui->localStorageEnabled, settings, QWebEngineSettings::LocalStorageEnabled);
- connectSetting(ui->webglEnabled, settings, QWebEngineSettings::WebGLEnabled);
- connectSetting(ui->canvasEnabled, settings, QWebEngineSettings::Accelerated2dCanvasEnabled);
-
- connectSetting(ui->xssAuditingEnabled, settings, QWebEngineSettings::XSSAuditingEnabled);
- connectSetting(ui->hyperlinkAuditingEnabled, settings, QWebEngineSettings::HyperlinkAuditingEnabled);
-
- connectSetting(ui->allowRunningInsecureContent, settings, QWebEngineSettings::AllowRunningInsecureContent);
- connectSetting(ui->allowGeolocationOnInsecureContent, settings, QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
- connectSetting(ui->ppapiPluginsEnabled, settings, QWebEngineSettings::PluginsEnabled);
- connectSetting(ui->fullscreenSupportEnabled, settings, QWebEngineSettings::FullScreenSupportEnabled);
- connectSetting(ui->screenCaptureEnabled, settings, QWebEngineSettings::ScreenCaptureEnabled);
- connectSetting(ui->printElementBackgrounds, settings, QWebEngineSettings::PrintElementBackgrounds);
-}
-
void ProfileView::loadCookies(QWebEngineCookieStore *store)
{
//
diff --git a/plugins/ProfileEditor/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h
index 6c77982..7d90109 100644
--- a/plugins/ProfileEditor/forms/profileview.h
+++ b/plugins/ProfileEditor/forms/profileview.h
@@ -30,10 +30,7 @@ public:
explicit ProfileView(WebProfile *profile, QWidget *parent = nullptr);
~ProfileView() override;
- bool isChanged() const;
-
private slots:
- void loadSettings(QWebEngineSettings *settings);
void loadCookies(QWebEngineCookieStore *store);
void cookieAdded(const QNetworkCookie &cookie);
@@ -42,9 +39,6 @@ private slots:
private:
Ui::ProfileView *ui;
WebProfile *m_profile;
- bool m_isChanged = false;
-
- void connectSetting(QCheckBox *checkBox, QWebEngineSettings *settings, QWebEngineSettings::WebAttribute attr);
};
#endif // PROFILEDIALOG_H