mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 02:52:12 +01:00
[ExternalJsObject] Add window.external Js object to all pages
SpeedDial is now available with external.speeddial
This commit is contained in:
parent
aa6aea1399
commit
1a5fc6a1a1
|
@ -250,7 +250,8 @@ SOURCES += \
|
||||||
network/sslerrordialog.cpp \
|
network/sslerrordialog.cpp \
|
||||||
adblock/adblocksearchtree.cpp \
|
adblock/adblocksearchtree.cpp \
|
||||||
tools/tabstackedwidget.cpp \
|
tools/tabstackedwidget.cpp \
|
||||||
tools/combotabbar.cpp
|
tools/combotabbar.cpp \
|
||||||
|
webview/javascript/externaljsobject.cpp
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
@ -437,7 +438,8 @@ HEADERS += \
|
||||||
network/sslerrordialog.h \
|
network/sslerrordialog.h \
|
||||||
adblock/adblocksearchtree.h \
|
adblock/adblocksearchtree.h \
|
||||||
tools/tabstackedwidget.h \
|
tools/tabstackedwidget.h \
|
||||||
tools/combotabbar.h
|
tools/combotabbar.h \
|
||||||
|
webview/javascript/externaljsobject.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
|
|
39
src/lib/webview/javascript/externaljsobject.cpp
Normal file
39
src/lib/webview/javascript/externaljsobject.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2014 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "externaljsobject.h"
|
||||||
|
#include "mainapplication.h"
|
||||||
|
#include "pluginproxy.h"
|
||||||
|
#include "speeddial.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
ExternalJsObject::ExternalJsObject(QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, m_onSpeedDial(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject* ExternalJsObject::speedDial()
|
||||||
|
{
|
||||||
|
return m_onSpeedDial ? mApp->plugins()->speedDial() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExternalJsObject::setOnSpeedDial(bool on)
|
||||||
|
{
|
||||||
|
m_onSpeedDial = on;
|
||||||
|
}
|
42
src/lib/webview/javascript/externaljsobject.h
Normal file
42
src/lib/webview/javascript/externaljsobject.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2014 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef EXTERNALJSOBJECT_H
|
||||||
|
#define EXTERNALJSOBJECT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class ExternalJsObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QObject* speedDial READ speedDial)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExternalJsObject(QObject* parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
QObject* speedDial();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setOnSpeedDial(bool on);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_onSpeedDial;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EXTERNALJSOBJECT_H
|
|
@ -40,6 +40,7 @@
|
||||||
#include "recoverywidget.h"
|
#include "recoverywidget.h"
|
||||||
#include "html5permissions/html5permissionsmanager.h"
|
#include "html5permissions/html5permissionsmanager.h"
|
||||||
#include "schemehandlers/fileschemehandler.h"
|
#include "schemehandlers/fileschemehandler.h"
|
||||||
|
#include "javascript/externaljsobject.h"
|
||||||
|
|
||||||
#ifdef NONBLOCK_JS_DIALOGS
|
#ifdef NONBLOCK_JS_DIALOGS
|
||||||
#include "ui_jsconfirm.h"
|
#include "ui_jsconfirm.h"
|
||||||
|
@ -69,7 +70,6 @@ QList<WebPage*> WebPage::s_livingPages;
|
||||||
WebPage::WebPage(QObject* parent)
|
WebPage::WebPage(QObject* parent)
|
||||||
: QWebPage(parent)
|
: QWebPage(parent)
|
||||||
, m_view(0)
|
, m_view(0)
|
||||||
, m_speedDial(mApp->plugins()->speedDial())
|
|
||||||
, m_fileWatcher(0)
|
, m_fileWatcher(0)
|
||||||
, m_runningLoop(0)
|
, m_runningLoop(0)
|
||||||
, m_loadProgress(-1)
|
, m_loadProgress(-1)
|
||||||
|
@ -291,12 +291,13 @@ void WebPage::addJavaScriptObject()
|
||||||
settings()->setAttribute(QWebSettings::JavascriptEnabled, m_javaScriptEnabled);
|
settings()->setAttribute(QWebSettings::JavascriptEnabled, m_javaScriptEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url().toString() != QLatin1String("qupzilla:speeddial")) {
|
ExternalJsObject* jsObject = new ExternalJsObject(this);
|
||||||
return;
|
mainFrame()->addToJavaScriptWindowObject("external", jsObject);
|
||||||
}
|
|
||||||
|
|
||||||
mainFrame()->addToJavaScriptWindowObject("speeddial", m_speedDial);
|
if (url().toString() == QLatin1String("qupzilla:speeddial")) {
|
||||||
m_speedDial->addWebFrame(mainFrame());
|
jsObject->setOnSpeedDial(true);
|
||||||
|
mApp->plugins()->speedDial()->addWebFrame(mainFrame());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebPage::handleUnsupportedContent(QNetworkReply* reply)
|
void WebPage::handleUnsupportedContent(QNetworkReply* reply)
|
||||||
|
|
|
@ -133,7 +133,6 @@ private:
|
||||||
|
|
||||||
NetworkManagerProxy* m_networkProxy;
|
NetworkManagerProxy* m_networkProxy;
|
||||||
TabbedWebView* m_view;
|
TabbedWebView* m_view;
|
||||||
SpeedDial* m_speedDial;
|
|
||||||
DelayedFileWatcher* m_fileWatcher;
|
DelayedFileWatcher* m_fileWatcher;
|
||||||
QEventLoop* m_runningLoop;
|
QEventLoop* m_runningLoop;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user