Merge pull request #990 from ra3xdh/fix-drawresizehandle-usage

Fix unnecessary setPen before draw_resize_handle
This commit is contained in:
Sergei Krasilnikov 2024-10-12 11:58:31 +03:00 committed by GitHub
commit aae2501748
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 7 deletions

View File

@ -116,7 +116,7 @@ void TabDiagram::paintDiagram(QPainter *painter) {
if (isSelected) {
painter->setPen(QPen(Qt::darkGray,3));
painter->drawRect(-5, -y2-5, x2+10, y2+10);
painter->setPen(QPen(Qt::darkRed,2));
misc::draw_resize_handle(painter, QPoint{0, -y2});
misc::draw_resize_handle(painter, QPoint{0, 0});
misc::draw_resize_handle(painter, QPoint{x2, -y2});

View File

@ -846,11 +846,12 @@ void misc::draw_resize_handle(QPainter* painter, const QPointF& center) {
// 1. Find out where on canvas lies the central point and remember these
// coordinates
// 2. Remove all transformations and draw the handle in its natural size
QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size
static QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size
resize_handle.moveCenter(painter->transform().map(center));
static QTransform transform{}; // reset transformation
painter->save();
painter->setTransform(QTransform{});
painter->setTransform(transform);
painter->setPen(QPen{Qt::darkRed, 2});
painter->drawRect(resize_handle);
painter->restore();

View File

@ -57,8 +57,6 @@ void qucs::Ellipse::paint(QPainter *painter) {
painter->setPen(QPen(Qt::white, Pen.width(), Pen.style()));
painter->drawEllipse(cx, cy, x2, y2);
painter->setPen(QPen(Qt::darkRed,2));
misc::draw_resize_handle(painter, QPoint{cx, cy});
misc::draw_resize_handle(painter, QPoint{cx, cy + y2});
misc::draw_resize_handle(painter, QPoint{cx + x2, cy});

View File

@ -52,8 +52,6 @@ void EllipseArc::paint(QPainter *painter) {
painter->setPen(QPen(Qt::white, Pen.width(), Pen.style()));
painter->drawArc(cx, cy, x2, y2, Angle, ArcLen);
painter->setPen(QPen(Qt::darkRed, 2));
misc::draw_resize_handle(painter, QPoint{cx, cy});
misc::draw_resize_handle(painter, QPoint{cx, cy + y2});
misc::draw_resize_handle(painter, QPoint{cx + x2, cy});