1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

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.
This commit is contained in:
Stefan Merettig 2015-03-26 16:44:59 +01:00 committed by tux3
parent db8b70e225
commit 076609afb9

View File

@ -62,7 +62,8 @@ ScreenGrabberChooserRectItem::~ScreenGrabberChooserRectItem()
QRectF ScreenGrabberChooserRectItem::boundingRect() const 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) void ScreenGrabberChooserRectItem::beginResize(QPointF mousePos)
@ -79,8 +80,20 @@ void ScreenGrabberChooserRectItem::beginResize(QPointF mousePos)
QRect ScreenGrabberChooserRectItem::chosenRect() const QRect ScreenGrabberChooserRectItem::chosenRect() const
{ {
QRect rect (x(), y(), this->rectWidth, this->rectHeight); QRect rect (x(), y(), rectWidth, rectHeight);
return rect.normalized(); 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() void ScreenGrabberChooserRectItem::showHandles()