From f2d5b00fd9960e20989f3dcb8bcf791e83bd89c8 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Tue, 2 Aug 2016 22:51:40 +0200 Subject: [PATCH] Detail bounding box is drawn when one of its items is in move, resize or rotate mode --HG-- branch : feature --- src/libs/vtools/tools/vtextgraphicsitem.cpp | 10 ++++++++++ src/libs/vtools/tools/vtextgraphicsitem.h | 1 + src/libs/vtools/tools/vtooldetail.cpp | 16 ++++++++++++++++ src/libs/vtools/tools/vtooldetail.h | 2 ++ 4 files changed, 29 insertions(+) diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index a5f4a3a81..252ffbb74 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -164,6 +164,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 diff --git a/src/libs/vtools/tools/vtextgraphicsitem.h b/src/libs/vtools/tools/vtextgraphicsitem.h index c601cc1e7..ef8dfe2b8 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; 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;