diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index d9009e9e7..4c7b0a667 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -66,7 +66,6 @@ VToolLine::VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent) firstPoint(initData.firstPoint), secondPoint(initData.secondPoint), lineColor(initData.lineColor), - m_isHovered(false), m_acceptHoverEvents(true) { m_isBoldLine = false; @@ -183,10 +182,11 @@ QString VToolLine::getTagName() const //--------------------------------------------------------------------------------------------------------------------- void VToolLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - const qreal width = ScaleWidth(m_isHovered ? qApp->Settings()->WidthMainLine() : qApp->Settings()->WidthHairLine(), - SceneScale(scene())); - - setPen(QPen(CorrectColor(this, lineColor), width, LineStyleToPenStyle(m_lineType))); + // Don't set pen width. Parent should take care of it. + QPen lPen = pen(); + lPen.setColor(CorrectColor(this, lineColor)); + lPen.setStyle(LineStyleToPenStyle(m_lineType)); + setPen(lPen); PaintWithFixItemHighlightSelected(this, painter, option, widget); } @@ -291,7 +291,6 @@ void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { if (m_acceptHoverEvents) { - m_isHovered = true; m_isBoldLine = true; setToolTip(MakeToolTip()); VScaledLine::hoverEnterEvent(event); @@ -311,7 +310,6 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { if (m_acceptHoverEvents && vis.isNull()) { - m_isHovered = false; m_isBoldLine = false; VScaledLine::hoverLeaveEvent(event); } diff --git a/src/libs/vtools/tools/drawTools/vtoolline.h b/src/libs/vtools/tools/drawTools/vtoolline.h index c4eb885a8..9a712157a 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.h +++ b/src/libs/vtools/tools/drawTools/vtoolline.h @@ -123,7 +123,6 @@ private: /** @brief lineColor color of a line. */ QString lineColor; - bool m_isHovered; bool m_acceptHoverEvents; VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent = nullptr); diff --git a/src/libs/vwidgets/scalesceneitems.cpp b/src/libs/vwidgets/scalesceneitems.cpp index c0a34eff0..cddb3b8e2 100644 --- a/src/libs/vwidgets/scalesceneitems.cpp +++ b/src/libs/vwidgets/scalesceneitems.cpp @@ -36,13 +36,17 @@ VScaledLine::VScaledLine(QGraphicsItem *parent) : QGraphicsLineItem(parent), m_isBoldLine(true) -{} +{ + QGraphicsItem::setCacheMode(QGraphicsItem::DeviceCoordinateCache); // Fix problem with constant redraw +} //--------------------------------------------------------------------------------------------------------------------- VScaledLine::VScaledLine(const QLineF &line, QGraphicsItem *parent) : QGraphicsLineItem(line, parent), m_isBoldLine(true) -{} +{ + QGraphicsItem::setCacheMode(QGraphicsItem::DeviceCoordinateCache); // Fix problem with constant redraw +} //--------------------------------------------------------------------------------------------------------------------- void VScaledLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)