Commit e4085dd0 authored by Eike Ziller's avatar Eike Ziller

Make "Diff Against Current File" available in file system view

Task-number: QTCREATORBUG-19211
Change-Id: I635b5a43ba39c0dd63c879249c5d8a593f11ca8b
Reviewed-by: default avatarAndré Hartmann <aha_1980@gmx.de>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 3136efff
......@@ -28,6 +28,7 @@
#include "projectexplorericons.h"
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/diffservice.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
......@@ -36,6 +37,10 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/fileutils.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/textdocument.h>
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
......@@ -338,12 +343,13 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
QAction *actionOpenFile = nullptr;
QAction *actionOpenProjects = nullptr;
QAction *actionOpenAsProject = nullptr;
const bool isDir = m_fileSystemModel->isDir(current);
const Utils::FileName filePath = hasCurrentItem ? Utils::FileName::fromString(
m_fileSystemModel->filePath(current))
: Utils::FileName();
if (hasCurrentItem) {
const QString fileName = m_fileSystemModel->fileName(current);
if (m_fileSystemModel->isDir(current)) {
if (isDir) {
actionOpenProjects = menu.addAction(tr("Open Project in \"%1\"").arg(fileName));
if (projectsInDirectory(current).isEmpty())
actionOpenProjects->setEnabled(false);
......@@ -362,6 +368,15 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
fakeEntry.document = &document;
Core::EditorManager::addNativeDirAndOpenWithActions(&menu, &fakeEntry);
if (hasCurrentItem && !isDir) {
if (ExtensionSystem::PluginManager::getObject<Core::DiffService>()) {
menu.addAction(
TextEditor::TextDocument::createDiffAgainstCurrentFileAction(&menu, [filePath]() {
return filePath;
}));
}
}
QAction *action = menu.exec(ev->globalPos());
if (!action)
return;
......
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