From 39648eed4182c29b11243d4a60f0043d38d320c9 Mon Sep 17 00:00:00 2001 From: garak Date: Mon, 3 May 2021 15:47:29 -0400 Subject: [PATCH] add copy paste to edit menu --- include/mainwindow.h | 7 +++++-- src/mainwindow.cpp | 15 +++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/mainwindow.h b/include/mainwindow.h index b61f8c29..bd88cb3a 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -259,8 +259,11 @@ private: QIcon* mapEditedIcon; QIcon* mapOpenedIcon; - QAction *undoAction; - QAction *redoAction; + QAction *undoAction = nullptr; + QAction *redoAction = nullptr; + + QAction *copyAction = nullptr; + QAction *pasteAction = nullptr; QWidget *eventTabObjectWidget; QWidget *eventTabWarpWidget; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5b7d781f..94584ac1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -154,13 +154,16 @@ void MainWindow::initExtraShortcuts() { shortcut_Open_Scripts->setObjectName("shortcut_Open_Scripts"); shortcut_Open_Scripts->setWhatsThis("Open Map Scripts"); - auto *shortcut_Copy = new Shortcut(QKeySequence("Ctrl+C"), this, SLOT(copy())); - shortcut_Copy->setObjectName("shortcut_Copy"); - shortcut_Copy->setWhatsThis("Copy"); + copyAction = new QAction("Copy", this); + copyAction->setShortcut(QKeySequence("Ctrl+C")); + connect(copyAction, &QAction::triggered, this, &MainWindow::copy); + ui->menuEdit->addSeparator(); + ui->menuEdit->addAction(copyAction); - auto *shortcut_Paste = new Shortcut(QKeySequence("Ctrl+V"), this, SLOT(paste())); - shortcut_Paste->setObjectName("shortcut_Paste"); - shortcut_Copy->setWhatsThis("Paste"); + pasteAction = new QAction("Paste", this); + pasteAction->setShortcut(QKeySequence("Ctrl+V")); + connect(pasteAction, &QAction::triggered, this, &MainWindow::paste); + ui->menuEdit->addAction(pasteAction); } QObjectList MainWindow::shortcutableObjects() const {