diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-18 23:35:40 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-18 23:35:40 (GMT) |
commit | 27888400bffdf033f4df48d29fde429efdf2b51c (patch) | |
tree | fd438c3e731cfb3879fd49da1faf0ebd1c4a6b60 | |
parent | 0b991014c55d02211eee01cad44b4ca4a2edb07d (diff) | |
download | Qt-27888400bffdf033f4df48d29fde429efdf2b51c.zip Qt-27888400bffdf033f4df48d29fde429efdf2b51c.tar.gz Qt-27888400bffdf033f4df48d29fde429efdf2b51c.tar.bz2 |
Pass error messages through to WebView users.
-rw-r--r-- | demos/declarative/webbrowser/webbrowser.qml | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview.cpp | 29 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview_p.h | 7 |
3 files changed, 38 insertions, 0 deletions
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 0f6ed25..345c9af 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -196,6 +196,8 @@ Item { fillColor: "white" focus: true + onAlert: print(message) + function doZoom(zoom,centerX,centerY) { if (centerX) { diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index da6c00d..e165e59 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -1192,6 +1192,35 @@ QmlGraphicsWebPage::~QmlGraphicsWebPage() { } +void QmlGraphicsWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) +{ + qWarning() << sourceID << ":" << lineNumber << ":" << message; +} + +QString QmlGraphicsWebPage::chooseFile(QWebFrame *originatingFrame, const QString& oldFile) +{ + // Not supported (it's modal) + return oldFile; +} + +void QmlGraphicsWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QString& msg) +{ + emit viewItem()->alert(msg); +} + +bool QmlGraphicsWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg) +{ + // Not supported (it's modal) + return false; +} + +bool QmlGraphicsWebPage::javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result) +{ + // Not supported (it's modal) + return false; +} + + /* Qt WebKit does not understand non-QWidget plugins, so dummy widgets are created, parented to a single dummy tool window. diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index e2e4888..fa7d19d 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -69,6 +69,11 @@ public: protected: QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); QWebPage *createWindow(WebWindowType type); + void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID); + QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile); + void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg); + bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg); + bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result); private: QmlGraphicsWebView *viewItem(); @@ -195,6 +200,8 @@ Q_SIGNALS: void zoomTo(qreal zoom, int centerX, int centerY); + void alert(const QString& message); + public Q_SLOTS: QVariant evaluateJavaScript(const QString&); |