mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Start working on QWESettings Attributes
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
6f0249f78b
commit
bbad4d86a8
|
@ -111,6 +111,53 @@ SiteWebEngineSettings SiteSettingsManager::getWebEngineSettings(const QUrl& url)
|
|||
return settings;
|
||||
}
|
||||
|
||||
QHash<QWebEngineSettings::WebAttribute, bool> SiteSettingsManager::getWebAttributes(const QUrl& url)
|
||||
{
|
||||
QHash<QWebEngineSettings::WebAttribute, bool> attribute;
|
||||
|
||||
QSqlQuery query(SqlDatabase::instance()->database());
|
||||
query.prepare(QSL("SELECT allow_images, allow_javascript FROM site_settings WHERE server=?"));
|
||||
query.addBindValue(url.host());
|
||||
query.exec();
|
||||
|
||||
// Fill the default values
|
||||
// Might not be required
|
||||
// TODO I hope the defaults are set with default webengine profile settings, needs testing
|
||||
attribute[QWebEngineSettings::AutoLoadImages] = getDefaultPermission(poAllowImages) == Allow;
|
||||
attribute[QWebEngineSettings::JavascriptEnabled] = getDefaultPermission(poAllowJavascript) == Allow;
|
||||
|
||||
if (query.next()) {
|
||||
Permission perm;
|
||||
|
||||
auto paerToBool = [&perm, &attribute]() {
|
||||
if (perm == Allow) {
|
||||
attribute[QWebEngineSettings::AutoLoadImages] = true;
|
||||
}
|
||||
else if (perm == Deny) {
|
||||
attribute[QWebEngineSettings::AutoLoadImages] = false;
|
||||
}
|
||||
};
|
||||
|
||||
perm = intToPermission(query.value(QSL("allow_images")).toInt());
|
||||
if (perm == Allow) {
|
||||
attribute[QWebEngineSettings::AutoLoadImages] = true;
|
||||
}
|
||||
else if (perm == Deny) {
|
||||
attribute[QWebEngineSettings::AutoLoadImages] = false;
|
||||
}
|
||||
|
||||
perm = intToPermission(query.value(QSL("allow_javascript")).toInt());
|
||||
if (perm == Allow) {
|
||||
attribute[QWebEngineSettings::JavascriptEnabled] = true;
|
||||
}
|
||||
else if (perm == Deny) {
|
||||
attribute[QWebEngineSettings::JavascriptEnabled] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
void SiteSettingsManager::setJavascript(const QUrl& url, const int value)
|
||||
{
|
||||
setOption(poAllowJavascript, url, value);
|
||||
|
|
|
@ -46,8 +46,23 @@ public:
|
|||
Q_ENUM(Permission);
|
||||
|
||||
enum PageOptions {
|
||||
poAllowJavascript,
|
||||
poAllowImages,
|
||||
|
||||
/* Javascript stuff */
|
||||
poAllowJavascript,
|
||||
poJavascriptCanOpenWindows,
|
||||
poJavascriptCanAccessClipboard,
|
||||
poJavascriptCanPaste,
|
||||
poAllowWindowActivationFromJavaScript,
|
||||
|
||||
poLocalStorageEnabled,
|
||||
poScrollAnimatorEnabled,
|
||||
poFullScreenSupportEnabled,
|
||||
poAllowRunningInsecureContent,
|
||||
poAllowGeolocationOnInsecureOrigins,
|
||||
poPlaybackRequiresUserGesture,
|
||||
poWebRTCPublicInterfacesOnly,
|
||||
|
||||
poAllowCookies,
|
||||
poZoomLevel,
|
||||
poAllowNotifications,
|
||||
|
@ -66,7 +81,7 @@ public:
|
|||
Permission AllowJavascript;
|
||||
Permission AllowImages;
|
||||
Permission AllowCookies;
|
||||
Permission ZoomLevel;
|
||||
int ZoomLevel;
|
||||
Permission AllowNotifications;
|
||||
Permission AllowGeolocation;
|
||||
Permission AllowMediaAudioCapture;
|
||||
|
@ -92,6 +107,8 @@ public:
|
|||
*/
|
||||
SiteWebEngineSettings getWebEngineSettings(const QUrl &url);
|
||||
|
||||
QHash<QWebEngineSettings::WebAttribute, bool> getWebAttributes(const QUrl &url);
|
||||
|
||||
void setJavascript(const QUrl &url, const int value);
|
||||
void setImages(const QUrl &url, const int value);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user