Qet Shape Item : minor

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4081 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-07-31 13:29:23 +00:00
parent eaea6f889b
commit 0fdb244bb5

View File

@@ -176,7 +176,7 @@ void QetShapeItem::removePoints(int number)
* @return the bounding rect of this item * @return the bounding rect of this item
*/ */
QRectF QetShapeItem::boundingRect() const { QRectF QetShapeItem::boundingRect() const {
return shape().boundingRect(); return shape().boundingRect().adjusted(-6, -6, 6, 6);
} }
/** /**
@@ -198,7 +198,7 @@ QPainterPath QetShapeItem::shape() const
} }
QPainterPathStroker pps; QPainterPathStroker pps;
pps.setWidth(10); pps.setWidth(m_hovered? 10 : 1);
pps.setJoinStyle(Qt::RoundJoin); pps.setJoinStyle(Qt::RoundJoin);
path = pps.createStroke(path); path = pps.createStroke(path);
@@ -295,6 +295,8 @@ void QetShapeItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
void QetShapeItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void QetShapeItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
if (!isSelected()) return;
QVector <QPointF> vector; QVector <QPointF> vector;
switch (m_shapeType) switch (m_shapeType)
{ {
@@ -305,7 +307,7 @@ void QetShapeItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
} }
int handler = m_handler.pointIsHoverHandler(event->pos(), vector); int handler = m_handler.pointIsHoverHandler(event->pos(), vector);
if (isSelected() && handler >= 0) if (handler >= 0)
{ {
if (m_shapeType & (Line | Polygon)) { if (m_shapeType & (Line | Polygon)) {
setCursor(Qt::SizeAllCursor); setCursor(Qt::SizeAllCursor);
@@ -330,7 +332,7 @@ void QetShapeItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
*/ */
void QetShapeItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { void QetShapeItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
m_hovered = false; m_hovered = false;
setCursor(Qt::ArrowCursor); unsetCursor();
QetGraphicsItem::hoverLeaveEvent(event); QetGraphicsItem::hoverLeaveEvent(event);
} }
@@ -340,6 +342,8 @@ void QetShapeItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
* @param event * @param event
*/ */
void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{ {
setCursor(Qt::ClosedHandCursor); setCursor(Qt::ClosedHandCursor);
//Shape is selected, we see if user click in a handler //Shape is selected, we see if user click in a handler
@@ -365,6 +369,7 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
} }
}
QetGraphicsItem::mousePressEvent(event); QetGraphicsItem::mousePressEvent(event);
} }