From c43166759a84ba990c644a200a939b672f98b88b Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Sun, 17 Nov 2024 01:48:21 -0700 Subject: [PATCH] Use keyPressEvent rather than shortcut for polyline delete segment The shortcut, which by default is the Backspace key, will prevent the keypress from being received by ScribbleArea::keyPressEvent, which in turn breaks the delete selection action. --- ChangeLog.md | 1 + app/src/mainwindow2.cpp | 6 ------ app/src/shortcutspage.cpp | 1 - app/ui/mainwindow2.ui | 8 -------- core_lib/data/resources/kb.ini | 1 - core_lib/src/tool/polylinetool.cpp | 9 ++++++--- core_lib/src/tool/polylinetool.h | 3 +-- core_lib/src/util/pencildef.h | 1 - 8 files changed, 8 insertions(+), 22 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5a6fde35b6..ea550e1595 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -17,6 +17,7 @@ + Fix hanging when adjusting cursor because of too many writes to disk [#1853](https://github.com/pencil2d/pencil/pull/1853) + Avoid updating width/feather sliders for tools that don’t use them [cce3107](https://github.com/pencil2d/pencil/commit/cce31079c871fcc04e957c44d5c6e65990f635f1) + Fix fill misbehaving when drawing was partly outside border [#1865](https://github.com/pencil2d/pencil/pull/1865) ++ Fix clearing selection with the delete shortcut [#1892](https://github.com/pencil2d/pencil/pull/1892) ## Pencil2D v0.7.0 - 12 July 2024 diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index aba7dae7d2..c4ec3d1a6f 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -40,7 +40,6 @@ GNU General Public License for more details. #include "pencilsettings.h" #include "object.h" #include "editor.h" -#include "polylinetool.h" #include "filemanager.h" #include "colormanager.h" @@ -265,7 +264,6 @@ void MainWindow2::createMenus() //--- Edit Menu --- replaceUndoRedoActions(); - connect(ui->actionRemoveLastPolylineSegment, &QAction::triggered, static_cast(mEditor->tools()->getTool(POLYLINE)), &PolylineTool::removeLastPolylineSegment); connect(ui->actionCut, &QAction::triggered, mEditor, &Editor::copyAndCut); connect(ui->actionCopy, &QAction::triggered, mEditor, &Editor::copy); connect(ui->actionPaste_Previous, &QAction::triggered, mEditor, &Editor::pasteFromPreviousFrame); @@ -1207,7 +1205,6 @@ void MainWindow2::setupKeyboardShortcuts() // edit menu ui->actionUndo->setShortcut(cmdKeySeq(CMD_UNDO)); ui->actionRedo->setShortcut(cmdKeySeq(CMD_REDO)); - ui->actionRemoveLastPolylineSegment->setShortcut(cmdKeySeq(CMD_REMOVE_LAST_POLYLINE_SEGMENT)); ui->actionCut->setShortcut(cmdKeySeq(CMD_CUT)); ui->actionCopy->setShortcut(cmdKeySeq(CMD_COPY)); ui->actionPaste_Previous->setShortcut(cmdKeySeq(CMD_PASTE_FROM_PREVIOUS)); @@ -1323,9 +1320,6 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionHelp->setShortcut(cmdKeySeq(CMD_HELP)); ui->actionExit->setShortcut(cmdKeySeq(CMD_EXIT)); - - // Actions not in a menu won't work unless added to a widget - addAction(ui->actionRemoveLastPolylineSegment); } void MainWindow2::clearKeyboardShortcuts() diff --git a/app/src/shortcutspage.cpp b/app/src/shortcutspage.cpp index 66caf4dc6f..36e887b6a0 100644 --- a/app/src/shortcutspage.cpp +++ b/app/src/shortcutspage.cpp @@ -400,7 +400,6 @@ static QString getHumanReadableShortcutName(const QString& cmdName) {CMD_CHANGE_LINE_COLOR_LAYER, ShortcutsPage::tr("Change Line Color (All keyframes on layer)", "Shortcut")}, {CMD_CHANGE_LAYER_OPACITY, ShortcutsPage::tr("Change Layer / Keyframe Opacity", "Shortcut")}, {CMD_UNDO, ShortcutsPage::tr("Undo", "Shortcut")}, - {CMD_REMOVE_LAST_POLYLINE_SEGMENT, ShortcutsPage::tr("Remove Last Polyline Segment", "Shortcut")}, {CMD_ZOOM_100, ShortcutsPage::tr("Set Zoom to 100%", "Shortcut")}, {CMD_ZOOM_200, ShortcutsPage::tr("Set Zoom to 200%", "Shortcut")}, {CMD_ZOOM_25, ShortcutsPage::tr("Set Zoom to 25%", "Shortcut")}, diff --git a/app/ui/mainwindow2.ui b/app/ui/mainwindow2.ui index 68a843fe20..39773e41ac 100644 --- a/app/ui/mainwindow2.ui +++ b/app/ui/mainwindow2.ui @@ -1273,14 +1273,6 @@ 30° - - - Remove Last Polyline Segment - - - Removes the lastest Polyline segment - - diff --git a/core_lib/data/resources/kb.ini b/core_lib/data/resources/kb.ini index afcd263ec0..310431e1bc 100644 --- a/core_lib/data/resources/kb.ini +++ b/core_lib/data/resources/kb.ini @@ -20,7 +20,6 @@ CmdExportMovie= CmdExportGIF=Ctrl+G CmdExportPalette= CmdUndo=Ctrl+Z -CmdRemoveLastPolylineSegment=Backspace CmdRedo=Ctrl+Shift+Z CmdCut=Ctrl+X CmdCopy=Ctrl+C diff --git a/core_lib/src/tool/polylinetool.cpp b/core_lib/src/tool/polylinetool.cpp index 97dd109248..14dc6d44e0 100644 --- a/core_lib/src/tool/polylinetool.cpp +++ b/core_lib/src/tool/polylinetool.cpp @@ -216,8 +216,6 @@ void PolylineTool::pointerDoubleClickEvent(PointerEvent* event) void PolylineTool::removeLastPolylineSegment() { - if (!isActive()) return; - if (mPoints.size() > 1) { mPoints.removeLast(); @@ -249,7 +247,12 @@ bool PolylineTool::keyPressEvent(QKeyEvent* event) return true; } break; - + case Qt::Key_Backspace: + if (mPoints.size() > 0) + { + removeLastPolylineSegment(); + return true; + } case Qt::Key_Escape: if (mPoints.size() > 0) { diff --git a/core_lib/src/tool/polylinetool.h b/core_lib/src/tool/polylinetool.h index da4b87606d..6f80f0cf3a 100644 --- a/core_lib/src/tool/polylinetool.h +++ b/core_lib/src/tool/polylinetool.h @@ -47,8 +47,6 @@ class PolylineTool : public StrokeTool void setAA(const int AA) override; void setClosedPath(const bool closed) override; - void removeLastPolylineSegment(); - bool leavingThisTool() override; bool isActive() const override; @@ -58,6 +56,7 @@ class PolylineTool : public StrokeTool bool mClosedPathOverrideEnabled = false; void drawPolyline(QList points, QPointF endPoint); + void removeLastPolylineSegment(); void cancelPolyline(); void endPolyline(QList points); }; diff --git a/core_lib/src/util/pencildef.h b/core_lib/src/util/pencildef.h index 3fd5000dc0..a16f6f89c6 100644 --- a/core_lib/src/util/pencildef.h +++ b/core_lib/src/util/pencildef.h @@ -139,7 +139,6 @@ const static int MaxFramesBound = 9999; #define CMD_EXPORT_GIF "CmdExportGIF" #define CMD_EXPORT_PALETTE "CmdExportPalette" #define CMD_UNDO "CmdUndo" -#define CMD_REMOVE_LAST_POLYLINE_SEGMENT "CmdRemoveLastPolylineSegment" #define CMD_REDO "CmdRedo" #define CMD_CUT "CmdCut" #define CMD_COPY "CmdCopy"