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

Add Shortcut to Cancel current selection #3751

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ These shortcuts are available in GUI mode:
| <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>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>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 |
Expand Down
1 change: 1 addition & 0 deletions flameshot.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,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
Expand Down
1 change: 1 addition & 0 deletions src/config/shortcutswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void ShortcutsWidget::loadShortcuts()
appendShortcut("TYPE_MOVE_DOWN", tr("Move selection down 1px"));
appendShortcut("TYPE_COMMIT_CURRENT_TOOL", tr("Commit text in text area"));
appendShortcut("TYPE_DELETE_CURRENT_TOOL", tr("Delete current tool"));
appendShortcut("TYPE_CANCLE", tr("Cancel current selection"));

// non-editable shortcuts have an empty shortcut name

Expand Down
1 change: 1 addition & 0 deletions src/tools/capturetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class CaptureTool : public QObject
TYPE_SIZEDECREASE = 21,
TYPE_INVERT = 22,
TYPE_ACCEPT = 23,
TYPE_CANCEL = 24,
};
Q_ENUM(Type);

Expand Down
1 change: 1 addition & 0 deletions src/utils/confighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ static QMap<QString, QSharedPointer<KeySequence>> 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" ),
Expand Down
22 changes: 21 additions & 1 deletion src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,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;
Expand Down Expand Up @@ -1560,6 +1559,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,
Expand Down Expand Up @@ -1871,6 +1874,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) {
Expand Down
1 change: 1 addition & 0 deletions src/widgets/capture/capturewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public slots:
private slots:
void undo();
void redo();
void cancel();
void togglePanel();
void childEnter();
void childLeave();
Expand Down