diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-11-08 20:43:34 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-11-08 20:43:34 +0100 |
commit | a18ebe8898af23f6ebd59d14e378967d983fe1d1 (patch) | |
tree | c3140cd5660fa0028b636d9c0ed8172f1630bc5b | |
parent | 707c13fcdf2cbc7e6021cbca3cc4b30fd7b9dcfc (diff) | |
parent | f3fdb0d2200ee1fa06bb8620f8bef84a37ab753a (diff) | |
download | qtwebengine-a18ebe8898af23f6ebd59d14e378967d983fe1d1.tar.gz |
Merge 5.9 into 5.9.3
Change-Id: I2839bdbacad0836c16e9c04fcd33509e024c614c
-rw-r--r-- | src/core/web_contents_adapter.cpp | 6 | ||||
-rw-r--r-- | src/core/web_contents_adapter.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 2 | ||||
-rw-r--r-- | src/webengine/ui_delegates_manager.cpp | 33 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 2 |
5 files changed, 40 insertions, 4 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 7c74bb7fd..1930e7a0e 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1427,6 +1427,12 @@ void WebContentsAdapter::focusIfNecessary() d->webContents->Focus(); } +bool WebContentsAdapter::isFindTextInProgress() const +{ + Q_D(const WebContentsAdapter); + return d->lastFindRequestId != d->webContentsDelegate->lastReceivedFindReply(); +} + WebContentsAdapterClient::RenderProcessTerminationStatus WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) { auto status = WebContentsAdapterClient::RenderProcessTerminationStatus(-1); diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 67fcbe7af..51fd2891d 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -184,6 +184,7 @@ public: void viewSource(); bool canViewSource(); void focusIfNecessary(); + bool isFindTextInProgress() const; private: 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(); } 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<FilePickerController> 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) diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index c583c7f51..9d8d52886 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -1433,7 +1433,7 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl & { Q_Q(QWebEnginePage); bool accepted = q->acceptNavigationRequest(url, static_cast<QWebEnginePage::NavigationType>(navigationType), isMainFrame); - if (accepted && adapter) + if (accepted && adapter && adapter->isFindTextInProgress()) adapter->stopFinding(); navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest; } |