mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
SBI_JavaScriptIcon: Fix temporarily enabling/disabling JavaScript
Closes #2560
This commit is contained in:
parent
b0117c799b
commit
4e39cad310
|
@ -82,14 +82,22 @@ void SBI_JavaScriptIcon::updateIcon()
|
||||||
|
|
||||||
void SBI_JavaScriptIcon::toggleJavaScript()
|
void SBI_JavaScriptIcon::toggleJavaScript()
|
||||||
{
|
{
|
||||||
if (!currentPage()) {
|
WebPage *page = currentPage();
|
||||||
|
if (!page) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool current = testCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled);
|
bool current = testCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled);
|
||||||
setCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled, !current);
|
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();
|
m_window->weView()->reload();
|
||||||
|
|
||||||
updateIcon();
|
updateIcon();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* StatusBarIcons - Extra icons in statusbar for Falkon
|
* 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
|
* 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
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
#define SBI_JAVASCRIPTICON_H
|
#define SBI_JAVASCRIPTICON_H
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "sbi_icon.h"
|
#include "sbi_icon.h"
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
|
QHash<WebPage*, bool> m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SBI_JAVASCRIPTICON_H
|
#endif // SBI_JAVASCRIPTICON_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user