summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-11-08 20:43:34 +0100
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-11-08 20:43:34 +0100
commita18ebe8898af23f6ebd59d14e378967d983fe1d1 (patch)
treec3140cd5660fa0028b636d9c0ed8172f1630bc5b
parent707c13fcdf2cbc7e6021cbca3cc4b30fd7b9dcfc (diff)
parentf3fdb0d2200ee1fa06bb8620f8bef84a37ab753a (diff)
Merge 5.9 into 5.9.3
-rw-r--r--src/core/web_contents_adapter.cpp6
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/webengine/api/qquickwebengineview.cpp2
-rw-r--r--src/webengine/ui_delegates_manager.cpp33
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp2
5 files changed, 40 insertions, 4 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 7c74bb7f..1930e7a0 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 67fcbe7a..51fd2891 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 53f4f585..25f57852 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 6cc496d5..c9c013d5 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 c583c7f5..9d8d5288 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;
}