diff --git a/README.md b/README.md
index 5b57540f..77551b16 100644
--- a/README.md
+++ b/README.md
@@ -214,6 +214,7 @@ These shortcuts are available in GUI mode:
| Ctrl + Q | Leave the capture screen |
| Ctrl + O | Choose an app to open the capture |
| Ctrl + Return | Commit text in text area|
+| Ctrl + Backspace | Cancel current selection |
| Return | Upload the selection to Imgur |
| Spacebar | Toggle visibility of sidebar with options of the selected tool, color picker for the drawing color and history menu |
| Right Click | Show the color wheel |
diff --git a/flameshot.example.ini b/flameshot.example.ini
index 22cb4f27..c7bcf721 100644
--- a/flameshot.example.ini
+++ b/flameshot.example.ini
@@ -102,6 +102,7 @@
;; Shortcut Settings for all tools
;[Shortcuts]
;TYPE_ARROW=A
+;TYPE_CANCEL=Ctrl+Backspace
;TYPE_CIRCLE=C
;TYPE_CIRCLECOUNT=
;TYPE_COMMIT_CURRENT_TOOL=Ctrl+Return
diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp
index e00e5c5f..9dd71a9e 100644
--- a/src/config/shortcutswidget.cpp
+++ b/src/config/shortcutswidget.cpp
@@ -192,6 +192,7 @@ void ShortcutsWidget::loadShortcuts()
appendShortcut("TYPE_COMMIT_CURRENT_TOOL", tr("Commit text in text area"));
appendShortcut("TYPE_DELETE_CURRENT_TOOL",
tr("Delete selected drawn object"));
+ appendShortcut("TYPE_CANCEL", tr("Cancel current selection"));
// non-editable shortcuts have an empty shortcut name
diff --git a/src/tools/capturetool.h b/src/tools/capturetool.h
index a095d618..a4e9715b 100644
--- a/src/tools/capturetool.h
+++ b/src/tools/capturetool.h
@@ -48,6 +48,7 @@ public:
TYPE_SIZEDECREASE = 21,
TYPE_INVERT = 22,
TYPE_ACCEPT = 23,
+ TYPE_CANCEL = 24,
};
Q_ENUM(Type);
diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp
index 6307fcd9..1a081c17 100644
--- a/src/utils/confighandler.cpp
+++ b/src/utils/confighandler.cpp
@@ -146,6 +146,7 @@ static QMap> recognizedShortcuts = {
SHORTCUT("TYPE_SAVE" , "Ctrl+S" ),
SHORTCUT("TYPE_ACCEPT" , "Return" ),
SHORTCUT("TYPE_EXIT" , "Ctrl+Q" ),
+ SHORTCUT("TYPE_CANCEL" , "Ctrl+Backspace" ),
SHORTCUT("TYPE_IMAGEUPLOADER" , ),
#if !defined(Q_OS_MACOS)
SHORTCUT("TYPE_OPEN_APP" , "Ctrl+O" ),
diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp
index 5b456529..f7e7b278 100644
--- a/src/widgets/capture/capturewidget.cpp
+++ b/src/widgets/capture/capturewidget.cpp
@@ -796,7 +796,6 @@ void CaptureWidget::mousePressEvent(QMouseEvent* e)
if (m_selection->getMouseSide(e->pos()) != SelectionWidget::CENTER) {
m_panel->setActiveLayer(-1);
}
-
if (e->button() == Qt::RightButton) {
if (m_activeTool && m_activeTool->editMode()) {
return;
@@ -1603,6 +1602,10 @@ void CaptureWidget::initShortcuts()
m_selection,
SLOT(moveDown()));
+ newShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_CANCEL")),
+ this,
+ SLOT(cancel()));
+
newShortcut(
QKeySequence(ConfigHandler().shortcut("TYPE_DELETE_CURRENT_TOOL")),
this,
@@ -1914,6 +1917,23 @@ void CaptureWidget::redo()
restoreCircleCountState();
}
+void CaptureWidget::cancel()
+{
+ if (m_activeButton != nullptr) {
+ uncheckActiveTool();
+ }
+ if (m_panel) {
+ m_panel->setActiveLayer(-1);
+ }
+ if (m_toolWidget) {
+ m_toolWidget->hide();
+ delete m_toolWidget;
+ m_toolWidget = nullptr;
+ }
+ m_selection->hide();
+ emit m_selection->geometrySettled();
+}
+
QRect CaptureWidget::extendedSelection() const
{
if (m_selection == nullptr) {
diff --git a/src/widgets/capture/capturewidget.h b/src/widgets/capture/capturewidget.h
index 4602e30e..8d9383dc 100644
--- a/src/widgets/capture/capturewidget.h
+++ b/src/widgets/capture/capturewidget.h
@@ -70,6 +70,7 @@ signals:
private slots:
void undo();
void redo();
+ void cancel();
void togglePanel();
void childEnter();
void childLeave();