forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -3323,8 +3323,10 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
|
|||||||
m_diffFileAction->setEnabled(DiffService::instance()
|
m_diffFileAction->setEnabled(DiffService::instance()
|
||||||
&& currentNodeIsTextFile && TextEditor::TextDocument::currentTextDocument());
|
&& currentNodeIsTextFile && TextEditor::TextDocument::currentTextDocument());
|
||||||
|
|
||||||
m_duplicateFileAction->setVisible(supports(DuplicateFile));
|
const bool canDuplicate = supports(AddNewFile)
|
||||||
m_duplicateFileAction->setEnabled(supports(DuplicateFile));
|
&& currentNode->asFileNode()->fileType() != FileType::Project;
|
||||||
|
m_duplicateFileAction->setVisible(canDuplicate);
|
||||||
|
m_duplicateFileAction->setEnabled(canDuplicate);
|
||||||
|
|
||||||
EditorManager::populateOpenWithMenu(m_openWithMenu,
|
EditorManager::populateOpenWithMenu(m_openWithMenu,
|
||||||
currentNode->filePath().toString());
|
currentNode->filePath().toString());
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ enum ProjectAction {
|
|||||||
// DeleteFile is a define on windows...
|
// DeleteFile is a define on windows...
|
||||||
EraseFile,
|
EraseFile,
|
||||||
Rename,
|
Rename,
|
||||||
DuplicateFile,
|
|
||||||
// hides actions that use the path(): Open containing folder, open terminal here and Find in Directory
|
// hides actions that use the path(): Open containing folder, open terminal here and Find in Directory
|
||||||
HidePathActions,
|
HidePathActions,
|
||||||
HideFileActions,
|
HideFileActions,
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ QmakeProFileNode *QmakePriFileNode::proFileNode() const
|
|||||||
|
|
||||||
bool QmakePriFileNode::supportsAction(ProjectAction action, const Node *node) const
|
bool QmakePriFileNode::supportsAction(ProjectAction action, const Node *node) const
|
||||||
{
|
{
|
||||||
if (action == Rename || action == DuplicateFile) {
|
if (action == Rename) {
|
||||||
const FileNode *fileNode = node->asFileNode();
|
const FileNode *fileNode = node->asFileNode();
|
||||||
return (fileNode && fileNode->fileType() != FileType::Project)
|
return (fileNode && fileNode->fileType() != FileType::Project)
|
||||||
|| dynamic_cast<const ResourceEditor::ResourceTopLevelNode *>(node);
|
|| dynamic_cast<const ResourceEditor::ResourceTopLevelNode *>(node);
|
||||||
|
|||||||
@@ -197,7 +197,6 @@ bool SimpleResourceFolderNode::supportsAction(ProjectAction action, const Node *
|
|||||||
|| action == AddExistingFile
|
|| action == AddExistingFile
|
||||||
|| action == AddExistingDirectory
|
|| action == AddExistingDirectory
|
||||||
|| action == RemoveFile
|
|| action == RemoveFile
|
||||||
|| action == DuplicateFile
|
|
||||||
|| action == Rename // Note: only works for the filename, works akwardly for relative file paths
|
|| 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
|
|| 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 == AddExistingFile
|
||||||
|| action == AddExistingDirectory
|
|| action == AddExistingDirectory
|
||||||
|| action == RemoveFile
|
|| action == RemoveFile
|
||||||
|| action == DuplicateFile
|
|
||||||
|| action == Rename // Note: only works for the filename, works akwardly for relative file paths
|
|| action == Rename // Note: only works for the filename, works akwardly for relative file paths
|
||||||
|| action == HidePathActions; // hides open terminal etc.
|
|| action == HidePathActions; // hides open terminal etc.
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user