summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxwebview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx/qfxwebview.cpp')
-rw-r--r--src/declarative/fx/qfxwebview.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index a7d233f..347c9c2 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -131,6 +131,8 @@ public:
QWebSettings *s;
};
+QML_DECLARE_TYPE(QFxWebSettings)
+QML_DEFINE_NOCREATE_TYPE(QFxWebSettings)
class QFxWebViewPrivate : public QFxPaintedItemPrivate
{
@@ -781,6 +783,27 @@ void QFxWebView::keyReleaseEvent(QKeyEvent* event)
QFxPaintedItem::keyReleaseEvent(event);
}
+bool QFxWebView::sceneEvent(QEvent *event)
+{
+ Q_D(const QFxWebView);
+
+ if (d->interactive) {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
+ if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
+ if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
+ page()->event(event);
+ if (event->isAccepted())
+ return true;
+ }
+ }
+ }
+ }
+ return QFxPaintedItem::sceneEvent(event);
+}
+
+
+
/*!
\qmlproperty action WebView::back
This property holds the action for causing the previous URL in the history to be displayed.
@@ -951,7 +974,7 @@ QWebPage *QFxWebView::page() const
}
\endqml
*/
-QObject *QFxWebView::settingsObject() const
+QFxWebSettings *QFxWebView::settingsObject() const
{
Q_D(const QFxWebView);
d->settings.s = page()->settings();
@@ -1101,22 +1124,35 @@ public:
QmlEngine *engine = qmlEngine(webview);
component = new QmlComponent(engine, url, this);
item = 0;
- if (component->isReady())
- qmlLoaded();
- else
+ if (component->isLoading())
connect(component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(qmlLoaded()));
+ else
+ qmlLoaded();
}
public Q_SLOTS:
void qmlLoaded()
{
+ if (component->isError()) {
+ // XXX Could instead give these errors to the WebView to handle.
+ foreach (QmlError err, component->errors())
+ qWarning(err.toString().toLatin1());
+ return;
+ }
item = qobject_cast<QFxItem*>(component->create(qmlContext(webview)));
item->setParent(webview);
+ QString jsObjName;
for (int i=0; i<propertyNames.count(); ++i) {
if (propertyNames[i] != QLatin1String("type") && propertyNames[i] != QLatin1String("data")) {
item->setProperty(propertyNames[i].toLatin1(),propertyValues[i]);
+ if (propertyNames[i] == QLatin1String("objectname"))
+ jsObjName = propertyValues[i];
}
}
+ if (!jsObjName.isNull()) {
+ QWebFrame *f = webview->page()->mainFrame();
+ f->addToJavaScriptWindowObject(jsObjName, item);
+ }
resizeEvent(0);
delete component;
component = 0;