From 49c615c1989d9fcfce7ed1be805538a9dca6a8a8 Mon Sep 17 00:00:00 2001 From: Taras Oleksyn Date: Sat, 29 Nov 2025 10:17:28 +0200 Subject: [PATCH] Add cancel button to capture window to improve touchscreen usability BUG: 490980 --- src/CMakeLists.txt | 1 + src/Gui/CancelAction.qml | 11 +++++++++++ src/Gui/CaptureOverlay.qml | 14 ++++++++++++++ src/Gui/CaptureWindow.cpp | 5 +++++ src/Gui/CaptureWindow.h | 1 + src/PlasmaVersion.h | 2 +- 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/Gui/CancelAction.qml diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 23fc4f483..f4957bda7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,6 +158,7 @@ qt_target_qml_sources(spectacle Gui/AnnotationOptionsToolBarContents.qml Gui/AnnotationsToolBarContents.qml Gui/ButtonGrid.qml + Gui/CancelAction.qml Gui/CaptureModeButtonsColumn.qml Gui/CaptureOptions.qml Gui/CaptureOverlay.qml diff --git a/src/Gui/CancelAction.qml b/src/Gui/CancelAction.qml new file mode 100644 index 000000000..74bf54816 --- /dev/null +++ b/src/Gui/CancelAction.qml @@ -0,0 +1,11 @@ +/* SPDX-FileCopyrightText: 2025 Noah Davis + * SPDX-License-Identifier: LGPL-2.0-or-later + */ + +import QtQuick.Templates as T + +T.Action { + icon.name: "dialog-cancel" + text: i18nc("@action cancel selection", "Cancel") + onTriggered: contextWindow.cancel() +} diff --git a/src/Gui/CaptureOverlay.qml b/src/Gui/CaptureOverlay.qml index e5089934d..5c15d9939 100644 --- a/src/Gui/CaptureOverlay.qml +++ b/src/Gui/CaptureOverlay.qml @@ -491,6 +491,11 @@ MouseArea { visible: action.enabled action: AcceptAction {} } + ToolButton { + display: TtToolButton.TextBesideIcon + visible: action.enabled + action: CancelAction {} + } ToolButton { display: TtToolButton.IconOnly visible: action.enabled @@ -527,6 +532,10 @@ MouseArea { visible: action.enabled action: AcceptAction {} } + ToolButton { + visible: action.enabled + action: CancelAction {} + } ToolButton { visible: action.enabled action: SaveAction {} @@ -560,6 +569,11 @@ MouseArea { visible: action.enabled action: RecordAction {} } + ToolButton { + display: TtToolButton.TextBesideIcon + visible: action.enabled + action: CancelAction {} + } } } diff --git a/src/Gui/CaptureWindow.cpp b/src/Gui/CaptureWindow.cpp index cb8ce97ab..c263d1b45 100644 --- a/src/Gui/CaptureWindow.cpp +++ b/src/Gui/CaptureWindow.cpp @@ -129,6 +129,11 @@ bool CaptureWindow::accept() return SelectionEditor::instance()->acceptSelection(); } +void CaptureWindow::cancel() +{ + SpectacleCore::instance()->cancelScreenshot(); +} + void CaptureWindow::save() { SelectionEditor::instance()->acceptSelection(ExportManager::Save | ExportManager::UserAction); diff --git a/src/Gui/CaptureWindow.h b/src/Gui/CaptureWindow.h index b5e87a834..0d50aac90 100644 --- a/src/Gui/CaptureWindow.h +++ b/src/Gui/CaptureWindow.h @@ -34,6 +34,7 @@ public: public Q_SLOTS: bool accept(); + void cancel(); void save() override; void saveAs() override; void copyImage() override; diff --git a/src/PlasmaVersion.h b/src/PlasmaVersion.h index 08502c895..9518da62b 100644 --- a/src/PlasmaVersion.h +++ b/src/PlasmaVersion.h @@ -15,7 +15,7 @@ public: static quint32 get(); /** - * Use this for plasama versions the same way you'd use QT_VERSION_CHECK() + * Use this for plasma versions the same way you'd use QT_VERSION_CHECK() */ static quint32 check(quint8 major, quint8 minor, quint8 patch); -- GitLab