From 076609afb9b3e2cd311ea8fd7caf710def31cf23 Mon Sep 17 00:00:00 2001 From: Stefan Merettig Date: Thu, 26 Mar 2015 16:44:59 +0100 Subject: [PATCH] Screen grabber: Calculate bounding rect, fixes some drawing issues This commit should fix drawing artifacts occuring when quickly clicking on the screen while moving the cursor in circles. --- .../tool/screengrabberchooserrectitem.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/widget/tool/screengrabberchooserrectitem.cpp b/src/widget/tool/screengrabberchooserrectitem.cpp index f44275a52..8e133110d 100644 --- a/src/widget/tool/screengrabberchooserrectitem.cpp +++ b/src/widget/tool/screengrabberchooserrectitem.cpp @@ -62,7 +62,8 @@ ScreenGrabberChooserRectItem::~ScreenGrabberChooserRectItem() QRectF ScreenGrabberChooserRectItem::boundingRect() const { - return QRectF(0, 0, this->rectWidth, this->rectHeight); + return QRectF(-HandleSize - 1, -HandleSize - 1, + rectWidth + HandleSize + 1, rectHeight + HandleSize + 1); } void ScreenGrabberChooserRectItem::beginResize(QPointF mousePos) @@ -79,8 +80,20 @@ void ScreenGrabberChooserRectItem::beginResize(QPointF mousePos) QRect ScreenGrabberChooserRectItem::chosenRect() const { - QRect rect (x(), y(), this->rectWidth, this->rectHeight); - return rect.normalized(); + QRect rect (x(), y(), rectWidth, rectHeight); + if (rectWidth < 0) + { + rect.setX(rect.x() + rectWidth); + rect.setWidth(-rectWidth); + } + + if (rectHeight < 0) + { + rect.setY(rect.y() + rectHeight); + rect.setHeight(-rectHeight); + } + + return rect; } void ScreenGrabberChooserRectItem::showHandles()