diff --git a/src/tools/capturetool.h b/src/tools/capturetool.h index 3daad476e6..e9fc669fe8 100644 --- a/src/tools/capturetool.h +++ b/src/tools/capturetool.h @@ -66,6 +66,8 @@ class CaptureTool : public QObject REQ_SHOW_COLOR_PICKER, // Notify is the screenshot has been saved. REQ_CAPTURE_DONE_OK, + // Notify to redraw screenshot with tools without object selection. + REQ_CLEAR_SELECTION, // Instance this->widget()'s widget inside the editor under the mouse. REQ_ADD_CHILD_WIDGET, // Instance this->widget()'s widget which handles its own lifetime. diff --git a/src/tools/copy/copytool.cpp b/src/tools/copy/copytool.cpp index f9b02d3edc..99dddc0076 100644 --- a/src/tools/copy/copytool.cpp +++ b/src/tools/copy/copytool.cpp @@ -41,6 +41,7 @@ CaptureTool* CopyTool::copy(QObject* parent) void CopyTool::pressed(CaptureContext& context) { + emit requestAction(REQ_CLEAR_SELECTION); context.request.addTask(CaptureRequest::COPY); emit requestAction(REQ_CAPTURE_DONE_OK); emit requestAction(REQ_CLOSE_GUI); diff --git a/src/tools/imgupload/imguploadertool.cpp b/src/tools/imgupload/imguploadertool.cpp index f6057a4969..4c51f6ce34 100644 --- a/src/tools/imgupload/imguploadertool.cpp +++ b/src/tools/imgupload/imguploadertool.cpp @@ -40,6 +40,7 @@ CaptureTool* ImgUploaderTool::copy(QObject* parent) void ImgUploaderTool::pressed(CaptureContext& context) { + emit requestAction(REQ_CLEAR_SELECTION); emit requestAction(REQ_CAPTURE_DONE_OK); context.request.addTask(CaptureRequest::UPLOAD); emit requestAction(REQ_CLOSE_GUI); diff --git a/src/tools/pin/pintool.cpp b/src/tools/pin/pintool.cpp index a022e07f1c..ff75d74700 100644 --- a/src/tools/pin/pintool.cpp +++ b/src/tools/pin/pintool.cpp @@ -42,6 +42,7 @@ CaptureTool* PinTool::copy(QObject* parent) void PinTool::pressed(CaptureContext& context) { + emit requestAction(REQ_CLEAR_SELECTION); emit requestAction(REQ_CAPTURE_DONE_OK); context.request.addTask(CaptureRequest::PIN); emit requestAction(REQ_CLOSE_GUI); diff --git a/src/tools/save/savetool.cpp b/src/tools/save/savetool.cpp index 95856660a7..d377703784 100644 --- a/src/tools/save/savetool.cpp +++ b/src/tools/save/savetool.cpp @@ -41,6 +41,7 @@ CaptureTool* SaveTool::copy(QObject* parent) void SaveTool::pressed(CaptureContext& context) { + emit requestAction(REQ_CLEAR_SELECTION); context.request.addSaveTask(); emit requestAction(REQ_CAPTURE_DONE_OK); emit requestAction(REQ_CLOSE_GUI); diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index af8b0d57bb..ede1f1ebc7 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -1143,6 +1143,12 @@ void CaptureWidget::handleToolSignal(CaptureTool::Request r) case CaptureTool::REQ_CAPTURE_DONE_OK: m_captureDone = true; break; + case CaptureTool::REQ_CLEAR_SELECTION: + if (m_panel->activeLayerIndex() >= 0) { + m_panel->setActiveLayer(-1); + drawToolsData(false); + } + break; case CaptureTool::REQ_ADD_CHILD_WIDGET: if (!m_activeTool) { break; @@ -1470,7 +1476,7 @@ void CaptureWidget::pushToolToStack() } } -void CaptureWidget::drawToolsData() +void CaptureWidget::drawToolsData(bool drawSelection) { // TODO refactor this for performance. The objects should not all be updated // at once every time @@ -1485,7 +1491,9 @@ void CaptureWidget::drawToolsData() } m_context.screenshot = pixmapItem; - drawObjectSelection(); + if (drawSelection) { + drawObjectSelection(); + } } void CaptureWidget::drawObjectSelection() diff --git a/src/widgets/capture/capturewidget.h b/src/widgets/capture/capturewidget.h index f213eac374..93d51412bd 100644 --- a/src/widgets/capture/capturewidget.h +++ b/src/widgets/capture/capturewidget.h @@ -127,7 +127,7 @@ private slots: QRect paddedUpdateRect(const QRect& r) const; void drawErrorMessage(const QString& msg, QPainter* painter); void drawInactiveRegion(QPainter* painter); - void drawToolsData(); + void drawToolsData(bool drawSelection = true); void drawObjectSelection(); void processPixmapWithTool(QPixmap* pixmap, CaptureTool* tool);