1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

SBI_JavaScriptIcon: Fix temporarily enabling/disabling JavaScript

Closes #2560
This commit is contained in:
David Rosca 2018-01-22 14:50:23 +01:00
parent b0117c799b
commit 4e39cad310
2 changed files with 13 additions and 3 deletions

View File

@ -82,14 +82,22 @@ void SBI_JavaScriptIcon::updateIcon()
void SBI_JavaScriptIcon::toggleJavaScript()
{
if (!currentPage()) {
WebPage *page = currentPage();
if (!page) {
return;
}
bool current = testCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled);
setCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled, !current);
m_settings[page] = !current;
connect(page, &WebPage::navigationRequestAccepted, this, [=](const QUrl &, WebPage::NavigationType, bool isMainFrame) {
if (isMainFrame) {
page->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, m_settings[page]);
}
});
m_window->weView()->reload();
updateIcon();

View File

@ -1,6 +1,6 @@
/* ============================================================
* StatusBarIcons - Extra icons in statusbar for Falkon
* Copyright (C) 2013-2014 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
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#define SBI_JAVASCRIPTICON_H
#include <QIcon>
#include <QHash>
#include "sbi_icon.h"
@ -38,6 +39,7 @@ private slots:
private:
QIcon m_icon;
QHash<WebPage*, bool> m_settings;
};
#endif // SBI_JAVASCRIPTICON_H