forked from qt-creator/qt-creator
QmlDesigner: Hide the cursor when dragging in SpinBox
Change-Id: I3900c510bc5510eaba51ea2ae8700aa9ca72f59a Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -47,6 +47,9 @@ Item {
|
||||
StudioControls.RealSpinBox {
|
||||
id: spinBox
|
||||
|
||||
onDragStarted: hideCursor();
|
||||
onDragEnded: restoreCursor();
|
||||
|
||||
property variant backendValue
|
||||
property bool hasSlider: wrapper.sliderIndicatorVisible
|
||||
|
||||
|
@@ -35,6 +35,8 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QQmlContext>
|
||||
|
||||
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
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <QQmlPropertyMap>
|
||||
#include <QQmlComponent>
|
||||
#include <QColor>
|
||||
#include <QPoint>
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user