void ResourceEditorPlugin::updateContextActions(Node *node, Project *) { bool isResourceNode = dynamic_cast<ResourceTopLevelNode *>(node); m_addPrefix->setEnabled(isResourceNode); m_addPrefix->setVisible(isResourceNode); bool enableRename = false; bool enableRemove = false; if (isResourceNode) { FolderNode *parent = node ? node->parentFolderNode() : 0; enableRename = parent && parent->supportedActions(node).contains(Rename); enableRemove = parent && parent->supportedActions(node).contains(RemoveFile); } m_renameResourceFile->setEnabled(isResourceNode && enableRename); m_renameResourceFile->setVisible(isResourceNode && enableRename); m_removeResourceFile->setEnabled(isResourceNode && enableRemove); m_removeResourceFile->setVisible(isResourceNode && enableRemove); m_openInEditor->setEnabled(isResourceNode); m_openInEditor->setVisible(isResourceNode); bool isResourceFolder = dynamic_cast<ResourceFolderNode *>(node); m_removePrefix->setEnabled(isResourceFolder); m_removePrefix->setVisible(isResourceFolder); m_renamePrefix->setEnabled(isResourceFolder); m_renamePrefix->setVisible(isResourceFolder); m_removeNonExisting->setEnabled(isResourceNode); m_removeNonExisting->setVisible(isResourceNode); if (isResourceNode) Core::EditorManager::populateOpenWithMenu(m_openWithMenu, node->path().toString()); else m_openWithMenu->clear(); m_openWithMenu->menuAction()->setVisible(!m_openWithMenu->actions().isEmpty()); bool isResourceFile = dynamic_cast<ResourceFileNode *>(node); m_copyPath->setEnabled(isResourceFile); m_copyPath->setVisible(isResourceFile); m_copyUrl->setEnabled(isResourceFile); m_copyUrl->setVisible(isResourceFile); if (isResourceFile) { ResourceFileNode *fileNode = static_cast<ResourceFileNode *>(node); QString qrcPath = fileNode->qrcPath(); m_copyPath->setParameter(QLatin1String(resourcePrefix) + qrcPath); m_copyUrl->setParameter(QLatin1String(urlPrefix) + qrcPath); } }
void ResourceEditorPlugin::updateContextActions(ProjectExplorer::Node *node, ProjectExplorer::Project *) { bool isResourceNode = qobject_cast<ResourceTopLevelNode *>(node); m_addPrefix->setEnabled(isResourceNode); m_addPrefix->setVisible(isResourceNode); bool enableRename = false; bool enableRemove = false; if (isResourceNode) { ProjectExplorer::FolderNode *parent = node ? node->parentFolderNode() : 0; enableRename = parent && parent->supportedActions(node).contains(ProjectExplorer::Rename); enableRemove = parent && parent->supportedActions(node).contains(ProjectExplorer::RemoveFile); } m_renameResourceFile->setEnabled(isResourceNode && enableRename); m_renameResourceFile->setVisible(isResourceNode && enableRename); m_removeResourceFile->setEnabled(isResourceNode && enableRemove); m_removeResourceFile->setVisible(isResourceNode && enableRemove); m_openInEditor->setEnabled(isResourceNode); m_openInEditor->setVisible(isResourceNode); m_openInTextEditor->setEnabled(isResourceNode); m_openInTextEditor->setVisible(isResourceNode); bool isResourceFolder = qobject_cast<ResourceFolderNode *>(node); m_removePrefix->setEnabled(isResourceFolder); m_removePrefix->setVisible(isResourceFolder); m_renamePrefix->setEnabled(isResourceFolder); m_renamePrefix->setVisible(isResourceFolder); bool isResourceFile = qobject_cast<ResourceFileNode *>(node); m_copyPath->setEnabled(isResourceFile); m_copyPath->setVisible(isResourceFile); m_copyUrl->setEnabled(isResourceFile); m_copyUrl->setVisible(isResourceFile); if (isResourceFile) { ResourceFileNode *fileNode = static_cast<ResourceFileNode *>(node); QString qrcPath = fileNode->qrcPath(); m_copyPath->setParameter(QLatin1String(resourcePrefix) + qrcPath); m_copyUrl->setParameter(QLatin1String(urlPrefix) + qrcPath); } }
void ResourceEditorPlugin::copyUrlContextMenu() { ResourceFileNode *node = static_cast<ResourceFileNode *>(ProjectTree::currentNode()); QApplication::clipboard()->setText(QLatin1String(urlPrefix) + node->qrcPath()); }