From 698f7a0171e6438392e00df9d34864cf0830f6cb Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 29 Dec 2020 23:56:54 +0300 Subject: [PATCH] Added timeout before changing geometry --- common.pri | 2 +- limereport/lrbasedesignintf.cpp | 11 ++++++++++- limereport/lrbasedesignintf.h | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/common.pri b/common.pri index 0e9d5d6..a27590b 100644 --- a/common.pri +++ b/common.pri @@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 73 +LIMEREPORT_VERSION_RELEASE = 76 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 5df12fd..1f05f32 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -85,7 +85,9 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q m_fillTransparentInDesignMode(true), m_unitType(Millimeters), m_itemGeometryLocked(false), - m_isChangingPos(false) + m_isChangingPos(false), + m_isMoveable(false) + { setGeometry(QRectF(0, 0, m_width, m_height)); if (BaseDesignIntf *item = dynamic_cast(parent)) { @@ -387,6 +389,10 @@ void BaseDesignIntf::setFixedPos(bool fixedPos) m_fixedPos = fixedPos; } +void BaseDesignIntf::onChangeGeometryTimeOut(){ + m_isMoveable = true; +} + void BaseDesignIntf::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { @@ -396,6 +402,8 @@ void BaseDesignIntf::mousePressEvent(QGraphicsSceneMouseEvent *event) m_oldGeometry = geometry(); QGraphicsItem::mousePressEvent(event); emit(itemSelected(this)); + m_isMoveable = false; + m_timer.singleShot(200, this, SLOT(onChangeGeometryTimeOut())); } else QGraphicsItem::mousePressEvent(event); } @@ -524,6 +532,7 @@ void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/) void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { + if (!m_isMoveable) return; if (!isSelected()){ QGraphicsItem::mouseMoveEvent(event); return; diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 00fc807..08ab8ed 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -403,6 +403,9 @@ private: Qt::CursorShape getPossibleCursor(int cursorFlags); void updatePossibleDirectionFlags(); +private slots: + void onChangeGeometryTimeOut(); + private: QPointF m_startPos; int m_resizeHandleSize; @@ -463,6 +466,9 @@ private: UnitType m_unitType; bool m_itemGeometryLocked; bool m_isChangingPos; + bool m_isMoveable; + QTimer m_timer; + signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void posChanging(QObject* object, QPointF newPos, QPointF oldPos);