From e83aac7af781f4ae764b4229b57480893a552516 Mon Sep 17 00:00:00 2001 From: Stefan Merettig Date: Wed, 25 Mar 2015 15:58:50 +0100 Subject: [PATCH] Screen grabber: Remove forced redraw If this doesn't help we'll need to split the screen capture display into tiles and display those instead, allowing Qt to only draw a few of them instead of everything. --- .../tool/screengrabberchooserrectitem.cpp | 1 - src/widget/tool/screengrabberoverlayitem.cpp | 17 ++++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/widget/tool/screengrabberchooserrectitem.cpp b/src/widget/tool/screengrabberchooserrectitem.cpp index 8a176d4b2..0d9b7a4d8 100644 --- a/src/widget/tool/screengrabberchooserrectitem.cpp +++ b/src/widget/tool/screengrabberchooserrectitem.cpp @@ -134,7 +134,6 @@ void ScreenGrabberChooserRectItem::mouseMove(QGraphicsSceneMouseEvent* event) } emit regionChosen(chosenRect()); - scene()->update(); } void ScreenGrabberChooserRectItem::mouseRelease(QGraphicsSceneMouseEvent* event) diff --git a/src/widget/tool/screengrabberoverlayitem.cpp b/src/widget/tool/screengrabberoverlayitem.cpp index 9641d0863..d57a3c5a5 100644 --- a/src/widget/tool/screengrabberoverlayitem.cpp +++ b/src/widget/tool/screengrabberoverlayitem.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "screenshotgrabber.h" @@ -41,8 +42,9 @@ ScreenGrabberOverlayItem::~ScreenGrabberOverlayItem() void ScreenGrabberOverlayItem::setChosenRect(QRect rect) { - this->chosenRect = rect; - update(); + QRect oldRect = chosenRect; + chosenRect = rect; + update(oldRect.united(rect)); } void ScreenGrabberOverlayItem::mousePressEvent(QGraphicsSceneMouseEvent* event) @@ -54,15 +56,6 @@ void ScreenGrabberOverlayItem::mousePressEvent(QGraphicsSceneMouseEvent* event) void ScreenGrabberOverlayItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { - if (!this->chosenRect.isValid()) - { - QGraphicsRectItem::paint(painter, option, widget); - return; - } - - // - painter->save(); - painter->setBrush(brush()); painter->setPen(pen()); @@ -76,6 +69,4 @@ void ScreenGrabberOverlayItem::paint(QPainter* painter, const QStyleOptionGraphi painter->drawRect(rightX, 0, self.width() - rightX, self.height()); // Right of chosen painter->drawRect(leftX, 0, chosenRect.width(), topY); // Top of chosen painter->drawRect(leftX, bottomY, chosenRect.width(), self.height() - bottomY); // Bottom of chosen - - painter->restore(); }