void NodeGraph::duplicateSelectedNodes() { QPointF scenePos = mapToScene( mapFromGlobal( QCursor::pos() ) ); duplicateSelectedNodes(scenePos); }
void NodeGraph::showMenu(const QPoint & pos) { _imp->_menu->clear(); QAction* findAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphFindNode, kShortcutActionGraphFindNodeLabel, _imp->_menu); _imp->_menu->addAction(findAction); _imp->_menu->addSeparator(); //QFont font(appFont,appFontSize); Menu* editMenu = new Menu(tr("Edit"), _imp->_menu); //editMenu->setFont(font); _imp->_menu->addAction( editMenu->menuAction() ); QAction* copyAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphCopy, kShortcutActionGraphCopyLabel, editMenu); QObject::connect( copyAction, SIGNAL(triggered()), this, SLOT(copySelectedNodes()) ); editMenu->addAction(copyAction); QAction* cutAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphCut, kShortcutActionGraphCutLabel, editMenu); QObject::connect( cutAction, SIGNAL(triggered()), this, SLOT(cutSelectedNodes()) ); editMenu->addAction(cutAction); QAction* pasteAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphPaste, kShortcutActionGraphPasteLabel, editMenu); bool cbEnabled = false; { QClipboard* clipboard = QApplication::clipboard(); const QMimeData* data = clipboard->mimeData(); if (data && data->hasFormat(QLatin1String("text/plain"))) { cbEnabled = true; } } pasteAction->setEnabled(cbEnabled); editMenu->addAction(pasteAction); QAction* deleteAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphRemoveNodes, kShortcutActionGraphRemoveNodesLabel, editMenu); QObject::connect( deleteAction, SIGNAL(triggered()), this, SLOT(deleteSelection()) ); editMenu->addAction(deleteAction); QAction* renameAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphRenameNode, kShortcutActionGraphRenameNodeLabel, editMenu); QObject::connect( renameAction, SIGNAL(triggered()), this, SLOT(renameNode()) ); editMenu->addAction(renameAction); QAction* duplicateAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphDuplicate, kShortcutActionGraphDuplicateLabel, editMenu); editMenu->addAction(duplicateAction); QAction* cloneAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphClone, kShortcutActionGraphCloneLabel, editMenu); editMenu->addAction(cloneAction); QAction* decloneAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphDeclone, kShortcutActionGraphDecloneLabel, editMenu); QObject::connect( decloneAction, SIGNAL(triggered()), this, SLOT(decloneSelectedNodes()) ); editMenu->addAction(decloneAction); QAction* switchInputs = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphExtractNode, kShortcutActionGraphExtractNodeLabel, editMenu); QObject::connect( switchInputs, SIGNAL(triggered()), this, SLOT(extractSelectedNode()) ); editMenu->addAction(switchInputs); QAction* extractNode = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphSwitchInputs, kShortcutActionGraphSwitchInputsLabel, editMenu); QObject::connect( extractNode, SIGNAL(triggered()), this, SLOT(switchInputs1and2ForSelectedNodes()) ); editMenu->addAction(extractNode); QAction* disableNodes = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphDisableNodes, kShortcutActionGraphDisableNodesLabel, editMenu); QObject::connect( disableNodes, SIGNAL(triggered()), this, SLOT(toggleSelectedNodesEnabled()) ); editMenu->addAction(disableNodes); QAction* groupFromSel = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphMakeGroup, kShortcutActionGraphMakeGroupLabel, editMenu); QObject::connect( groupFromSel, SIGNAL(triggered()), this, SLOT(createGroupFromSelection()) ); editMenu->addAction(groupFromSel); QAction* expandGroup = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphExpandGroup, kShortcutActionGraphExpandGroupLabel, editMenu); QObject::connect( expandGroup, SIGNAL(triggered()), this, SLOT(expandSelectedGroups()) ); editMenu->addAction(expandGroup); QAction* displayCacheInfoAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphShowCacheSize, kShortcutActionGraphShowCacheSizeLabel, _imp->_menu); displayCacheInfoAction->setCheckable(true); displayCacheInfoAction->setChecked( _imp->_cacheSizeText->isVisible() ); QObject::connect( displayCacheInfoAction, SIGNAL(triggered()), this, SLOT(toggleCacheInfo()) ); _imp->_menu->addAction(displayCacheInfoAction); NodesGuiList selectedNodes = getSelectedNodes(); if ( !selectedNodes.empty() ) { QAction* turnOffPreviewAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphTogglePreview, kShortcutActionGraphTogglePreviewLabel, _imp->_menu); turnOffPreviewAction->setCheckable(true); turnOffPreviewAction->setChecked(false); QObject::connect( turnOffPreviewAction, SIGNAL(triggered()), this, SLOT(togglePreviewsForSelectedNodes()) ); _imp->_menu->addAction(turnOffPreviewAction); if (selectedNodes.size() == 1) { QAction* openNodePanelAction = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphOpenNodePanel, kShortcutActionGraphOpenNodePanelLabel, _imp->_menu); openNodePanelAction->setCheckable(true); openNodePanelAction->setChecked(false); QObject::connect( openNodePanelAction, SIGNAL(triggered()), this, SLOT(showSelectedNodeSettingsPanel()) ); _imp->_menu->addAction(openNodePanelAction); } } QAction* autoHideInputs = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphAutoHideInputs, kShortcutActionGraphAutoHideInputsLabel, _imp->_menu); autoHideInputs->setCheckable(true); autoHideInputs->setChecked( appPTR->getCurrentSettings()->areOptionalInputsAutoHidden() ); QObject::connect( autoHideInputs, SIGNAL(triggered()), this, SLOT(toggleAutoHideInputs()) ); _imp->_menu->addAction(autoHideInputs); QAction* hideInputs = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphHideInputs, kShortcutActionGraphHideInputsLabel, _imp->_menu); hideInputs->setCheckable(true); bool hideInputsVal = false; if ( !selectedNodes.empty() ) { hideInputsVal = selectedNodes.front()->getNode()->getEffectInstance()->getHideInputsKnobValue(); } hideInputs->setChecked(hideInputsVal); QObject::connect( hideInputs, SIGNAL(triggered()), this, SLOT(toggleHideInputs()) ); _imp->_menu->addAction(hideInputs); QAction* knobLinks = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphShowExpressions, kShortcutActionGraphShowExpressionsLabel, _imp->_menu); knobLinks->setCheckable(true); knobLinks->setChecked( areKnobLinksVisible() ); QObject::connect( knobLinks, SIGNAL(triggered()), this, SLOT(toggleKnobLinksVisible()) ); _imp->_menu->addAction(knobLinks); QAction* autoPreview = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphToggleAutoPreview, kShortcutActionGraphToggleAutoPreviewLabel, _imp->_menu); autoPreview->setCheckable(true); autoPreview->setChecked( getGui()->getApp()->getProject()->isAutoPreviewEnabled() ); QObject::connect( autoPreview, SIGNAL(triggered()), this, SLOT(toggleAutoPreview()) ); QObject::connect( getGui()->getApp()->getProject().get(), SIGNAL(autoPreviewChanged(bool)), autoPreview, SLOT(setChecked(bool)) ); _imp->_menu->addAction(autoPreview); QAction* autoTurbo = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphToggleAutoTurbo, kShortcutActionGraphToggleAutoTurboLabel, _imp->_menu); autoTurbo->setCheckable(true); autoTurbo->setChecked( appPTR->getCurrentSettings()->isAutoTurboEnabled() ); QObject::connect( autoTurbo, SIGNAL(triggered()), this, SLOT(toggleAutoTurbo()) ); _imp->_menu->addAction(autoTurbo); QAction* forceRefreshPreviews = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphForcePreview, kShortcutActionGraphForcePreviewLabel, _imp->_menu); QObject::connect( forceRefreshPreviews, SIGNAL(triggered()), this, SLOT(forceRefreshAllPreviews()) ); _imp->_menu->addAction(forceRefreshPreviews); QAction* frameAllNodes = new ActionWithShortcut(kShortcutGroupNodegraph, kShortcutActionGraphFrameNodes, kShortcutActionGraphFrameNodesLabel, _imp->_menu); QObject::connect( frameAllNodes, SIGNAL(triggered()), this, SLOT(centerOnAllNodes()) ); _imp->_menu->addAction(frameAllNodes); _imp->_menu->addSeparator(); std::list<ToolButton*> orederedToolButtons = getGui()->getToolButtonsOrdered(); for (std::list<ToolButton*>::iterator it = orederedToolButtons.begin(); it != orederedToolButtons.end(); ++it) { (*it)->getMenu()->setIcon( (*it)->getMenuIcon() ); _imp->_menu->addAction( (*it)->getMenu()->menuAction() ); } QAction* ret = _imp->_menu->exec(pos); if (ret == findAction) { popFindDialog(); } else if (ret == duplicateAction) { QRectF rect = visibleSceneRect(); duplicateSelectedNodes( rect.center() ); } else if (ret == cloneAction) { QRectF rect = visibleSceneRect(); cloneSelectedNodes( rect.center() ); } else if (ret == pasteAction) { QRectF rect = visibleSceneRect(); pasteClipboard( rect.center() ); } } // NodeGraph::showMenu