Commit 9c6f5591 authored by Eike Ziller's avatar Eike Ziller

Editors: Add "Open with" to open editors and combo box context menus

Change-Id: I67e75220ac86c7fd4d5005424f8b1922e2cbacfd
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
Reviewed-by: default avatarJarek Kobus <jaroslaw.kobus@digia.com>
parent db918592
...@@ -820,7 +820,7 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod ...@@ -820,7 +820,7 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod
contextMenu->addAction(d->m_closeAllEditorsExceptVisibleContextAction); contextMenu->addAction(d->m_closeAllEditorsExceptVisibleContextAction);
} }
void EditorManager::addNativeDirActions(QMenu *contextMenu, DocumentModel::Entry *entry) void EditorManager::addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentModel::Entry *entry)
{ {
QTC_ASSERT(contextMenu, return); QTC_ASSERT(contextMenu, return);
bool enabled = entry && !entry->fileName().isEmpty(); bool enabled = entry && !entry->fileName().isEmpty();
...@@ -830,6 +830,12 @@ void EditorManager::addNativeDirActions(QMenu *contextMenu, DocumentModel::Entry ...@@ -830,6 +830,12 @@ void EditorManager::addNativeDirActions(QMenu *contextMenu, DocumentModel::Entry
contextMenu->addAction(d->m_openGraphicalShellAction); contextMenu->addAction(d->m_openGraphicalShellAction);
contextMenu->addAction(d->m_openTerminalAction); contextMenu->addAction(d->m_openTerminalAction);
contextMenu->addAction(d->m_findInDirectoryAction); contextMenu->addAction(d->m_findInDirectoryAction);
QMenu *openWith = contextMenu->addMenu(tr("Open with"));
connect(openWith, SIGNAL(triggered(QAction*)),
DocumentManager::instance(), SLOT(executeOpenWithMenuAction(QAction*)));
openWith->setEnabled(enabled);
if (enabled)
DocumentManager::populateOpenWithMenu(openWith, entry->fileName());
} }
static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view) static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view)
......
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
static QString windowTitleVcsTopic(); static QString windowTitleVcsTopic();
static void addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentModel::Entry *entry); static void addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentModel::Entry *entry);
static void addNativeDirActions(QMenu *contextMenu, DocumentModel::Entry *entry); static void addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentModel::Entry *entry);
signals: signals:
void currentEditorChanged(Core::IEditor *editor); void currentEditorChanged(Core::IEditor *editor);
......
...@@ -208,7 +208,7 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos) ...@@ -208,7 +208,7 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos)
m_model->mapToSource(editorIndex).row()); m_model->mapToSource(editorIndex).row());
EditorManager::addSaveAndCloseEditorActions(&contextMenu, entry); EditorManager::addSaveAndCloseEditorActions(&contextMenu, entry);
contextMenu.addSeparator(); contextMenu.addSeparator();
EditorManager::addNativeDirActions(&contextMenu, entry); EditorManager::addNativeDirAndOpenWithActions(&contextMenu, entry);
contextMenu.exec(mapToGlobal(pos)); contextMenu.exec(mapToGlobal(pos));
} }
......
...@@ -325,7 +325,7 @@ void EditorToolBar::listContextMenu(QPoint pos) ...@@ -325,7 +325,7 @@ void EditorToolBar::listContextMenu(QPoint pos)
menu.addSeparator(); menu.addSeparator();
EditorManager::addSaveAndCloseEditorActions(&menu, entry); EditorManager::addSaveAndCloseEditorActions(&menu, entry);
menu.addSeparator(); menu.addSeparator();
EditorManager::addNativeDirActions(&menu, entry); EditorManager::addNativeDirAndOpenWithActions(&menu, entry);
QAction *result = menu.exec(d->m_editorList->mapToGlobal(pos)); QAction *result = menu.exec(d->m_editorList->mapToGlobal(pos));
if (result == copyPath) if (result == copyPath)
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName)); QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
......
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