Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NC: fix - reset the margin of the selected annotation #2170

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tools/capturetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/tools/copy/copytool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/tools/imgupload/imguploadertool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/tools/pin/pintool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/tools/save/savetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -1485,7 +1491,9 @@ void CaptureWidget::drawToolsData()
}

m_context.screenshot = pixmapItem;
drawObjectSelection();
if (drawSelection) {
drawObjectSelection();
}
}

void CaptureWidget::drawObjectSelection()
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/capture/capturewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down