Commit 113bdf11 authored by David Schulz's avatar David Schulz
Browse files

ResourceEditor: Use open with menu from document manager.



Task-number: QTCREATORBUG-13723
Change-Id: I4acc8bd0c2b9fa9c6c4c82008a20c44e5d6055ec
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent c5c7b79b
......@@ -50,7 +50,6 @@ const char C_REMOVE_FILE[] = "ResourceEditor.RemoveFile";
const char C_RENAME_FILE[] = "ResourceEditor.RenameFile";
const char C_OPEN_EDITOR[] = "ResourceEditor.OpenEditor";
const char C_OPEN_TEXT_EDITOR[] = "ResourceEditor.OpenTextEditor";
const char C_COPY_PATH[] = "ResourceEditor.CopyPath";
const char C_COPY_URL[] = "ResourceEditor.CopyUrl";
......
......@@ -38,6 +38,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/id.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
......@@ -180,10 +181,12 @@ bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *err
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_openInEditor, SIGNAL(triggered()), this, SLOT(openEditorContextMenu()));
m_openInTextEditor = new QAction(tr("Open in Text Editor"), this);
command = Core::ActionManager::registerAction(m_openInTextEditor, Constants::C_OPEN_TEXT_EDITOR, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_openInTextEditor, SIGNAL(triggered()), this, SLOT(openTextEditorContextMenu()));
m_openWithMenu = new QMenu(tr("Open With"), folderContextMenu->menu());
folderContextMenu->menu()->insertMenu(
folderContextMenu->insertLocation(ProjectExplorer::Constants::G_FOLDER_FILES),
m_openWithMenu);
connect(m_openWithMenu, &QMenu::triggered,
Core::DocumentManager::instance(), &Core::DocumentManager::executeOpenWithMenuAction);
m_copyPath = new Utils::ParameterAction(QString(), tr("Copy path \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
command = Core::ActionManager::registerAction(m_copyPath, Constants::C_COPY_PATH, projectTreeContext);
......@@ -270,16 +273,7 @@ void ResourceEditorPlugin::removeFileContextMenu()
void ResourceEditorPlugin::openEditorContextMenu()
{
ResourceTopLevelNode *topLevel = static_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QString path = topLevel->path();
Core::EditorManager::openEditor(path);
}
void ResourceEditorPlugin::openTextEditorContextMenu()
{
ResourceTopLevelNode *topLevel = static_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QString path = topLevel->path();
Core::EditorManager::openEditor(path, Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
Core::EditorManager::openEditor(ProjectTree::currentNode()->path());
}
void ResourceEditorPlugin::copyPathContextMenu()
......@@ -331,9 +325,6 @@ void ResourceEditorPlugin::updateContextActions(ProjectExplorer::Node *node, Pro
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);
......@@ -341,6 +332,12 @@ void ResourceEditorPlugin::updateContextActions(ProjectExplorer::Node *node, Pro
m_renamePrefix->setEnabled(isResourceFolder);
m_renamePrefix->setVisible(isResourceFolder);
if (isResourceNode)
Core::DocumentManager::populateOpenWithMenu(m_openWithMenu, node->path());
else
m_openWithMenu->clear();
m_openWithMenu->menuAction()->setVisible(!m_openWithMenu->actions().isEmpty());
bool isResourceFile = qobject_cast<ResourceFileNode *>(node);
m_copyPath->setEnabled(isResourceFile);
m_copyPath->setVisible(isResourceFile);
......
......@@ -35,6 +35,7 @@
QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
QT_END_NAMESPACE
namespace ProjectExplorer {
......@@ -75,7 +76,6 @@ private slots:
void removeFileContextMenu();
void openEditorContextMenu();
void openTextEditorContextMenu();
void copyPathContextMenu();
void copyUrlContextMenu();
......@@ -102,7 +102,7 @@ private:
QAction *m_removeResourceFile;
QAction *m_openInEditor;
QAction *m_openInTextEditor;
QMenu *m_openWithMenu;
// file context menu
Utils::ParameterAction *m_copyPath;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment