forked from qt-creator/qt-creator
Move File System view to Core plugin
So it can be accessed from a wider range of places. Change-Id: I282883addecf7bb070a65d9f4f7b8e6e2e4b5e47 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -83,6 +83,8 @@ add_qtc_plugin(Core
|
||||
find/searchresultwindow.cpp find/searchresultwindow.h
|
||||
find/textfindconstants.h
|
||||
findplaceholder.cpp findplaceholder.h
|
||||
foldernavigationwidget.cpp
|
||||
foldernavigationwidget.h
|
||||
generalsettings.cpp generalsettings.h generalsettings.ui
|
||||
generatedfile.cpp generatedfile.h
|
||||
helpitem.cpp helpitem.h
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "coreplugin.h"
|
||||
#include "designmode.h"
|
||||
#include "editmode.h"
|
||||
#include "foldernavigationwidget.h"
|
||||
#include "helpmanager.h"
|
||||
#include "icore.h"
|
||||
#include "idocument.h"
|
||||
@@ -104,6 +105,7 @@ CorePlugin::~CorePlugin()
|
||||
Find::destroy();
|
||||
|
||||
delete m_locator;
|
||||
delete m_folderNavigationWidgetFactory;
|
||||
delete m_editMode;
|
||||
|
||||
DesignMode::destroyModeIfRequired();
|
||||
@@ -176,6 +178,8 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
m_editMode = new EditMode;
|
||||
ModeManager::activateMode(m_editMode->id());
|
||||
|
||||
m_folderNavigationWidgetFactory = new FolderNavigationWidgetFactory;
|
||||
|
||||
IWizardFactory::initialize();
|
||||
|
||||
// Make sure we respect the process's umask when creating new files
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foldernavigationwidget.h"
|
||||
#include <qglobal.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
@@ -39,6 +40,9 @@ class PathChooser;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
class FolderNavigationWidgetFactory;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class EditMode;
|
||||
@@ -92,6 +96,7 @@ private:
|
||||
MainWindow *m_mainWindow = nullptr;
|
||||
EditMode *m_editMode = nullptr;
|
||||
Locator *m_locator = nullptr;
|
||||
FolderNavigationWidgetFactory *m_folderNavigationWidgetFactory;
|
||||
Utils::Environment m_startupSystemEnvironment;
|
||||
Utils::EnvironmentItems m_environmentChanges;
|
||||
};
|
||||
|
@@ -111,7 +111,8 @@ SOURCES += corejsextensions.cpp \
|
||||
menubarfilter.cpp \
|
||||
welcomepagehelper.cpp \
|
||||
dialogs/codecselector.cpp \
|
||||
plugininstallwizard.cpp
|
||||
plugininstallwizard.cpp \
|
||||
foldernavigationwidget.cpp
|
||||
|
||||
HEADERS += corejsextensions.h \
|
||||
mainwindow.h \
|
||||
@@ -225,7 +226,8 @@ HEADERS += corejsextensions.h \
|
||||
editormanager/ieditorfactory_p.h \
|
||||
welcomepagehelper.h \
|
||||
dialogs/codecselector.h \
|
||||
plugininstallwizard.h
|
||||
plugininstallwizard.h \
|
||||
foldernavigationwidget.h
|
||||
|
||||
FORMS += dialogs/newdialog.ui \
|
||||
dialogs/saveitemsdialog.ui \
|
||||
|
@@ -71,6 +71,8 @@ Project {
|
||||
"fileutils.h",
|
||||
"findplaceholder.cpp",
|
||||
"findplaceholder.h",
|
||||
"foldernavigationwidget.cpp",
|
||||
"foldernavigationwidget.h",
|
||||
"generalsettings.cpp",
|
||||
"generalsettings.h",
|
||||
"generalsettings.ui",
|
||||
|
@@ -90,8 +90,7 @@ const char ADDNEWFILE[] = "QtCreator.FileSystem.AddNewFile";
|
||||
const char RENAMEFILE[] = "QtCreator.FileSystem.RenameFile";
|
||||
const char REMOVEFILE[] = "QtCreator.FileSystem.RemoveFile";
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
namespace Core {
|
||||
|
||||
static FolderNavigationWidgetFactory *m_instance = nullptr;
|
||||
|
||||
@@ -100,6 +99,13 @@ QVector<FolderNavigationWidgetFactory::RootDirectory>
|
||||
|
||||
Utils::FilePath FolderNavigationWidgetFactory::m_fallbackSyncFilePath;
|
||||
|
||||
FolderNavigationWidgetFactory *FolderNavigationWidgetFactory::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
static QWidget *createHLine()
|
||||
{
|
||||
auto widget = new QFrame;
|
||||
@@ -240,6 +246,10 @@ static bool isChildOf(const QModelIndex &index, const QModelIndex &parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
/*!
|
||||
\class FolderNavigationWidget
|
||||
|
||||
@@ -686,12 +696,6 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
|
||||
if (m_fileSystemModel->flags(current) & Qt::ItemIsEditable)
|
||||
menu.addAction(Core::ActionManager::command(RENAMEFILE)->action());
|
||||
newFolder = menu.addAction(tr("New Folder"));
|
||||
if (!isDir && Core::DiffService::instance()) {
|
||||
menu.addAction(
|
||||
TextEditor::TextDocument::createDiffAgainstCurrentFileAction(&menu, [filePath]() {
|
||||
return filePath;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
@@ -956,5 +960,4 @@ void DelayedFileCrumbLabel::setScrollBarOnce() const
|
||||
that->m_bar.clear();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ProjectExplorer
|
@@ -25,7 +25,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/inavigationwidgetfactory.h>
|
||||
#include "core_global.h"
|
||||
#include "inavigationwidgetfactory.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QIcon>
|
||||
@@ -51,12 +53,13 @@ class QModelIndex;
|
||||
class QSortFilterProxyModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class DelayedFileCrumbLabel;
|
||||
} // namespace Internal
|
||||
|
||||
class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
|
||||
class CORE_EXPORT FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -69,6 +72,8 @@ public:
|
||||
QIcon icon;
|
||||
};
|
||||
|
||||
static FolderNavigationWidgetFactory *instance();
|
||||
|
||||
FolderNavigationWidgetFactory();
|
||||
|
||||
Core::NavigationView createWidget() override;
|
||||
@@ -99,7 +104,7 @@ private:
|
||||
static Utils::FilePath m_fallbackSyncFilePath;
|
||||
};
|
||||
|
||||
class FolderNavigationWidget : public QWidget
|
||||
class CORE_EXPORT FolderNavigationWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool autoSynchronization READ autoSynchronization WRITE setAutoSynchronization)
|
||||
@@ -136,8 +141,7 @@ private:
|
||||
void setRootAutoSynchronization(bool sync);
|
||||
void setHiddenFilesFilter(bool filter);
|
||||
void selectBestRootForFile(const Utils::FilePath &filePath);
|
||||
void handleCurrentEditorChanged(Core::IEditor *editor);
|
||||
void selectFile(const Utils::FilePath &filePath);
|
||||
void handleCurrentEditorChanged(Core::IEditor *editor); void selectFile(const Utils::FilePath &filePath);
|
||||
void setRootDirectory(const Utils::FilePath &directory);
|
||||
int bestRootForFile(const Utils::FilePath &filePath);
|
||||
void openItem(const QModelIndex &index);
|
||||
@@ -155,11 +159,10 @@ private:
|
||||
QToolButton *m_toggleRootSync = nullptr;
|
||||
QComboBox *m_rootSelector = nullptr;
|
||||
QWidget *m_crumbContainer = nullptr;
|
||||
DelayedFileCrumbLabel *m_crumbLabel = nullptr;
|
||||
Internal::DelayedFileCrumbLabel *m_crumbLabel = nullptr;
|
||||
|
||||
// FolderNavigationWidgetFactory needs private members to build a menu
|
||||
friend class FolderNavigationWidgetFactory;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ProjectExplorer
|
||||
} // namespace Core
|
@@ -82,7 +82,6 @@ add_qtc_plugin(ProjectExplorer
|
||||
filesinallprojectsfind.h
|
||||
filesinallprojectsfind.cpp
|
||||
filterkitaspectsdialog.cpp filterkitaspectsdialog.h
|
||||
foldernavigationwidget.cpp foldernavigationwidget.h
|
||||
gccparser.cpp gccparser.h
|
||||
gcctoolchain.cpp gcctoolchain.h
|
||||
gcctoolchainfactories.h
|
||||
|
@@ -63,7 +63,6 @@
|
||||
#include "devicesupport/sshsettingspage.h"
|
||||
#include "editorsettingspropertiespage.h"
|
||||
#include "filesinallprojectsfind.h"
|
||||
#include "foldernavigationwidget.h"
|
||||
#include "jsonwizard/jsonwizardfactory.h"
|
||||
#include "jsonwizard/jsonwizardgeneratorfactory.h"
|
||||
#include "jsonwizard/jsonwizardpagefactory_p.h"
|
||||
@@ -117,6 +116,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/fileutils.h>
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <coreplugin/foldernavigationwidget.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/idocumentfactory.h>
|
||||
@@ -665,7 +665,6 @@ public:
|
||||
CustomParsersSettingsPage m_customParsersSettingsPage;
|
||||
|
||||
ProjectTreeWidgetFactory m_projectTreeFactory;
|
||||
FolderNavigationWidgetFactory m_folderNavigationWidgetFactory;
|
||||
DefaultDeployConfigurationFactory m_defaultDeployConfigFactory;
|
||||
|
||||
IDocumentFactory m_documentFactory;
|
||||
@@ -2934,7 +2933,8 @@ ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() {}
|
||||
|
||||
void ProjectExplorerPluginPrivate::extendFolderNavigationWidgetFactory()
|
||||
{
|
||||
connect(&m_folderNavigationWidgetFactory,
|
||||
auto folderNavigationWidgetFactory = FolderNavigationWidgetFactory::instance();
|
||||
connect(folderNavigationWidgetFactory,
|
||||
&FolderNavigationWidgetFactory::aboutToShowContextMenu,
|
||||
this,
|
||||
[this](QMenu *menu, const FilePath &filePath, bool isDir) {
|
||||
@@ -2955,7 +2955,7 @@ void ProjectExplorerPluginPrivate::extendFolderNavigationWidgetFactory()
|
||||
});
|
||||
}
|
||||
});
|
||||
connect(&m_folderNavigationWidgetFactory,
|
||||
connect(folderNavigationWidgetFactory,
|
||||
&FolderNavigationWidgetFactory::fileRenamed,
|
||||
this,
|
||||
[](const FilePath &before, const FilePath &after) {
|
||||
@@ -2979,7 +2979,7 @@ void ProjectExplorerPluginPrivate::extendFolderNavigationWidgetFactory()
|
||||
});
|
||||
}
|
||||
});
|
||||
connect(&m_folderNavigationWidgetFactory,
|
||||
connect(folderNavigationWidgetFactory,
|
||||
&FolderNavigationWidgetFactory::aboutToRemoveFile,
|
||||
this,
|
||||
[](const FilePath &filePath) {
|
||||
@@ -3846,7 +3846,8 @@ void ProjectExplorerPluginPrivate::showInFileSystemPane()
|
||||
{
|
||||
Node *currentNode = ProjectTree::currentNode();
|
||||
QTC_ASSERT(currentNode, return );
|
||||
QWidget *widget = NavigationWidget::activateSubWidget(m_folderNavigationWidgetFactory.id(),
|
||||
QWidget *widget
|
||||
= NavigationWidget::activateSubWidget(FolderNavigationWidgetFactory::instance()->id(),
|
||||
Side::Left);
|
||||
if (auto *navWidget = qobject_cast<FolderNavigationWidget *>(widget))
|
||||
navWidget->syncWithFilePath(currentNode->filePath());
|
||||
|
@@ -85,7 +85,6 @@ HEADERS += projectexplorer.h \
|
||||
applicationlauncher.h \
|
||||
runsettingspropertiespage.h \
|
||||
projecttreewidget.h \
|
||||
foldernavigationwidget.h \
|
||||
buildprogress.h \
|
||||
projectnodes.h \
|
||||
sessiondialog.h \
|
||||
@@ -239,7 +238,6 @@ SOURCES += projectexplorer.cpp \
|
||||
applicationlauncher.cpp \
|
||||
runsettingspropertiespage.cpp \
|
||||
projecttreewidget.cpp \
|
||||
foldernavigationwidget.cpp \
|
||||
buildprogress.cpp \
|
||||
projectnodes.cpp \
|
||||
sessiondialog.cpp \
|
||||
|
@@ -74,7 +74,6 @@ Project {
|
||||
"fileinsessionfinder.cpp", "fileinsessionfinder.h",
|
||||
"filesinallprojectsfind.cpp", "filesinallprojectsfind.h",
|
||||
"filterkitaspectsdialog.cpp", "filterkitaspectsdialog.h",
|
||||
"foldernavigationwidget.cpp", "foldernavigationwidget.h",
|
||||
"gccparser.cpp", "gccparser.h",
|
||||
"gcctoolchain.cpp", "gcctoolchain.h",
|
||||
"gcctoolchainfactories.h",
|
||||
|
@@ -28,7 +28,6 @@
|
||||
#include "buildconfiguration.h"
|
||||
#include "deployconfiguration.h"
|
||||
#include "editorconfiguration.h"
|
||||
#include "foldernavigationwidget.h"
|
||||
#include "kit.h"
|
||||
#include "project.h"
|
||||
#include "projectexplorer.h"
|
||||
@@ -37,6 +36,7 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/foldernavigationwidget.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/imode.h>
|
||||
|
@@ -34,15 +34,18 @@
|
||||
#include "outlinefactory.h"
|
||||
#include "plaintexteditorfactory.h"
|
||||
#include "snippets/snippetprovider.h"
|
||||
#include "textdocument.h"
|
||||
#include "texteditor.h"
|
||||
#include "texteditoractionhandler.h"
|
||||
#include "texteditorsettings.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/diffservice.h>
|
||||
#include <coreplugin/externaltoolmanager.h>
|
||||
#include <coreplugin/foldernavigationwidget.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
@@ -165,13 +168,26 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
tr("Text", "SnippetProvider"));
|
||||
|
||||
d->createStandardContextMenu();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextEditorPluginPrivate::extensionsInitialized()
|
||||
{
|
||||
connect(&settings, &TextEditorSettings::fontSettingsChanged,
|
||||
this, &TextEditorPluginPrivate::updateSearchResultsFont);
|
||||
connect(FolderNavigationWidgetFactory::instance(),
|
||||
&FolderNavigationWidgetFactory::aboutToShowContextMenu,
|
||||
this,
|
||||
[](QMenu *menu, const FilePath &filePath, bool isDir) {
|
||||
if (!isDir && Core::DiffService::instance()) {
|
||||
menu->addAction(TextEditor::TextDocument::createDiffAgainstCurrentFileAction(
|
||||
menu, [filePath]() { return filePath; }));
|
||||
}
|
||||
});
|
||||
|
||||
connect(&settings,
|
||||
&TextEditorSettings::fontSettingsChanged,
|
||||
this,
|
||||
&TextEditorPluginPrivate::updateSearchResultsFont);
|
||||
|
||||
updateSearchResultsFont(TextEditorSettings::fontSettings());
|
||||
|
||||
|
Reference in New Issue
Block a user