From 7cd504511cc89ea8addbbf5f8295ba7505ea0df4 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 2 Jul 2019 11:09:36 +0200 Subject: [PATCH] QmlDesigner: Hide the cursor when dragging in SpinBox Change-Id: I3900c510bc5510eaba51ea2ae8700aa9ca72f59a Reviewed-by: Thomas Hartmann --- .../imports/HelperWidgets/SpinBox.qml | 3 +++ .../propertyeditorcontextobject.cpp | 20 +++++++++++++++++++ .../propertyeditorcontextobject.h | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SpinBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SpinBox.qml index 8411e8d1733..2ec1052877a 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SpinBox.qml @@ -47,6 +47,9 @@ Item { StudioControls.RealSpinBox { id: spinBox + onDragStarted: hideCursor(); + onDragEnded: restoreCursor(); + property variant backendValue property bool hasSlider: wrapper.sliderIndicatorVisible diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index 8fdab5a821e..d553ccca222 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -35,6 +35,8 @@ #include #include +#include +#include #include static uchar fromHex(const uchar c, const uchar c2) @@ -386,4 +388,22 @@ void PropertyEditorContextObject::setHasAliasExport(bool hasAliasExport) emit hasAliasExportChanged(); } +void PropertyEditorContextObject::hideCursor() +{ + if (QApplication::overrideCursor()) + return; + + QApplication::setOverrideCursor(QCursor(Qt::BlankCursor)); + m_lastPos = QCursor::pos(); +} + +void PropertyEditorContextObject::restoreCursor() +{ + if (!QApplication::overrideCursor()) + return; + + QCursor::setPos(m_lastPos); + QApplication::restoreOverrideCursor(); +} + } //QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h index 42f4951a585..150800febae 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace QmlDesigner { @@ -85,6 +86,9 @@ public: Q_INVOKABLE void changeTypeName(const QString &typeName); Q_INVOKABLE void insertKeyframe(const QString &propertyName); + Q_INVOKABLE void hideCursor(); + Q_INVOKABLE void restoreCursor(); + int majorVersion() const; int majorQtQuickVersion() const; int minorQtQuickVersion() const; @@ -157,6 +161,8 @@ private: QQmlComponent *m_qmlComponent; QQmlContext *m_qmlContext; + QPoint m_lastPos; + Model *m_model = nullptr; bool m_aliasExport = false;