mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-26 09:56:32 -05:00
add edit command for event pastes
This commit is contained in:
@@ -414,7 +414,11 @@ int EventDelete::id() const {
|
||||
EventDuplicate::EventDuplicate(Editor *editor, Map *map,
|
||||
QList<Event *> selectedEvents,
|
||||
QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
setText("Duplicate Event");
|
||||
if (selectedEvents.size() > 1) {
|
||||
setText("Duplicate Events");
|
||||
} else {
|
||||
setText("Duplicate Event");
|
||||
}
|
||||
|
||||
this->editor = editor;
|
||||
|
||||
@@ -462,6 +466,24 @@ int EventDuplicate::id() const {
|
||||
return CommandId::ID_EventDuplicate | getEventTypeMask(this->selectedEvents);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
EventPaste::EventPaste(Editor *editor, Map *map,
|
||||
QList<Event *> pastedEvents,
|
||||
QUndoCommand *parent) : EventDuplicate(editor, map, pastedEvents) {
|
||||
if (pastedEvents.size() > 1) {
|
||||
setText("Paste Events");
|
||||
} else {
|
||||
setText("Paste Event");
|
||||
}
|
||||
}
|
||||
|
||||
int EventPaste::id() const {
|
||||
return CommandId::ID_EventPaste | getEventTypeMask(this->selectedEvents);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
@@ -156,9 +156,11 @@ void MainWindow::initExtraShortcuts() {
|
||||
|
||||
auto *shortcut_Copy = new Shortcut(QKeySequence("Ctrl+C"), this, SLOT(copy()));
|
||||
shortcut_Copy->setObjectName("shortcut_Copy");
|
||||
shortcut_Copy->setWhatsThis("Copy");
|
||||
|
||||
auto *shortcut_Paste = new Shortcut(QKeySequence("Ctrl+V"), this, SLOT(paste()));
|
||||
shortcut_Paste->setObjectName("shortcut_Paste");
|
||||
shortcut_Copy->setWhatsThis("Paste");
|
||||
}
|
||||
|
||||
QObjectList MainWindow::shortcutableObjects() const {
|
||||
@@ -1583,18 +1585,8 @@ void MainWindow::paste() {
|
||||
newEvents.append(pasteEvent);
|
||||
}
|
||||
|
||||
editor->project->loadEventPixmaps(editor->map->getAllEvents());
|
||||
editor->map->editHistory.push(new EventPaste(this->editor, editor->map, newEvents));
|
||||
|
||||
for (Event *event : newEvents) {
|
||||
editor->addMapEvent(event);
|
||||
}
|
||||
|
||||
// select these events
|
||||
editor->selected_events->clear();
|
||||
for (Event *event : newEvents) {
|
||||
editor->selected_events->append(event->pixmapItem);
|
||||
}
|
||||
editor->shouldReselectEvents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user