From 27888400bffdf033f4df48d29fde429efdf2b51c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 19 Nov 2009 09:35:40 +1000 Subject: Pass error messages through to WebView users. --- demos/declarative/webbrowser/webbrowser.qml | 2 ++ .../graphicsitems/qmlgraphicswebview.cpp | 29 ++++++++++++++++++++++ .../graphicsitems/qmlgraphicswebview_p.h | 7 ++++++ 3 files changed, 38 insertions(+) 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&); -- cgit v0.12