forked from qt-creator/qt-creator
QmlDesigner: Fix fly mode speed on macOS
Task-number: QDS-12337 Change-Id: I7590cd79a8d3b0b27cad7edb5e11be091223b6fb Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
committed by
Miikka Heikkinen
parent
af6dcb6659
commit
465a2e7ac4
@@ -81,11 +81,20 @@ QWidget *Edit3DCanvas::busyIndicator() const
|
|||||||
return m_busyIndicator;
|
return m_busyIndicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
extern "C" bool AXIsProcessTrusted();
|
||||||
|
#endif
|
||||||
|
|
||||||
void Edit3DCanvas::setFlyMode(bool enabled, const QPoint &pos)
|
void Edit3DCanvas::setFlyMode(bool enabled, const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (m_flyMode == enabled)
|
if (m_flyMode == enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
if (!AXIsProcessTrusted())
|
||||||
|
m_isTrusted = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_flyMode = enabled;
|
m_flyMode = enabled;
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
@@ -190,7 +199,8 @@ void Edit3DCanvas::mouseMoveEvent(QMouseEvent *e)
|
|||||||
// We notify explicit camera rotation need for puppet rather than rely in mouse events,
|
// We notify explicit camera rotation need for puppet rather than rely in mouse events,
|
||||||
// as mouse isn't grabbed on puppet side and can't handle fast movements that go out of
|
// as mouse isn't grabbed on puppet side and can't handle fast movements that go out of
|
||||||
// edit camera mouse area. This also simplifies split view handling.
|
// edit camera mouse area. This also simplifies split view handling.
|
||||||
QPointF diff = m_hiddenCursorPos - e->globalPos();
|
QPointF diff = m_isTrusted ? (m_hiddenCursorPos - e->globalPos()) : (m_lastCursorPos - e->globalPos());
|
||||||
|
|
||||||
if (e->buttons() == (Qt::LeftButton | Qt::RightButton)) {
|
if (e->buttons() == (Qt::LeftButton | Qt::RightButton)) {
|
||||||
m_parent->view()->emitView3DAction(View3DActionType::EditCameraMove,
|
m_parent->view()->emitView3DAction(View3DActionType::EditCameraMove,
|
||||||
QVector3D{float(-diff.x()), float(-diff.y()), 0.f});
|
QVector3D{float(-diff.x()), float(-diff.y()), 0.f});
|
||||||
@@ -201,7 +211,11 @@ void Edit3DCanvas::mouseMoveEvent(QMouseEvent *e)
|
|||||||
// Skip first move to avoid undesirable jump occasionally when initiating flight mode
|
// Skip first move to avoid undesirable jump occasionally when initiating flight mode
|
||||||
m_flyModeFirstUpdate = false;
|
m_flyModeFirstUpdate = false;
|
||||||
}
|
}
|
||||||
QCursor::setPos(m_hiddenCursorPos);
|
|
||||||
|
if (m_isTrusted)
|
||||||
|
QCursor::setPos(m_hiddenCursorPos);
|
||||||
|
else
|
||||||
|
m_lastCursorPos = e->globalPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,10 +53,12 @@ private:
|
|||||||
qint32 m_activeScene = -1;
|
qint32 m_activeScene = -1;
|
||||||
QElapsedTimer m_usageTimer;
|
QElapsedTimer m_usageTimer;
|
||||||
qreal m_opacity = 1.0;
|
qreal m_opacity = 1.0;
|
||||||
|
bool m_isTrusted = true;
|
||||||
QWidget *m_busyIndicator = nullptr;
|
QWidget *m_busyIndicator = nullptr;
|
||||||
bool m_flyMode = false;
|
bool m_flyMode = false;
|
||||||
QPoint m_flyModeStartCursorPos;
|
QPoint m_flyModeStartCursorPos;
|
||||||
QPoint m_hiddenCursorPos;
|
QPoint m_hiddenCursorPos;
|
||||||
|
QPoint m_lastCursorPos;
|
||||||
qint64 m_flyModeStartTime = 0;
|
qint64 m_flyModeStartTime = 0;
|
||||||
bool m_flyModeFirstUpdate = false;
|
bool m_flyModeFirstUpdate = false;
|
||||||
bool m_contextMenuPending = false;
|
bool m_contextMenuPending = false;
|
||||||
|
Reference in New Issue
Block a user