mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-13 10:32:11 +01:00
WebPage: Always build nonblock js dialogs support
Can be enabled with QUPZILLA_ENABLE_JS_NONBLOCK_DIALOGS environment variable.
This commit is contained in:
parent
642d835d55
commit
f87c6897a0
17
BUILDING.md
17
BUILDING.md
|
@ -66,28 +66,13 @@ Available Defines
|
||||||
$ export NAME="value"
|
$ export NAME="value"
|
||||||
|
|
||||||
General:
|
General:
|
||||||
PORTABLE_BUILD Falkon won't write any data outside of path of execution.
|
PORTABLE_BUILD Falkon won't write any data outside of path of execution.
|
||||||
It will also disable plugins by default.
|
It will also disable plugins by default.
|
||||||
(disabled by default)
|
(disabled by default)
|
||||||
|
|
||||||
example:
|
example:
|
||||||
$ export PORTABLE_BUILD="true"
|
$ export PORTABLE_BUILD="true"
|
||||||
|
|
||||||
|
|
||||||
NONBLOCK_JS_DIALOGS Enable non-blocking JavaScript dialogs from alert() prompt()
|
|
||||||
and confirm() functions. They are shown inside page and are not
|
|
||||||
blocking application window.
|
|
||||||
However, due to synchronous API, there is a possible crash when
|
|
||||||
closing browser windows with opened dialogs.
|
|
||||||
If you can take this risk and/or make sure you aren't closing browser
|
|
||||||
with opened dialogs, you may enable this option.
|
|
||||||
These dialogs are much more beautiful than normal QDialogs.
|
|
||||||
(disabled by default)
|
|
||||||
|
|
||||||
example:
|
|
||||||
$ export NONBLOCK_JS_DIALOGS="true"
|
|
||||||
|
|
||||||
|
|
||||||
Windows specific defines:
|
Windows specific defines:
|
||||||
|
|
||||||
W7API Enable Windows 7 API support
|
W7API Enable Windows 7 API support
|
||||||
|
|
|
@ -55,10 +55,6 @@ option(PORTABLE_BUILD "TODO" OFF)
|
||||||
if (PORTABLE_BUILD)
|
if (PORTABLE_BUILD)
|
||||||
add_definitions(-DPORTABLE_BUILD)
|
add_definitions(-DPORTABLE_BUILD)
|
||||||
endif()
|
endif()
|
||||||
option(NONBLOCK_JS_DIALOGS "TODO" OFF)
|
|
||||||
if (NONBLOCK_JS_DIALOGS)
|
|
||||||
add_definitions(-DNONBLOCK_JS_DIALOGS)
|
|
||||||
endif()
|
|
||||||
option(DISABLE_DBUS "TODO" OFF)
|
option(DISABLE_DBUS "TODO" OFF)
|
||||||
if (DISABLE_DBUS)
|
if (DISABLE_DBUS)
|
||||||
add_definitions(-DDISABLE_DBUS)
|
add_definitions(-DDISABLE_DBUS)
|
||||||
|
|
|
@ -39,15 +39,10 @@
|
||||||
#include "networkmanager.h"
|
#include "networkmanager.h"
|
||||||
#include "webhittestresult.h"
|
#include "webhittestresult.h"
|
||||||
#include "adblock/adblockmanager.h"
|
#include "adblock/adblockmanager.h"
|
||||||
|
|
||||||
#ifdef NONBLOCK_JS_DIALOGS
|
|
||||||
#include "ui_jsconfirm.h"
|
#include "ui_jsconfirm.h"
|
||||||
#include "ui_jsalert.h"
|
#include "ui_jsalert.h"
|
||||||
#include "ui_jsprompt.h"
|
#include "ui_jsprompt.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -60,12 +55,14 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QAuthenticator>
|
#include <QAuthenticator>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
QString WebPage::s_lastUploadLocation = QDir::homePath();
|
QString WebPage::s_lastUploadLocation = QDir::homePath();
|
||||||
QUrl WebPage::s_lastUnsupportedUrl;
|
QUrl WebPage::s_lastUnsupportedUrl;
|
||||||
QTime WebPage::s_lastUnsupportedUrlTime;
|
QTime WebPage::s_lastUnsupportedUrlTime;
|
||||||
|
|
||||||
static const bool kEnableJsOutput = qEnvironmentVariableIsSet("QUPZILLA_ENABLE_JS_OUTPUT");
|
static const bool kEnableJsOutput = qEnvironmentVariableIsSet("QUPZILLA_ENABLE_JS_OUTPUT");
|
||||||
|
static const bool kEnableJsNonBlockDialogs = qEnvironmentVariableIsSet("QUPZILLA_ENABLE_JS_NONBLOCK_DIALOGS");
|
||||||
|
|
||||||
WebPage::WebPage(QObject* parent)
|
WebPage::WebPage(QObject* parent)
|
||||||
: QWebEnginePage(mApp->webProfile(), parent)
|
: QWebEnginePage(mApp->webProfile(), parent)
|
||||||
|
@ -429,11 +426,10 @@ QVector<PasswordEntry> WebPage::autoFillData() const
|
||||||
|
|
||||||
bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result)
|
bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result)
|
||||||
{
|
{
|
||||||
Q_UNUSED(securityOrigin)
|
if (!kEnableJsNonBlockDialogs) {
|
||||||
|
return QWebEnginePage::javaScriptPrompt(securityOrigin, msg, defaultValue, result);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NONBLOCK_JS_DIALOGS
|
|
||||||
return QWebEnginePage::javaScriptPrompt(securityOrigin, msg, defaultValue, result);
|
|
||||||
#else
|
|
||||||
if (m_runningLoop) {
|
if (m_runningLoop) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -469,16 +465,14 @@ bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, c
|
||||||
view()->setFocus();
|
view()->setFocus();
|
||||||
|
|
||||||
return _result;
|
return _result;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebPage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
|
bool WebPage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(securityOrigin)
|
if (!kEnableJsNonBlockDialogs) {
|
||||||
|
return QWebEnginePage::javaScriptConfirm(securityOrigin, msg);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NONBLOCK_JS_DIALOGS
|
|
||||||
return QWebEnginePage::javaScriptConfirm(securityOrigin, msg);
|
|
||||||
#else
|
|
||||||
if (m_runningLoop) {
|
if (m_runningLoop) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -510,7 +504,6 @@ bool WebPage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
|
||||||
view()->setFocus();
|
view()->setFocus();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
|
void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
|
||||||
|
@ -521,22 +514,24 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NONBLOCK_JS_DIALOGS
|
if (!kEnableJsNonBlockDialogs) {
|
||||||
QString title = tr("JavaScript alert");
|
QString title = tr("JavaScript alert");
|
||||||
if (!url().host().isEmpty()) {
|
if (!url().host().isEmpty()) {
|
||||||
title.append(QString(" - %1").arg(url().host()));
|
title.append(QString(" - %1").arg(url().host()));
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBoxDialog dialog(QMessageBox::Ok, view());
|
||||||
|
dialog.setDefaultButton(QMessageBox::Ok);
|
||||||
|
dialog.setWindowTitle(title);
|
||||||
|
dialog.setText(msg);
|
||||||
|
dialog.setCheckBoxText(tr("Prevent this page from creating additional dialogs"));
|
||||||
|
dialog.setIcon(QMessageBox::Information);
|
||||||
|
dialog.exec();
|
||||||
|
|
||||||
|
m_blockAlerts = dialog.isChecked();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckBoxDialog dialog(QMessageBox::Ok, view());
|
|
||||||
dialog.setDefaultButton(QMessageBox::Ok);
|
|
||||||
dialog.setWindowTitle(title);
|
|
||||||
dialog.setText(msg);
|
|
||||||
dialog.setCheckBoxText(tr("Prevent this page from creating additional dialogs"));
|
|
||||||
dialog.setIcon(QMessageBox::Information);
|
|
||||||
dialog.exec();
|
|
||||||
|
|
||||||
m_blockAlerts = dialog.isChecked();
|
|
||||||
#else
|
|
||||||
ResizableFrame* widget = new ResizableFrame(view()->overlayWidget());
|
ResizableFrame* widget = new ResizableFrame(view()->overlayWidget());
|
||||||
|
|
||||||
widget->setObjectName("jsFrame");
|
widget->setObjectName("jsFrame");
|
||||||
|
@ -563,7 +558,6 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
|
||||||
delete widget;
|
delete widget;
|
||||||
|
|
||||||
view()->setFocus();
|
view()->setFocus();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
|
void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user