diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index a5f4a3a81..10f392748 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -59,6 +59,7 @@ VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent) m_rectBoundingBox.setTopLeft(QPointF(0, 0)); SetSize(MIN_W, m_iMinH); setZValue(TOP_Z); + setAcceptHoverEvents(true); } //--------------------------------------------------------------------------------------------------------------------- @@ -164,6 +165,16 @@ void VTextGraphicsItem::Reset() setZValue(TOP_Z); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VTextGraphicsItem::IsIdle checks if the item is in normal mode. + * @return true, if item is in normal mode and false otherwise. + */ +bool VTextGraphicsItem::IsIdle() const +{ + return m_eMode == mNormal; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VTextGraphicsItem::AddLine adds a line of text to the label list. If necessary, it also resizes the @@ -355,6 +366,10 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) SetOverrideCursor(cursorArrowCloseHand, 1, 1); } } + else + { + SetOverrideCursor(cursorArrowCloseHand, 1, 1); + } // raise the label and redraw it setZValue(TOP_Z + 1); UpdateBox(); @@ -436,7 +451,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) if (pME->button() == Qt::LeftButton) { // restore the cursor - if (m_eMode == mMove) + if (m_eMode == mMove || m_eMode == mRotate) { RestoreOverrideCursor(cursorArrowCloseHand); } @@ -488,6 +503,37 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VTextGraphicsItem::hoverMoveEvent checks if cursor has to be changed + * @param pHE pointer to the scene hover event + */ +void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) +{ + if (m_eMode == mMove || m_eMode == mResize) + { + if (m_rectResize.contains(pHE->pos()) == true) + { + SetOverrideCursor(Qt::SizeFDiagCursor); + } + else + { + RestoreOverrideCursor(Qt::SizeFDiagCursor); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VTextGraphicsItem::hoverLeaveEvent tries to restore normal mouse cursor + * @param pHE not used + */ +void VTextGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE) +{ + Q_UNUSED(pHE); + RestoreOverrideCursor(Qt::SizeFDiagCursor); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VTextGraphicsItem::UpdateBox redraws the label content diff --git a/src/libs/vtools/tools/vtextgraphicsitem.h b/src/libs/vtools/tools/vtextgraphicsitem.h index c601cc1e7..d8638eff6 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.h +++ b/src/libs/vtools/tools/vtextgraphicsitem.h @@ -59,6 +59,7 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void Reset(); + bool IsIdle() const; int GetFontSize() const; QRectF boundingRect() const; @@ -75,6 +76,8 @@ protected: void mousePressEvent(QGraphicsSceneMouseEvent* pME); void mouseMoveEvent(QGraphicsSceneMouseEvent* pME); void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME); + void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE); + void hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE); void UpdateBox(); void UpdateFont(); diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 1d827e268..be8d58ea0 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -331,6 +331,22 @@ void VToolDetail::FullUpdateFromGuiOk(int result) dialog = nullptr; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolDetail::paint draws a bounding box around detail, if one of its text items is not idle. + */ +void VToolDetail::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + if (dataLabel->IsIdle() == false || patternInfo->IsIdle() == false) + { + painter->save(); + painter->setPen(QPen(Qt::black, 3, Qt::DashLine)); + painter->drawRect(boundingRect().adjusted(1, 1, -1, -1)); + painter->restore(); + } + VNoBrushScalePathItem::paint(painter, option, widget); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToFile add tag with informations about tool into file. diff --git a/src/libs/vtools/tools/vtooldetail.h b/src/libs/vtools/tools/vtooldetail.h index a91526e05..9c470e96c 100644 --- a/src/libs/vtools/tools/vtooldetail.h +++ b/src/libs/vtools/tools/vtooldetail.h @@ -96,6 +96,8 @@ public slots: virtual void ResetChildren(QGraphicsItem* pItem); virtual void UpdateAll(); protected: + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget) Q_DECL_OVERRIDE; virtual void AddToFile () Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;