mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Add Shortcut to Cancel current selection (#3751)
This PR adds the ability to close the selection using the Ctrl + Backspace key combination, addressing issue #3319. The new shortcut allows users to quickly exit the selection mode without relying on mouse interactions.
This commit is contained in:
@@ -214,6 +214,7 @@ These shortcuts are available in GUI mode:
|
|||||||
| <kbd>Ctrl</kbd> + <kbd>Q</kbd> | Leave the capture screen |
|
| <kbd>Ctrl</kbd> + <kbd>Q</kbd> | Leave the capture screen |
|
||||||
| <kbd>Ctrl</kbd> + <kbd>O</kbd> | Choose an app to open the capture |
|
| <kbd>Ctrl</kbd> + <kbd>O</kbd> | Choose an app to open the capture |
|
||||||
| <kbd>Ctrl</kbd> + <kbd>Return</kbd> | Commit text in text area|
|
| <kbd>Ctrl</kbd> + <kbd>Return</kbd> | Commit text in text area|
|
||||||
|
| <kbd>Ctrl</kbd> + <kbd>Backspace</kbd> | Cancel current selection |
|
||||||
| <kbd>Return</kbd> | Upload the selection to Imgur |
|
| <kbd>Return</kbd> | Upload the selection to Imgur |
|
||||||
| <kbd>Spacebar</kbd> | Toggle visibility of sidebar with options of the selected tool, color picker for the drawing color and history menu |
|
| <kbd>Spacebar</kbd> | 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 |
|
| Right Click | Show the color wheel |
|
||||||
|
|||||||
@@ -102,6 +102,7 @@
|
|||||||
;; Shortcut Settings for all tools
|
;; Shortcut Settings for all tools
|
||||||
;[Shortcuts]
|
;[Shortcuts]
|
||||||
;TYPE_ARROW=A
|
;TYPE_ARROW=A
|
||||||
|
;TYPE_CANCEL=Ctrl+Backspace
|
||||||
;TYPE_CIRCLE=C
|
;TYPE_CIRCLE=C
|
||||||
;TYPE_CIRCLECOUNT=
|
;TYPE_CIRCLECOUNT=
|
||||||
;TYPE_COMMIT_CURRENT_TOOL=Ctrl+Return
|
;TYPE_COMMIT_CURRENT_TOOL=Ctrl+Return
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ void ShortcutsWidget::loadShortcuts()
|
|||||||
appendShortcut("TYPE_COMMIT_CURRENT_TOOL", tr("Commit text in text area"));
|
appendShortcut("TYPE_COMMIT_CURRENT_TOOL", tr("Commit text in text area"));
|
||||||
appendShortcut("TYPE_DELETE_CURRENT_TOOL",
|
appendShortcut("TYPE_DELETE_CURRENT_TOOL",
|
||||||
tr("Delete selected drawn object"));
|
tr("Delete selected drawn object"));
|
||||||
|
appendShortcut("TYPE_CANCEL", tr("Cancel current selection"));
|
||||||
|
|
||||||
// non-editable shortcuts have an empty shortcut name
|
// non-editable shortcuts have an empty shortcut name
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
TYPE_SIZEDECREASE = 21,
|
TYPE_SIZEDECREASE = 21,
|
||||||
TYPE_INVERT = 22,
|
TYPE_INVERT = 22,
|
||||||
TYPE_ACCEPT = 23,
|
TYPE_ACCEPT = 23,
|
||||||
|
TYPE_CANCEL = 24,
|
||||||
};
|
};
|
||||||
Q_ENUM(Type);
|
Q_ENUM(Type);
|
||||||
|
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {
|
|||||||
SHORTCUT("TYPE_SAVE" , "Ctrl+S" ),
|
SHORTCUT("TYPE_SAVE" , "Ctrl+S" ),
|
||||||
SHORTCUT("TYPE_ACCEPT" , "Return" ),
|
SHORTCUT("TYPE_ACCEPT" , "Return" ),
|
||||||
SHORTCUT("TYPE_EXIT" , "Ctrl+Q" ),
|
SHORTCUT("TYPE_EXIT" , "Ctrl+Q" ),
|
||||||
|
SHORTCUT("TYPE_CANCEL" , "Ctrl+Backspace" ),
|
||||||
SHORTCUT("TYPE_IMAGEUPLOADER" , ),
|
SHORTCUT("TYPE_IMAGEUPLOADER" , ),
|
||||||
#if !defined(Q_OS_MACOS)
|
#if !defined(Q_OS_MACOS)
|
||||||
SHORTCUT("TYPE_OPEN_APP" , "Ctrl+O" ),
|
SHORTCUT("TYPE_OPEN_APP" , "Ctrl+O" ),
|
||||||
|
|||||||
@@ -796,7 +796,6 @@ void CaptureWidget::mousePressEvent(QMouseEvent* e)
|
|||||||
if (m_selection->getMouseSide(e->pos()) != SelectionWidget::CENTER) {
|
if (m_selection->getMouseSide(e->pos()) != SelectionWidget::CENTER) {
|
||||||
m_panel->setActiveLayer(-1);
|
m_panel->setActiveLayer(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->button() == Qt::RightButton) {
|
if (e->button() == Qt::RightButton) {
|
||||||
if (m_activeTool && m_activeTool->editMode()) {
|
if (m_activeTool && m_activeTool->editMode()) {
|
||||||
return;
|
return;
|
||||||
@@ -1603,6 +1602,10 @@ void CaptureWidget::initShortcuts()
|
|||||||
m_selection,
|
m_selection,
|
||||||
SLOT(moveDown()));
|
SLOT(moveDown()));
|
||||||
|
|
||||||
|
newShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_CANCEL")),
|
||||||
|
this,
|
||||||
|
SLOT(cancel()));
|
||||||
|
|
||||||
newShortcut(
|
newShortcut(
|
||||||
QKeySequence(ConfigHandler().shortcut("TYPE_DELETE_CURRENT_TOOL")),
|
QKeySequence(ConfigHandler().shortcut("TYPE_DELETE_CURRENT_TOOL")),
|
||||||
this,
|
this,
|
||||||
@@ -1914,6 +1917,23 @@ void CaptureWidget::redo()
|
|||||||
restoreCircleCountState();
|
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
|
QRect CaptureWidget::extendedSelection() const
|
||||||
{
|
{
|
||||||
if (m_selection == nullptr) {
|
if (m_selection == nullptr) {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
|
void cancel();
|
||||||
void togglePanel();
|
void togglePanel();
|
||||||
void childEnter();
|
void childEnter();
|
||||||
void childLeave();
|
void childLeave();
|
||||||
|
|||||||
Reference in New Issue
Block a user