From ef1d61a3516182b0a39330b5ac5988f92c82bc4f Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Tue, 3 Oct 2017 13:14:58 +0200 Subject: Pass editor shortcuts to Chromium by ForwardKeyboardEventWithCommands Moreover, extend the list of supported editor shortcuts and stabilize the corresponding auto test. Task-number: QTBUG-54692 Task-number: QTBUG-54812 Task-number: QTBUG-54221 Task-number: QTBUG-59053 Change-Id: I4dd8230519639ea6e3340992dbb54a609ecfcd91 Reviewed-by: Alexandru Croitor --- src/webengine/api/qquickwebengineview.cpp | 33 ---------------------- .../render_widget_host_view_qt_delegate_quick.cpp | 2 +- 2 files changed, 1 insertion(+), 34 deletions(-) (limited to 'src/webengine') diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 3da21fde5..f5d3646d8 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -94,27 +94,6 @@ QT_BEGIN_NAMESPACE using namespace QtWebEngineCore; -QQuickWebEngineView::WebAction editorActionForKeyEvent(QKeyEvent* event) -{ - static struct { - QKeySequence::StandardKey standardKey; - QQuickWebEngineView::WebAction action; - } editorActions[] = { - { QKeySequence::Cut, QQuickWebEngineView::Cut }, - { QKeySequence::Copy, QQuickWebEngineView::Copy }, - { QKeySequence::Paste, QQuickWebEngineView::Paste }, - { QKeySequence::Undo, QQuickWebEngineView::Undo }, - { QKeySequence::Redo, QQuickWebEngineView::Redo }, - { QKeySequence::SelectAll, QQuickWebEngineView::SelectAll }, - { QKeySequence::UnknownKey, QQuickWebEngineView::NoWebAction } - }; - for (int i = 0; editorActions[i].standardKey != QKeySequence::UnknownKey; ++i) - if (event == editorActions[i].standardKey) - return editorActions[i].action; - - return QQuickWebEngineView::NoWebAction; -} - #ifndef QT_NO_ACCESSIBILITY static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object) { @@ -578,18 +557,6 @@ void QQuickWebEngineViewPrivate::focusContainer() void QQuickWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event) { Q_Q(QQuickWebEngineView); -#ifdef Q_OS_OSX - if (event->type() == QEvent::KeyPress) { - QQuickWebEngineView::WebAction action = editorActionForKeyEvent(event); - if (action != QQuickWebEngineView::NoWebAction) { - // Try triggering a registered short-cut - if (QGuiApplicationPrivate::instance()->shortcutMap.tryShortcut(event)) - return; - q->triggerWebAction(action); - return; - } - } -#endif if (q->parentItem()) QCoreApplication::sendEvent(q->parentItem(), event); } diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp index cde742c39..0e06ddbce 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp @@ -225,7 +225,7 @@ void RenderWidgetHostViewQtDelegateQuick::inputMethodStateChanged(bool editorVis bool RenderWidgetHostViewQtDelegateQuick::event(QEvent *event) { if (event->type() == QEvent::ShortcutOverride) - return m_client->handleShortcutOverrideEvent(static_cast(event)); + return m_client->forwardEvent(event); #ifndef QT_NO_GESTURES if (event->type() == QEvent::NativeGesture) -- cgit v1.2.3 From e9309d91ac3ec0ddd7076b5cf66655380aa82cac Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 8 Sep 2017 13:21:38 +0200 Subject: Fix position of keyboard-invoked context menu in QQuickWebEngineView In QQuickWebEngineView the context menu is a QtQuickControls.Menu item. This menu is shown by calling popup() which always displays the menu below the mouse cursor. Work around the problem by moving the mouse cursor temporarily to the right position. Use a QObject property "pos" to store the requested menu position between addMenu() and showMenu() calls, because the Menu item doesn't have a "pos" QML property. Change-Id: Id772a0bb1a7548cad932e9f499ade68be32d86d3 Reviewed-by: Peter Varga --- src/webengine/ui_delegates_manager.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/webengine') diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index 6cc496d5b..c9c013d52 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -257,7 +257,7 @@ QObject *UIDelegatesManager::addMenu(QObject *parentMenu, const QString &title, if (!title.isEmpty()) QQmlProperty(menu, QStringLiteral("title")).write(title); if (!pos.isNull()) - QQmlProperty(menu, QStringLiteral("pos")).write(pos); + menu->setProperty("pos", pos); menu->setParent(parentMenu); @@ -496,9 +496,38 @@ void UIDelegatesManager::showFilePicker(QSharedPointer con QMetaObject::invokeMethod(filePicker, "open"); } +class TemporaryCursorMove +{ +public: + TemporaryCursorMove(const QQuickItem *item, const QPoint &pos) + { + if (pos.isNull() || !item->contains(pos)) + return; + const QPoint oldPos = QCursor::pos(); + const QPoint globalPos = item->mapToGlobal(QPointF(pos)).toPoint(); + if (oldPos == globalPos) + return; + m_oldCursorPos = oldPos; + QCursor::setPos(globalPos); + } + + ~TemporaryCursorMove() + { + if (!m_oldCursorPos.isNull()) + QCursor::setPos(m_oldCursorPos); + } + +private: + QPoint m_oldCursorPos; +}; + void UIDelegatesManager::showMenu(QObject *menu) { - QMetaObject::invokeMethod(menu, "popup"); + // QtQuick.Controls.Menu.popup() always shows the menu under the mouse cursor, i.e. the menu's + // position we set above is ignored. Work around the problem by moving the mouse cursor + // temporarily to the right position. + TemporaryCursorMove tcm(m_view, menu->property("pos").toPoint()); + QMetaObject::invokeMethod(menu, "popup"); } void UIDelegatesManager::showMessageBubble(const QRect &anchor, const QString &mainText, const QString &subText) -- cgit v1.2.3 From f3fdb0d2200ee1fa06bb8620f8bef84a37ab753a Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 3 Nov 2017 10:12:31 +0100 Subject: Do not stop findText on navigation if no finding in progress Avoid unnecessary unselect calls to prevent to lose active focus on an input field during background load. Task-number: QTBUG-64082 Change-Id: I13e8e2a96254360a78329d6ea2b6858da86a2b5a Reviewed-by: Viktor Engelmann --- src/webengine/api/qquickwebengineview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/webengine') diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 53f4f5855..25f578528 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -356,7 +356,7 @@ void QQuickWebEngineViewPrivate::navigationRequested(int navigationType, const Q Q_EMIT q->navigationRequested(&navigationRequest); navigationRequestAction = navigationRequest.action(); - if ((navigationRequestAction == WebContentsAdapterClient::AcceptRequest) && adapter) + if ((navigationRequestAction == WebContentsAdapterClient::AcceptRequest) && adapter && adapter->isFindTextInProgress()) adapter->stopFinding(); } -- cgit v1.2.3 From 4de8486b6614896a2b84cc64b69606c7b3bd07e8 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Mon, 6 Nov 2017 16:04:45 +0100 Subject: Notify Chromium about leaving view Forward QEvent::Leave for Widget and QEvent::HoverLeave for Quick. Task-number: QTBUG-64265 Change-Id: Ide32768902956476d24b1d4115e305392b62feb3 Reviewed-by: Allan Sandfeld Jensen --- src/webengine/render_widget_host_view_qt_delegate_quick.cpp | 5 +++++ src/webengine/render_widget_host_view_qt_delegate_quick.h | 1 + 2 files changed, 6 insertions(+) (limited to 'src/webengine') diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp index 5d8c4fa43..0d77a5040 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp @@ -332,6 +332,11 @@ void RenderWidgetHostViewQtDelegateQuick::hoverMoveEvent(QHoverEvent *event) m_client->forwardEvent(event); } +void RenderWidgetHostViewQtDelegateQuick::hoverLeaveEvent(QHoverEvent *event) +{ + m_client->forwardEvent(event); +} + QVariant RenderWidgetHostViewQtDelegateQuick::inputMethodQuery(Qt::InputMethodQuery query) const { return m_client->inputMethodQuery(query); diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h index 7a08e915b..eeb7db9cb 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.h +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h @@ -90,6 +90,7 @@ protected: virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; virtual void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE; virtual void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + virtual void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; virtual void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE; virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; -- cgit v1.2.3 From 2ed1e0ba423a75f68c1547fe0c06e62e773ef64d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 24 Oct 2017 18:51:42 +0200 Subject: Add 'webengine' prefix to configure features, tests, libraries, etc This is done to make sure there are no conflicts with features in other modules, because they all share a global namespace. Change-Id: I95b3b7fadd8ffc2979ee3aad2234ee543d57c7d8 Reviewed-by: Michal Klocek --- src/webengine/webengine.pro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/webengine') diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro index 24fa2d9d8..58e1263a7 100644 --- a/src/webengine/webengine.pro +++ b/src/webengine/webengine.pro @@ -58,7 +58,7 @@ HEADERS = \ render_widget_host_view_qt_delegate_quickwindow.h \ ui_delegates_manager.h -qtConfig(testsupport) { +qtConfig(webengine-testsupport) { QT += testlib SOURCES += api/qquickwebenginetestsupport.cpp @@ -67,11 +67,11 @@ qtConfig(testsupport) { DEFINES += ENABLE_QML_TESTSUPPORT_API } -qtConfig(spellchecker) { +qtConfig(webengine-spellchecker) { DEFINES += ENABLE_SPELLCHECK } -qtConfig(printing-and-pdf) { +qtConfig(webengine-printing-and-pdf) { DEFINES += ENABLE_PDF } -- cgit v1.2.3