diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index 90eac6808f..81b36880e0 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -277,6 +277,7 @@ void MainWindow2::createMenus() connect(ui->actionRedo, &QAction::triggered, mEditor, &Editor::redo); 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); connect(ui->actionPaste, &QAction::triggered, mEditor, &Editor::paste); connect(ui->actionClearFrame, &QAction::triggered, mEditor, &Editor::clearCurrentFrame); connect(mEditor->select(), &SelectionManager::selectionChanged, this, &MainWindow2::selectionChanged); @@ -1194,6 +1195,7 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionRedo->setShortcut(cmdKeySeq(CMD_REDO)); ui->actionCut->setShortcut(cmdKeySeq(CMD_CUT)); ui->actionCopy->setShortcut(cmdKeySeq(CMD_COPY)); + ui->actionPaste_Previous->setShortcut(cmdKeySeq(CMD_PASTE_FROM_PREVIOUS)); ui->actionPaste->setShortcut(cmdKeySeq(CMD_PASTE)); ui->actionClearFrame->setShortcut(cmdKeySeq(CMD_CLEAR_FRAME)); ui->actionSelect_All->setShortcut(cmdKeySeq(CMD_SELECT_ALL)); diff --git a/app/src/shortcutspage.cpp b/app/src/shortcutspage.cpp index 6ac8169727..acabdea55e 100644 --- a/app/src/shortcutspage.cpp +++ b/app/src/shortcutspage.cpp @@ -302,6 +302,7 @@ static QString getHumanReadableShortcutName(const QString& cmdName) {CMD_ADD_FRAME, ShortcutsPage::tr("Add Frame", "Shortcut")}, {CMD_CLEAR_FRAME, ShortcutsPage::tr("Clear Frame", "Shortcut")}, {CMD_COPY, ShortcutsPage::tr("Copy", "Shortcut")}, + {CMD_PASTE_FROM_PREVIOUS, ShortcutsPage::tr("Paste from Previous Keyframe", "Shortcut")}, {CMD_CUT, ShortcutsPage::tr("Cut", "Shortcut")}, {CMD_DELETE_CUR_LAYER, ShortcutsPage::tr("Delete Current Layer", "Shortcut")}, {CMD_DESELECT_ALL, ShortcutsPage::tr("Deselect All", "Shortcut")}, diff --git a/app/ui/mainwindow2.ui b/app/ui/mainwindow2.ui index 4a21090ab8..57905d5d22 100644 --- a/app/ui/mainwindow2.ui +++ b/app/ui/mainwindow2.ui @@ -49,7 +49,7 @@ 0 0 831 - 24 + 26 @@ -113,6 +113,7 @@ + @@ -1189,6 +1190,14 @@ Status Bar + + + Paste from Previous Keyframe + + + Paste from Previous Keyframe + + diff --git a/core_lib/data/resources/kb.ini b/core_lib/data/resources/kb.ini index d29ea3aadf..5e417811fa 100644 --- a/core_lib/data/resources/kb.ini +++ b/core_lib/data/resources/kb.ini @@ -16,6 +16,7 @@ CmdUndo=Ctrl+Z CmdRedo=Ctrl+Shift+Z CmdCut=Ctrl+X CmdCopy=Ctrl+C +CmdPasteFromPrevious=Ctrl+Left CmdPaste=Ctrl+V CmdSelectAll=Ctrl+A CmdDeselectAll=Ctrl+D diff --git a/core_lib/src/interface/editor.cpp b/core_lib/src/interface/editor.cpp index 3a9a826f38..b8ab068f59 100644 --- a/core_lib/src/interface/editor.cpp +++ b/core_lib/src/interface/editor.cpp @@ -50,7 +50,6 @@ GNU General Public License for more details. #include "timeline.h" #include "util.h" - Editor::Editor(QObject* parent) : QObject(parent) { mBackupIndex = -1; @@ -557,6 +556,37 @@ void Editor::copyAndCut() } } +void Editor::pasteFromPreviousFrame() +{ + Layer* currentLayer = layers()->currentLayer(); + int prevFrame = currentLayer->getPreviousKeyFramePosition(mFrame); + if (!currentLayer->keyExists(mFrame) || prevFrame == mFrame) + { + return; + } + + if (currentLayer->type() == Layer::BITMAP) + { + backup(tr("Paste from Previous Keyframe")); + BitmapImage* bitmapImage = static_cast(currentLayer->getKeyFrameAt(prevFrame)); + if (select()->somethingSelected()) + { + BitmapImage copy = bitmapImage->copy(select()->mySelectionRect().toRect()); + pasteToCanvas(©, mFrame); + } + else + { + pasteToCanvas(bitmapImage, mFrame); + } + } + else if (currentLayer->type() == Layer::VECTOR) + { + backup(tr("Paste from Previous Keyframe")); + VectorImage* vectorImage = static_cast(currentLayer->getKeyFrameAt(prevFrame)); + pasteToCanvas(vectorImage, mFrame); + } +} + void Editor::pasteToCanvas(BitmapImage* bitmapImage, int frameNumber) { Layer* currentLayer = layers()->currentLayer(); diff --git a/core_lib/src/interface/editor.h b/core_lib/src/interface/editor.h index 31504f8e75..7ab2a9f66b 100644 --- a/core_lib/src/interface/editor.h +++ b/core_lib/src/interface/editor.h @@ -198,6 +198,7 @@ class Editor : public QObject void copy(); void copyAndCut(); + void pasteFromPreviousFrame(); void paste(); bool canCopy() const; diff --git a/core_lib/src/util/pencildef.h b/core_lib/src/util/pencildef.h index 7cd7172bdd..a463c301d1 100644 --- a/core_lib/src/util/pencildef.h +++ b/core_lib/src/util/pencildef.h @@ -129,6 +129,7 @@ const static int MaxFramesBound = 9999; #define CMD_CUT "CmdCut" #define CMD_COPY "CmdCopy" #define CMD_PASTE "CmdPaste" +#define CMD_PASTE_FROM_PREVIOUS "CmdPasteFromPrevious" #define CMD_SELECT_ALL "CmdSelectAll" #define CMD_DESELECT_ALL "CmdDeselectAll" #define CMD_CLEAR_FRAME "CmdClearFrame"