Skip to content

Commit

Permalink
Use keyPressEvent rather than shortcut for polyline delete segment
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
scribblemaniac committed Dec 9, 2024
1 parent 1a7a7d7 commit c431667
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 22 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -265,7 +264,6 @@ void MainWindow2::createMenus()

//--- Edit Menu ---
replaceUndoRedoActions();
connect(ui->actionRemoveLastPolylineSegment, &QAction::triggered, static_cast<PolylineTool*>(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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion app/src/shortcutspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
Expand Down
8 changes: 0 additions & 8 deletions app/ui/mainwindow2.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1273,14 +1273,6 @@
<string>30°</string>
</property>
</action>
<action name="actionRemoveLastPolylineSegment">
<property name="text">
<string>Remove Last Polyline Segment</string>
</property>
<property name="toolTip">
<string>Removes the lastest Polyline segment</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
1 change: 0 additions & 1 deletion core_lib/data/resources/kb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ CmdExportMovie=
CmdExportGIF=Ctrl+G
CmdExportPalette=
CmdUndo=Ctrl+Z
CmdRemoveLastPolylineSegment=Backspace
CmdRedo=Ctrl+Shift+Z
CmdCut=Ctrl+X
CmdCopy=Ctrl+C
Expand Down
9 changes: 6 additions & 3 deletions core_lib/src/tool/polylinetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ void PolylineTool::pointerDoubleClickEvent(PointerEvent* event)

void PolylineTool::removeLastPolylineSegment()
{
if (!isActive()) return;

if (mPoints.size() > 1)
{
mPoints.removeLast();
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 1 addition & 2 deletions core_lib/src/tool/polylinetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -58,6 +56,7 @@ class PolylineTool : public StrokeTool
bool mClosedPathOverrideEnabled = false;

void drawPolyline(QList<QPointF> points, QPointF endPoint);
void removeLastPolylineSegment();
void cancelPolyline();
void endPolyline(QList<QPointF> points);
};
Expand Down
1 change: 0 additions & 1 deletion core_lib/src/util/pencildef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c431667

Please sign in to comment.