void SCgMainWindow::initializeActions() { QUndoStack* undoStack = mScene->undoStack(); QAction* actionRedo = undoStack->createRedoAction(mScene); actionRedo->setShortcut(QKeySequence::Redo); // actionRedo->setShortcutContext(Qt::WidgetShortcut); QAction* actionUndo = undoStack->createUndoAction(mScene); actionUndo->setShortcut(QKeySequence::Undo); // actionUndo->setShortcutContext(Qt::WidgetShortcut); QAction* actionDelete = new QAction("Delete", mScene); actionDelete->setShortcut(QKeySequence::Delete); connect(actionDelete, SIGNAL(triggered()), mInputHandler, SLOT(deleteSelected())); actionDelete->setShortcutContext(Qt::WidgetShortcut); QAction* actionDeleteJustContour = new QAction("Delete just contour", mScene); actionDeleteJustContour->setShortcut( QKeySequence(tr("Backspace")) ); connect(actionDeleteJustContour, SIGNAL(triggered()), mInputHandler, SLOT(deleteJustContour())); actionDeleteJustContour->setShortcutContext(Qt::WidgetShortcut); mView->addAction(actionDeleteJustContour); mView->addAction(actionDelete); mView->addAction(actionRedo); mView->addAction(actionUndo); }
void SCgView::createActions() { QAction* sep = new QAction(this); sep->setSeparator(true); mActionsList.append(sep); mActionChangeContent = new QAction(mWindow->findIcon("edit-content-change.png"),tr("Set content"),mWindow); mActionChangeContent->setShortcut(QKeySequence( tr("C") )); connect(mActionChangeContent, SIGNAL(triggered()), this, SLOT(changeContent())); mActionShowContent = new QAction(tr("Show content"),mWindow); mActionShowContent->setCheckable(true); mActionShowContent->setShortcut(QKeySequence( tr("H") )); connect(mActionShowContent, SIGNAL(triggered(bool)), this, SLOT(setContentVisible(bool))); mActionShowAllContent = new QAction(tr("Show all content"), mWindow); connect(mActionShowAllContent, SIGNAL(triggered(bool)), this, SLOT(setContentVisible(bool))); mActionHideAllContent = new QAction(tr("Hide all content"), mWindow); connect(mActionHideAllContent, SIGNAL(triggered(bool)), this, SLOT(setContentVisible(bool))); mActionDeleteContent = new QAction(mWindow->findIcon("edit-content-delete.png"), tr("Delete content"), mWindow); mActionDeleteContent->setShortcut(QKeySequence( tr("D") )); connect(mActionDeleteContent, SIGNAL(triggered()), this, SLOT(deleteContent())); mActionChangeIdtf = new QAction(mWindow->findIcon("edit-change-idtf.png"), tr("Change identifier"), mWindow); mActionChangeIdtf->setShortcut(QKeySequence( tr("I") )); connect(mActionChangeIdtf, SIGNAL(triggered()), this, SLOT(changeIdentifier())); mActionDelete = new QAction(QIcon::fromTheme("edit-delete", mWindow->findIcon("edit-delete.png")), tr("Delete"), mWindow); mActionDelete->setShortcut(QKeySequence::Delete); connect(mActionDelete, SIGNAL(triggered()), this, SLOT(deleteSelected())); mActionContourDelete = new QAction(mWindow->findIcon("edit-delete.png"), tr("Delete contour"), mWindow); mActionContourDelete->setShortcut( QKeySequence(tr("Backspace")) ); connect(mActionContourDelete, SIGNAL(triggered()), this, SLOT(deleteJustContour())); mActionSwapPairOrient = new QAction(mWindow->findIcon("edit-swap-pair.png"), tr("Swap orientation"), mWindow); mActionSwapPairOrient->setShortcut( QKeySequence(tr("S"))); connect(mActionSwapPairOrient, SIGNAL(triggered()), this, SLOT(swapPairOrient())); mActionCopy = new QAction(QIcon::fromTheme("edit-copy", mWindow->findIcon("edit-copy.png")), tr("Copy"),this); mActionCopy->setShortcut(QKeySequence::Copy); connect(mActionCopy, SIGNAL(triggered()), mWindow, SLOT(copy())); mActionCut = new QAction(QIcon::fromTheme("edit-cut", mWindow->findIcon("edit-cut.png")), tr("Cut"),this); mActionCut->setShortcut(QKeySequence::Cut); connect(mActionCut, SIGNAL(triggered()), mWindow, SLOT(cut())); mActionPaste = new QAction(QIcon::fromTheme("edit-paste", mWindow->findIcon("edit-paste.png")), tr("Paste"),this); mActionPaste->setShortcut(QKeySequence::Paste); connect(mActionPaste, SIGNAL(triggered()), mWindow, SLOT(paste())); mActionSelectAll = new QAction(QIcon::fromTheme("edit-select-all", mWindow->findIcon("edit-select-all.png")), tr("Select All"),this); mActionSelectAll->setShortcut(QKeySequence::SelectAll); connect(mActionSelectAll, SIGNAL(triggered()), this, SLOT(selectAllCommand())); mActionsList.append(mActionChangeContent); mActionsList.append(mActionShowContent); mActionsList.append(mActionShowAllContent); mActionsList.append(mActionHideAllContent); mActionsList.append(mActionDeleteContent); sep = new QAction(this); sep->setSeparator(true); mActionsList.append(sep); mActionsList.append(mActionChangeIdtf); mActionsList.append(mActionSwapPairOrient); sep = new QAction(this); sep->setSeparator(true); mActionsList.append(sep); mActionsList.append(mActionCopy); mActionsList.append(mActionCut); mActionsList.append(mActionPaste); sep = new QAction(this); sep->setSeparator(true); mActionsList.append(sep); mActionsList.append(mActionSelectAll); sep = new QAction(this); sep->setSeparator(true); mActionsList.append(sep); mActionsList.append(mActionContourDelete); mActionsList.append(mActionDelete); }