mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
parent
5230554943
commit
d5ea5342cf
@ -77,6 +77,8 @@ WebPage::WebPage(QObject* parent)
|
||||
, m_secureStatus(false)
|
||||
, m_adjustingScheduled(false)
|
||||
{
|
||||
m_javaScriptEnabled = mApp->webSettings()->testAttribute(QWebSettings::JavascriptEnabled);
|
||||
|
||||
m_networkProxy = new NetworkManagerProxy(this);
|
||||
m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager());
|
||||
m_networkProxy->setPage(this);
|
||||
@ -286,7 +288,7 @@ void WebPage::addJavaScriptObject()
|
||||
// Make sure all other sites have JavaScript set by user preferences
|
||||
// (JavaScript is enabled in WebPage::urlChanged)
|
||||
if (url().scheme() != QLatin1String("qupzilla")) {
|
||||
settings()->setAttribute(QWebSettings::JavascriptEnabled, mApp->webSettings()->testAttribute(QWebSettings::JavascriptEnabled));
|
||||
settings()->setAttribute(QWebSettings::JavascriptEnabled, m_javaScriptEnabled);
|
||||
}
|
||||
|
||||
if (url().toString() != QLatin1String("qupzilla:speeddial")) {
|
||||
@ -996,6 +998,12 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebPage::setJavaScriptEnabled(bool enabled)
|
||||
{
|
||||
settings()->setAttribute(QWebSettings::JavascriptEnabled, enabled);
|
||||
m_javaScriptEnabled = enabled;
|
||||
}
|
||||
|
||||
QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile)
|
||||
{
|
||||
QString suggFileName;
|
||||
|
@ -63,6 +63,8 @@ public:
|
||||
bool javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg);
|
||||
void javaScriptAlert(QWebFrame* originatingFrame, const QString &msg);
|
||||
|
||||
void setJavaScriptEnabled(bool enabled);
|
||||
|
||||
void addAdBlockRule(const AdBlockRule* rule, const QUrl &url);
|
||||
QVector<AdBlockedEntry> adBlockedEntries() const;
|
||||
|
||||
@ -146,6 +148,7 @@ private:
|
||||
int m_loadProgress;
|
||||
bool m_blockAlerts;
|
||||
bool m_secureStatus;
|
||||
bool m_javaScriptEnabled;
|
||||
bool m_adjustingScheduled;
|
||||
};
|
||||
|
||||
|
@ -55,6 +55,11 @@ void SBI_JavaScriptIcon::showMenu(const QPoint &point)
|
||||
menu.addAction(tr("Enable JavaScript (temporarily)"), this, SLOT(toggleJavaScript()));
|
||||
}
|
||||
|
||||
// JavaScript needs to be always enabled for qupzilla: sites
|
||||
if (currentPage()->url().scheme() == QLatin1String("qupzilla")) {
|
||||
menu.actions().at(1)->setEnabled(false);
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_icon, tr("Global settings"))->setFont(boldFont);
|
||||
menu.addAction(tr("Manage JavaScript settings"), this, SLOT(openJavaScriptSettings()));
|
||||
@ -76,7 +81,7 @@ void SBI_JavaScriptIcon::updateIcon()
|
||||
void SBI_JavaScriptIcon::toggleJavaScript()
|
||||
{
|
||||
bool current = currentPageSettings()->testAttribute(QWebSettings::JavascriptEnabled);
|
||||
currentPageSettings()->setAttribute(QWebSettings::JavascriptEnabled, !current);
|
||||
currentPage()->setJavaScriptEnabled(!current);
|
||||
|
||||
p_QupZilla->weView()->reload();
|
||||
|
||||
@ -89,7 +94,12 @@ void SBI_JavaScriptIcon::openJavaScriptSettings()
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
WebPage* SBI_JavaScriptIcon::currentPage()
|
||||
{
|
||||
return p_QupZilla->weView()->page();
|
||||
}
|
||||
|
||||
QWebSettings* SBI_JavaScriptIcon::currentPageSettings()
|
||||
{
|
||||
return p_QupZilla->weView()->page()->settings();
|
||||
return currentPage()->settings();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
class QWebSettings;
|
||||
|
||||
class QupZilla;
|
||||
class WebPage;
|
||||
|
||||
class SBI_JavaScriptIcon : public ClickableLabel
|
||||
{
|
||||
@ -41,6 +42,7 @@ private slots:
|
||||
void openJavaScriptSettings();
|
||||
|
||||
private:
|
||||
WebPage* currentPage();
|
||||
QWebSettings* currentPageSettings();
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
|
Loading…
Reference in New Issue
Block a user