From 1d589c259b80e4b078dac98adfcea8e701b2d358 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 21 Jun 2019 16:47:17 +0200 Subject: [PATCH] ProjectExplorer: Remove dedicated "DuplicateFile" ability Duplication works for any file node whose parent project node can add files. No need to duplicate (!) this logic everywhere. This makes the "Duplicate File" action available for cmake, qbs, etc. Change-Id: Id1f0378c3b3d7e2dbca4d6bbcca5df1c2d33ee0b Reviewed-by: hjk --- src/plugins/projectexplorer/projectexplorer.cpp | 6 ++++-- src/plugins/projectexplorer/projectnodes.h | 1 - src/plugins/qmakeprojectmanager/qmakenodes.cpp | 2 +- src/plugins/resourceeditor/resourcenode.cpp | 2 -- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 6452a0ac75a..867e53af13e 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3323,8 +3323,10 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() m_diffFileAction->setEnabled(DiffService::instance() && currentNodeIsTextFile && TextEditor::TextDocument::currentTextDocument()); - m_duplicateFileAction->setVisible(supports(DuplicateFile)); - m_duplicateFileAction->setEnabled(supports(DuplicateFile)); + const bool canDuplicate = supports(AddNewFile) + && currentNode->asFileNode()->fileType() != FileType::Project; + m_duplicateFileAction->setVisible(canDuplicate); + m_duplicateFileAction->setEnabled(canDuplicate); EditorManager::populateOpenWithMenu(m_openWithMenu, currentNode->filePath().toString()); diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h index 2795f1a8fbd..e6afdda0384 100644 --- a/src/plugins/projectexplorer/projectnodes.h +++ b/src/plugins/projectexplorer/projectnodes.h @@ -78,7 +78,6 @@ enum ProjectAction { // DeleteFile is a define on windows... EraseFile, Rename, - DuplicateFile, // hides actions that use the path(): Open containing folder, open terminal here and Find in Directory HidePathActions, HideFileActions, diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index 1716077db00..984be6e96c7 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -84,7 +84,7 @@ QmakeProFileNode *QmakePriFileNode::proFileNode() const bool QmakePriFileNode::supportsAction(ProjectAction action, const Node *node) const { - if (action == Rename || action == DuplicateFile) { + if (action == Rename) { const FileNode *fileNode = node->asFileNode(); return (fileNode && fileNode->fileType() != FileType::Project) || dynamic_cast(node); diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp index baf214a2bef..0395c607b43 100644 --- a/src/plugins/resourceeditor/resourcenode.cpp +++ b/src/plugins/resourceeditor/resourcenode.cpp @@ -197,7 +197,6 @@ bool SimpleResourceFolderNode::supportsAction(ProjectAction action, const Node * || action == AddExistingFile || action == AddExistingDirectory || action == RemoveFile - || action == DuplicateFile || action == Rename // Note: only works for the filename, works akwardly for relative file paths || action == InheritedFromParent; // Do not add to list of projects when adding new file } @@ -487,7 +486,6 @@ bool ResourceFolderNode::supportsAction(ProjectAction action, const Node *node) || action == AddExistingFile || action == AddExistingDirectory || action == RemoveFile - || action == DuplicateFile || action == Rename // Note: only works for the filename, works akwardly for relative file paths || action == HidePathActions; // hides open terminal etc. }