这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
6 changes: 6 additions & 0 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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 @@ -264,6 +265,7 @@ void MainWindow2::createMenus()
//--- Edit Menu ---
connect(mEditor, &Editor::updateBackup, this, &MainWindow2::undoActSetText);
connect(ui->actionUndo, &QAction::triggered, mEditor, &Editor::undo);
connect(ui->actionRemoveLastPolylineSegment, &QAction::triggered, static_cast<PolylineTool*>(mEditor->tools()->getTool(POLYLINE)), &PolylineTool::removeLastPolylineSegment);
connect(ui->actionRedo, &QAction::triggered, mEditor, &Editor::redo);
connect(ui->actionCut, &QAction::triggered, mEditor, &Editor::copyAndCut);
connect(ui->actionCopy, &QAction::triggered, mEditor, &Editor::copy);
Expand Down Expand Up @@ -1190,6 +1192,7 @@ 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 @@ -1305,6 +1308,9 @@ 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: 1 addition & 0 deletions app/src/shortcutspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ 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: 8 additions & 0 deletions app/ui/mainwindow2.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,14 @@
<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: 1 addition & 0 deletions core_lib/data/resources/kb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CmdExportMovie=
CmdExportGIF=Ctrl+G
CmdExportPalette=
CmdUndo=Ctrl+Z
CmdRemoveLastPolylineSegment=Backspace
CmdRedo=Ctrl+Shift+Z
CmdCut=Ctrl+X
CmdCopy=Ctrl+C
Expand Down
15 changes: 15 additions & 0 deletions core_lib/src/tool/polylinetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ void PolylineTool::pointerDoubleClickEvent(PointerEvent* event)
endPolyline(mPoints);
}

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

if (mPoints.size() > 1)
{
mPoints.removeLast();
drawPolyline(mPoints, getCurrentPoint());
}
else if (mPoints.size() == 1)
{
cancelPolyline();
clearToolData();
}
}

bool PolylineTool::keyPressEvent(QKeyEvent* event)
{
Expand Down
2 changes: 2 additions & 0 deletions core_lib/src/tool/polylinetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ 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 Down
1 change: 1 addition & 0 deletions core_lib/src/util/pencildef.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ 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