From 6e1dce0cd7783b22bd3ba28ccb359847cbdca7c6 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Fri, 8 Jul 2016 00:46:33 +0200 Subject: [PATCH] Fixed moving labels and added warning icon to detail dialog when detail name is empty --HG-- branch : feature --- src/libs/vtools/dialogs/tools/dialogdetail.cpp | 4 ++++ src/libs/vtools/tools/vtextgraphicsitem.cpp | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 3f6da9a01..f7eeebfc7 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -257,11 +257,15 @@ void DialogDetail::NameDetailChanged() { flagName = false; ChangeColor(labelEditNamePoint, Qt::red); + QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"); + ui.tabWidget->setTabIcon(1, icon); } else { flagName = true; ChangeColor(labelEditNamePoint, okColor); + QIcon icon; + ui.tabWidget->setTabIcon(1, icon); } } CheckState(); diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index 5975462dd..408a0d73d 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -242,11 +242,16 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME) QPointF pt = m_ptStartPos + ptDiff; pt.setX(pt.x() + m_rectBoundingBox.width()/2); pt.setY(pt.y() + m_rectBoundingBox.height()/2); - if (parentItem()->boundingRect().contains(pt) == true) + QRectF rectBB = parentItem()->boundingRect(); + if (rectBB.contains(pt) == false) { - setPos(m_ptStartPos + ptDiff); - UpdateBox(); + pt.setX(qMin(rectBB.right(), qMax(pt.x(), rectBB.left()))); + pt.setY(qMin(rectBB.bottom(), qMax(pt.y(), rectBB.top()))); } + pt.setX(pt.x() - m_rectBoundingBox.width()/2); + pt.setY(pt.y() - m_rectBoundingBox.height()/2); + setPos(pt); + UpdateBox(); } else if (m_eMode == mResize) {