1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Use correct web settings in private browsing mode

Closes #2427
This commit is contained in:
David Rosca 2018-01-02 22:19:09 +01:00
parent 4e0e4b0d35
commit ee62ad0215
6 changed files with 20 additions and 12 deletions

View File

@ -279,7 +279,7 @@ void BrowserWindow::postLaunch()
startUrl.clear(); startUrl.clear();
// qupzilla:restore needs JavaScript enabled // qupzilla:restore needs JavaScript enabled
// correct value is then restored in MainApplication::destroyRestoreManager // correct value is then restored in MainApplication::destroyRestoreManager
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true); mApp->webSettings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
m_tabWidget->addView(QUrl("falkon:restore"), Qz::NT_CleanSelectedTabAtTheEnd); m_tabWidget->addView(QUrl("falkon:restore"), Qz::NT_CleanSelectedTabAtTheEnd);
} }
else if (mApp->afterLaunch() == MainApplication::SelectSession || mApp->afterLaunch() == MainApplication::RestoreSession) { else if (mApp->afterLaunch() == MainApplication::SelectSession || mApp->afterLaunch() == MainApplication::RestoreSession) {
@ -522,7 +522,7 @@ void BrowserWindow::createEncodingSubMenu(const QString &name, QStringList &code
}); });
QMenu* subMenu = new QMenu(name, menu); QMenu* subMenu = new QMenu(name, menu);
const QString activeCodecName = QWebEngineSettings::defaultSettings()->defaultTextEncoding(); const QString activeCodecName = mApp->webSettings()->defaultTextEncoding();
foreach (const QString &codecName, codecNames) { foreach (const QString &codecName, codecNames) {
subMenu->addAction(createEncodingAction(codecName, activeCodecName, subMenu)); subMenu->addAction(createEncodingAction(codecName, activeCodecName, subMenu));
@ -738,7 +738,7 @@ void BrowserWindow::changeEncoding()
{ {
if (QAction* action = qobject_cast<QAction*>(sender())) { if (QAction* action = qobject_cast<QAction*>(sender())) {
const QString encoding = action->data().toString(); const QString encoding = action->data().toString();
QWebEngineSettings::defaultSettings()->setDefaultTextEncoding(encoding); mApp->webSettings()->setDefaultTextEncoding(encoding);
Settings settings; Settings settings;
settings.setValue("Web-Browser-Settings/DefaultEncoding", encoding); settings.setValue("Web-Browser-Settings/DefaultEncoding", encoding);
@ -1073,7 +1073,7 @@ void BrowserWindow::createSidebarsMenu(QMenu* menu)
void BrowserWindow::createEncodingMenu(QMenu* menu) void BrowserWindow::createEncodingMenu(QMenu* menu)
{ {
const QString activeCodecName = QWebEngineSettings::defaultSettings()->defaultTextEncoding(); const QString activeCodecName = mApp->webSettings()->defaultTextEncoding();
QStringList isoCodecs; QStringList isoCodecs;
QStringList utfCodecs; QStringList utfCodecs;

View File

@ -462,7 +462,7 @@ void MainApplication::destroyRestoreManager()
{ {
// Restore JavaScript settings // Restore JavaScript settings
const bool jsEnabled = Settings().value(QSL("Web-Browser-Settings/allowJavaScript"), true).toBool(); const bool jsEnabled = Settings().value(QSL("Web-Browser-Settings/allowJavaScript"), true).toBool();
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::JavascriptEnabled, jsEnabled); m_webProfile->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, jsEnabled);
delete m_restoreManager; delete m_restoreManager;
m_restoreManager = 0; m_restoreManager = 0;
@ -611,6 +611,11 @@ QWebEngineProfile *MainApplication::webProfile() const
return m_webProfile; return m_webProfile;
} }
QWebEngineSettings *MainApplication::webSettings() const
{
return m_webProfile->settings();
}
// static // static
MainApplication* MainApplication::instance() MainApplication* MainApplication::instance()
{ {
@ -878,7 +883,7 @@ void MainApplication::loadSettings()
loadTheme(activeTheme); loadTheme(activeTheme);
QWebEngineSettings* webSettings = QWebEngineSettings::defaultSettings(); QWebEngineSettings* webSettings = m_webProfile->settings();
// Web browsing settings // Web browsing settings
settings.beginGroup("Web-Browser-Settings"); settings.beginGroup("Web-Browser-Settings");

View File

@ -29,6 +29,7 @@
class QMenu; class QMenu;
class QWebEngineProfile; class QWebEngineProfile;
class QWebEngineSettings;
class QNetworkAccessManager; class QNetworkAccessManager;
class QWebEngineDownloadItem; class QWebEngineDownloadItem;
@ -112,6 +113,7 @@ public:
HTML5PermissionsManager* html5PermissionsManager(); HTML5PermissionsManager* html5PermissionsManager();
DesktopNotificationsFactory* desktopNotifications(); DesktopNotificationsFactory* desktopNotifications();
QWebEngineProfile* webProfile() const; QWebEngineProfile* webProfile() const;
QWebEngineSettings *webSettings() const;
QByteArray saveState() const; QByteArray saveState() const;

View File

@ -350,7 +350,7 @@ Preferences::Preferences(BrowserWindow* window)
//FONTS //FONTS
settings.beginGroup("Browser-Fonts"); settings.beginGroup("Browser-Fonts");
QWebEngineSettings* webSettings = QWebEngineSettings::defaultSettings(); QWebEngineSettings* webSettings = mApp->webSettings();
auto defaultFont = [&](QWebEngineSettings::FontFamily font) -> const QString { auto defaultFont = [&](QWebEngineSettings::FontFamily font) -> const QString {
const QString family = webSettings->fontFamily(font); const QString family = webSettings->fontFamily(font);
if (!family.isEmpty()) if (!family.isEmpty())

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* Falkon - Qt web browser * Falkon - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -93,7 +93,7 @@ bool WebInspector::isEnabled()
if (!qEnvironmentVariableIsSet("QTWEBENGINE_REMOTE_DEBUGGING")) { if (!qEnvironmentVariableIsSet("QTWEBENGINE_REMOTE_DEBUGGING")) {
return false; return false;
} }
if (!QWebEngineSettings::defaultSettings()->testAttribute(QWebEngineSettings::JavascriptEnabled)) { if (!mApp->webSettings()->testAttribute(QWebEngineSettings::JavascriptEnabled)) {
return false; return false;
} }
return true; return true;

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* StatusBarIcons - Extra icons in statusbar for Falkon * StatusBarIcons - Extra icons in statusbar for Falkon
* Copyright (C) 2013-2017 David Rosca <nowrep@gmail.com> * Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
#include "tabwidget.h" #include "tabwidget.h"
#include "tabbedwebview.h" #include "tabbedwebview.h"
#include "webpage.h" #include "webpage.h"
#include "mainapplication.h"
#include <QGraphicsColorizeEffect> #include <QGraphicsColorizeEffect>
#include <QSettings> #include <QSettings>
@ -40,7 +41,7 @@ SBI_ImagesIcon::SBI_ImagesIcon(BrowserWindow* window, const QString &settingsPat
m_loadingImages = settings.value("LoadImages", true).toBool(); m_loadingImages = settings.value("LoadImages", true).toBool();
settings.endGroup(); settings.endGroup();
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::AutoLoadImages, m_loadingImages); mApp->webSettings()->setAttribute(QWebEngineSettings::AutoLoadImages, m_loadingImages);
updateIcon(); updateIcon();
@ -97,7 +98,7 @@ void SBI_ImagesIcon::setGlobalLoadingImages(bool enable)
// Switch it in websettings // Switch it in websettings
m_loadingImages = enable; m_loadingImages = enable;
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::AutoLoadImages, m_loadingImages); mApp->webSettings()->setAttribute(QWebEngineSettings::AutoLoadImages, m_loadingImages);
updateIcon(); updateIcon();
// We should reload page on disabling images // We should reload page on disabling images