这是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
2 changes: 2 additions & 0 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions app/src/shortcutspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
Expand Down
11 changes: 10 additions & 1 deletion app/ui/mainwindow2.ui
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<x>0</x>
<y>0</y>
<width>831</width>
<height>24</height>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -113,6 +113,7 @@
<addaction name="actionCut"/>
<addaction name="actionCopy"/>
<addaction name="actionPaste"/>
<addaction name="actionPaste_Previous"/>
<addaction name="actionClearFrame"/>
<addaction name="separator"/>
<addaction name="menuSelection"/>
Expand Down Expand Up @@ -1189,6 +1190,14 @@
<string>Status Bar</string>
</property>
</action>
<action name="actionPaste_Previous">
<property name="text">
<string>Paste from Previous Keyframe</string>
</property>
<property name="toolTip">
<string>Paste from Previous Keyframe</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 @@ -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
Expand Down
32 changes: 31 additions & 1 deletion core_lib/src/interface/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<BitmapImage*>(currentLayer->getKeyFrameAt(prevFrame));
if (select()->somethingSelected())
{
BitmapImage copy = bitmapImage->copy(select()->mySelectionRect().toRect());
pasteToCanvas(&copy, mFrame);
}
else
{
pasteToCanvas(bitmapImage, mFrame);
}
}
else if (currentLayer->type() == Layer::VECTOR)
{
backup(tr("Paste from Previous Keyframe"));
VectorImage* vectorImage = static_cast<VectorImage*>(currentLayer->getKeyFrameAt(prevFrame));
pasteToCanvas(vectorImage, mFrame);
}
}

void Editor::pasteToCanvas(BitmapImage* bitmapImage, int frameNumber)
{
Layer* currentLayer = layers()->currentLayer();
Expand Down
1 change: 1 addition & 0 deletions core_lib/src/interface/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class Editor : public QObject

void copy();
void copyAndCut();
void pasteFromPreviousFrame();
void paste();

bool canCopy() const;
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 @@ -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"
Expand Down