aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2021-10-05 14:16:42 +0200
committerEike Ziller <eike.ziller@qt.io>2021-10-22 11:13:10 +0000
commitb2cdfccf54e1fe711203a6b470107a7811a952c5 (patch)
tree191f9873e7301dfaec1c2c78fb6a6273f6d291f1 /src
parent348c3c98a0ccd38d3a0a83e6c38170ce00517850 (diff)
Make File System view independent from ProjectExplorer
As preparation for moving it to Core so the "Show in File System View" functionality can spread more. Change-Id: I0f7d36f1d7eebe7b074c7949dd95b2cd985bfec8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/coreplugin/coreicons.cpp4
-rw-r--r--src/plugins/coreplugin/coreicons.h1
-rw-r--r--src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp7
-rw-r--r--src/plugins/projectexplorer/foldernavigationwidget.cpp150
-rw-r--r--src/plugins/projectexplorer/foldernavigationwidget.h9
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp141
-rw-r--r--src/plugins/projectexplorer/projectexplorericons.cpp2
-rw-r--r--src/plugins/projectexplorer/projectexplorericons.h1
8 files changed, 164 insertions, 151 deletions
diff --git a/src/plugins/coreplugin/coreicons.cpp b/src/plugins/coreplugin/coreicons.cpp
index 1f10b74bdf..fd3901f297 100644
--- a/src/plugins/coreplugin/coreicons.cpp
+++ b/src/plugins/coreplugin/coreicons.cpp
@@ -54,5 +54,9 @@ const Icon MODE_DESIGN_FLAT({
const Icon MODE_DESIGN_FLAT_ACTIVE({
{":/fancyactionbar/images/mode_design_mask.png", Theme::IconsModeDesignActiveColor}});
+const Icon DESKTOP_DEVICE_SMALL({{":/utils/images/desktopdevicesmall.png",
+ Theme::PanelTextColorDark}},
+ Icon::Tint);
+
} // namespace Icons
} // namespace Core
diff --git a/src/plugins/coreplugin/coreicons.h b/src/plugins/coreplugin/coreicons.h
index 412e980814..dd0292ba9a 100644
--- a/src/plugins/coreplugin/coreicons.h
+++ b/src/plugins/coreplugin/coreicons.h
@@ -43,6 +43,7 @@ CORE_EXPORT extern const Utils::Icon MODE_EDIT_FLAT_ACTIVE;
CORE_EXPORT extern const Utils::Icon MODE_DESIGN_CLASSIC;
CORE_EXPORT extern const Utils::Icon MODE_DESIGN_FLAT;
CORE_EXPORT extern const Utils::Icon MODE_DESIGN_FLAT_ACTIVE;
+CORE_EXPORT extern const Utils::Icon DESKTOP_DEVICE_SMALL;
} // namespace Icons
} // namespace Core
diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp b/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp
index 90f7bd92cb..949d35aa80 100644
--- a/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp
+++ b/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp
@@ -28,6 +28,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorericons.h>
+#include <coreplugin/coreicons.h>
#include <utils/icon.h>
#include <utils/qtcassert.h>
@@ -42,9 +43,9 @@ DesktopDeviceFactory::DesktopDeviceFactory()
setConstructionFunction([] { return IDevice::Ptr(new DesktopDevice); });
setDisplayName(DesktopDevice::tr("Desktop"));
setIcon(Utils::creatorTheme()->flag(Utils::Theme::FlatSideBarIcons)
- ? Utils::Icon::combinedIcon({Icons::DESKTOP_DEVICE.icon(),
- Icons::DESKTOP_DEVICE_SMALL.icon()})
- : QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
+ ? Utils::Icon::combinedIcon(
+ {Icons::DESKTOP_DEVICE.icon(), Core::Icons::DESKTOP_DEVICE_SMALL.icon()})
+ : QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
}
} // namespace Internal
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp
index 988d77eba5..00ce540697 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.cpp
+++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp
@@ -24,14 +24,10 @@
****************************************************************************/
#include "foldernavigationwidget.h"
-#include "projectexplorer.h"
-#include "projectexplorerconstants.h"
-#include "projectexplorericons.h"
-#include "projectnodes.h"
-#include "projecttree.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
+#include <coreplugin/coreicons.h>
#include <coreplugin/diffservice.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
@@ -90,6 +86,10 @@ const char kSyncKey[] = ".SyncWithEditor";
const char kShowBreadCrumbs[] = ".ShowBreadCrumbs";
const char kSyncRootWithEditor[] = ".SyncRootWithEditor";
+const char ADDNEWFILE[] = "QtCreator.FileSystem.AddNewFile";
+const char RENAMEFILE[] = "QtCreator.FileSystem.RenameFile";
+const char REMOVEFILE[] = "QtCreator.FileSystem.RemoveFile";
+
namespace ProjectExplorer {
namespace Internal {
@@ -199,29 +199,6 @@ Qt::ItemFlags FolderNavigationModel::flags(const QModelIndex &index) const
return QFileSystemModel::flags(index);
}
-static QVector<FolderNode *> renamableFolderNodes(const Utils::FilePath &before,
- const Utils::FilePath &after)
-{
- QVector<FolderNode *> folderNodes;
- ProjectTree::forEachNode([&](Node *node) {
- if (node->asFileNode()
- && node->filePath() == before
- && node->parentFolderNode()
- && node->parentFolderNode()->canRenameFile(before, after)) {
- folderNodes.append(node->parentFolderNode());
- }
- });
- return folderNodes;
-}
-
-static QStringList projectNames(const QVector<FolderNode *> &folders)
-{
- const QStringList names = Utils::transform<QList>(folders, [](FolderNode *n) {
- return n->managingProject()->filePath().fileName();
- });
- return Utils::filteredUnique(names);
-}
-
bool FolderNavigationModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
QTC_ASSERT(index.isValid() && parent(index).isValid() && index.column() == 0
@@ -238,25 +215,7 @@ bool FolderNavigationModel::setData(const QModelIndex &index, const QVariant &va
// for files we can do more than just rename on disk, for directories the user is on his/her own
if (success && fileInfo(index).isFile()) {
Core::DocumentManager::renamedFile(beforeFilePath, afterFilePath);
- const QVector<FolderNode *> folderNodes = renamableFolderNodes(beforeFilePath,
- afterFilePath);
- QVector<FolderNode *> failedNodes;
- for (FolderNode *folder : folderNodes) {
- if (!folder->renameFile(beforeFilePath, afterFilePath))
- failedNodes.append(folder);
- }
- if (!failedNodes.isEmpty()) {
- const QString projects = projectNames(failedNodes).join(", ");
- const QString errorMessage
- = FolderNavigationWidget::tr("The file \"%1\" was renamed to \"%2\", "
- "but the following projects could not be automatically changed: %3")
- .arg(beforeFilePath.toUserOutput(), afterFilePath.toUserOutput(), projects);
- QTimer::singleShot(0, Core::ICore::instance(), [errorMessage] {
- QMessageBox::warning(Core::ICore::dialogParent(),
- ProjectExplorerPlugin::tr("Project Editing Failed"),
- errorMessage);
- });
- }
+ emit m_instance->fileRenamed(beforeFilePath, afterFilePath);
}
return success;
}
@@ -509,7 +468,7 @@ void FolderNavigationWidget::addNewItem()
return;
const auto filePath = Utils::FilePath::fromString(m_fileSystemModel->filePath(current));
const Utils::FilePath path = filePath.isDir() ? filePath : filePath.parentDir();
- Core::ICore::showNewItemDialog(ProjectExplorerPlugin::tr("New File", "Title of dialog"),
+ Core::ICore::showNewItemDialog(tr("New File", "Title of dialog"),
Utils::filtered(Core::IWizardFactory::allWizardFactories(),
Utils::equal(&Core::IWizardFactory::kind,
Core::IWizardFactory::FileWizard)),
@@ -523,20 +482,6 @@ void FolderNavigationWidget::editCurrentItem()
m_listView->edit(current);
}
-static QVector<FolderNode *> removableFolderNodes(const Utils::FilePath &filePath)
-{
- QVector<FolderNode *> folderNodes;
- ProjectTree::forEachNode([&](Node *node) {
- if (node->asFileNode()
- && node->filePath() == filePath
- && node->parentFolderNode()
- && node->parentFolderNode()->supportsAction(RemoveFile, node)) {
- folderNodes.append(node->parentFolderNode());
- }
- });
- return folderNodes;
-}
-
void FolderNavigationWidget::removeCurrentItem()
{
const QModelIndex current = m_sortProxyModel->mapToSource(m_listView->currentIndex());
@@ -546,24 +491,9 @@ void FolderNavigationWidget::removeCurrentItem()
RemoveFileDialog dialog(filePath, Core::ICore::dialogParent());
dialog.setDeleteFileVisible(false);
if (dialog.exec() == QDialog::Accepted) {
- const QVector<FolderNode *> folderNodes = removableFolderNodes(filePath);
- const QVector<FolderNode *> failedNodes = Utils::filtered(folderNodes,
- [filePath](FolderNode *folder) {
- return folder->removeFiles({filePath}) != RemovedFilesFromProject::Ok;
- });
+ emit m_instance->aboutToRemoveFile(filePath);
Core::FileChangeBlocker changeGuard(filePath);
Core::FileUtils::removeFiles({filePath}, true /*delete from disk*/);
- if (!failedNodes.isEmpty()) {
- const QString projects = projectNames(failedNodes).join(", ");
- const QString errorMessage
- = tr("The following projects failed to automatically remove the file: %1")
- .arg(projects);
- QTimer::singleShot(0, Core::ICore::instance(), [errorMessage] {
- QMessageBox::warning(Core::ICore::dialogParent(),
- ProjectExplorerPlugin::tr("Project Editing Failed"),
- errorMessage);
- });
- }
}
}
@@ -674,24 +604,6 @@ void FolderNavigationWidget::openItem(const QModelIndex &index)
Core::EditorManager::openEditor(path);
}
-QStringList FolderNavigationWidget::projectsInDirectory(const QModelIndex &index) const
-{
- QTC_ASSERT(index.isValid() && m_fileSystemModel->isDir(index), return {});
- const QFileInfo fi = m_fileSystemModel->fileInfo(index);
- if (!fi.isReadable() || !fi.isExecutable())
- return {};
- const QString path = m_fileSystemModel->filePath(index);
- // Try to find project files in directory and open those.
- return FolderNavigationWidget::projectFilesInDirectory(path);
-}
-
-void FolderNavigationWidget::openProjectsInDirectory(const QModelIndex &index)
-{
- const QStringList projectFiles = projectsInDirectory(index);
- if (!projectFiles.isEmpty())
- Core::ICore::openFiles(Utils::transform(projectFiles, &FilePath::fromString));
-}
-
void FolderNavigationWidget::createNewFolder(const QModelIndex &parent)
{
static const QString baseName = tr("New Folder");
@@ -748,24 +660,15 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
const QModelIndex current = m_sortProxyModel->mapToSource(m_listView->currentIndex());
const bool hasCurrentItem = current.isValid();
QAction *actionOpenFile = nullptr;
- QAction *actionOpenProjects = nullptr;
- QAction *actionOpenAsProject = nullptr;
QAction *newFolder = nullptr;
const bool isDir = m_fileSystemModel->isDir(current);
const Utils::FilePath filePath = hasCurrentItem ? Utils::FilePath::fromString(
m_fileSystemModel->filePath(current))
: Utils::FilePath();
if (hasCurrentItem) {
- const QString fileName = m_fileSystemModel->fileName(current);
- if (isDir) {
- actionOpenProjects = menu.addAction(tr("Open Project in \"%1\"").arg(fileName));
- if (projectsInDirectory(current).isEmpty())
- actionOpenProjects->setEnabled(false);
- } else {
- actionOpenFile = menu.addAction(tr("Open \"%1\"").arg(fileName));
- if (ProjectExplorerPlugin::isProjectFile(Utils::FilePath::fromString(fileName)))
- actionOpenAsProject = menu.addAction(tr("Open Project \"%1\"").arg(fileName));
- }
+ if (!isDir)
+ actionOpenFile = menu.addAction(tr("Open \"%1\"").arg(filePath.toUserOutput()));
+ emit m_instance->aboutToShowContextMenu(&menu, filePath, isDir);
}
// we need dummy DocumentModel::Entry with absolute file path in it
@@ -777,11 +680,11 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
Core::EditorManager::addNativeDirAndOpenWithActions(&menu, &fakeEntry);
if (hasCurrentItem) {
- menu.addAction(Core::ActionManager::command(Constants::ADDNEWFILE)->action());
+ menu.addAction(Core::ActionManager::command(ADDNEWFILE)->action());
if (!isDir)
- menu.addAction(Core::ActionManager::command(Constants::REMOVEFILE)->action());
+ menu.addAction(Core::ActionManager::command(REMOVEFILE)->action());
if (m_fileSystemModel->flags(current) & Qt::ItemIsEditable)
- menu.addAction(Core::ActionManager::command(Constants::RENAMEFILE)->action());
+ menu.addAction(Core::ActionManager::command(RENAMEFILE)->action());
newFolder = menu.addAction(tr("New Folder"));
if (!isDir && Core::DiffService::instance()) {
menu.addAction(
@@ -792,7 +695,7 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
}
menu.addSeparator();
- QAction * const collapseAllAction = menu.addAction(ProjectExplorerPlugin::tr("Collapse All"));
+ QAction *const collapseAllAction = menu.addAction(tr("Collapse All"));
QAction *action = menu.exec(ev->globalPos());
if (!action)
@@ -801,11 +704,7 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
ev->accept();
if (action == actionOpenFile) {
openItem(current);
- } else if (action == actionOpenAsProject) {
- ProjectExplorerPlugin::openProject(filePath);
- } else if (action == actionOpenProjects)
- openProjectsInDirectory(current);
- else if (action == newFolder) {
+ } else if (action == newFolder) {
if (isDir)
createNewFolder(current);
else
@@ -846,15 +745,6 @@ bool FolderNavigationWidget::isShowingFoldersOnTop() const
return m_showFoldersOnTopAction->isChecked();
}
-QStringList FolderNavigationWidget::projectFilesInDirectory(const QString &path)
-{
- QDir dir(path);
- QStringList projectFiles;
- foreach (const QFileInfo &i, dir.entryInfoList(ProjectExplorerPlugin::projectFileGlobs(), QDir::Files))
- projectFiles.append(i.absoluteFilePath());
- return projectFiles;
-}
-
// --------------------FolderNavigationWidgetFactory
FolderNavigationWidgetFactory::FolderNavigationWidgetFactory()
{
@@ -868,7 +758,7 @@ FolderNavigationWidgetFactory::FolderNavigationWidgetFactory()
0 /*sortValue*/,
FolderNavigationWidget::tr("Computer"),
Utils::FilePath(),
- Icons::DESKTOP_DEVICE_SMALL.icon()});
+ Core::Icons::DESKTOP_DEVICE_SMALL.icon()});
insertRootDirectory({QLatin1String("A.Home"),
10 /*sortValue*/,
FolderNavigationWidget::tr("Home"),
@@ -999,21 +889,21 @@ void FolderNavigationWidgetFactory::registerActions()
Core::Context context(C_FOLDERNAVIGATIONWIDGET);
auto add = new QAction(tr("Add New..."), this);
- Core::ActionManager::registerAction(add, Constants::ADDNEWFILE, context);
+ Core::ActionManager::registerAction(add, ADDNEWFILE, context);
connect(add, &QAction::triggered, Core::ICore::instance(), [] {
if (auto navWidget = currentFolderNavigationWidget())
navWidget->addNewItem();
});
auto rename = new QAction(tr("Rename..."), this);
- Core::ActionManager::registerAction(rename, Constants::RENAMEFILE, context);
+ Core::ActionManager::registerAction(rename, RENAMEFILE, context);
connect(rename, &QAction::triggered, Core::ICore::instance(), [] {
if (auto navWidget = currentFolderNavigationWidget())
navWidget->editCurrentItem();
});
auto remove = new QAction(tr("Remove..."), this);
- Core::ActionManager::registerAction(remove, Constants::REMOVEFILE, context);
+ Core::ActionManager::registerAction(remove, REMOVEFILE, context);
connect(remove, &QAction::triggered, Core::ICore::instance(), [] {
if (auto navWidget = currentFolderNavigationWidget())
navWidget->removeCurrentItem();
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h
index 06fef60225..8b823a63e1 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.h
+++ b/src/plugins/projectexplorer/foldernavigationwidget.h
@@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE
class QAction;
class QComboBox;
class QFileSystemModel;
+class QMenu;
class QModelIndex;
class QSortFilterProxyModel;
QT_END_NAMESPACE
@@ -85,6 +86,10 @@ signals:
void rootDirectoryAdded(const RootDirectory &directory);
void rootDirectoryRemoved(const QString &id);
+ void aboutToShowContextMenu(QMenu *menu, const Utils::FilePath &filePath, bool isDir);
+ void fileRenamed(const Utils::FilePath &before, const Utils::FilePath &after);
+ void aboutToRemoveFile(const Utils::FilePath &filePath);
+
private:
static int rootIndex(const QString &id);
void updateProjectsDirectoryRoot();
@@ -101,8 +106,6 @@ class FolderNavigationWidget : public QWidget
public:
explicit FolderNavigationWidget(QWidget *parent = nullptr);
- static QStringList projectFilesInDirectory(const QString &path);
-
bool autoSynchronization() const;
bool hiddenFilesFilter() const;
bool isShowingBreadCrumbs() const;
@@ -138,8 +141,6 @@ private:
void setRootDirectory(const Utils::FilePath &directory);
int bestRootForFile(const Utils::FilePath &filePath);
void openItem(const QModelIndex &index);
- QStringList projectsInDirectory(const QModelIndex &index) const;
- void openProjectsInDirectory(const QModelIndex &index);
void createNewFolder(const QModelIndex &parent);
Utils::NavigationTreeView *m_listView = nullptr;
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 46db91993a..c9fcf0ff26 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -491,6 +491,8 @@ public:
QList<QPair<QString, QString> > recentProjects() const;
+ void extendFolderNavigationWidgetFactory();
+
public:
QMenu *m_sessionMenu;
QMenu *m_openWithMenu;
@@ -692,6 +694,57 @@ public:
static ProjectExplorerPlugin *m_instance = nullptr;
static ProjectExplorerPluginPrivate *dd = nullptr;
+static FilePaths projectFilesInDirectory(const FilePath &path)
+{
+ return path.dirEntries(ProjectExplorerPlugin::projectFileGlobs(), QDir::Files);
+}
+
+static FilePaths projectsInDirectory(const FilePath &filePath)
+{
+ if (!filePath.isReadableDir())
+ return {};
+ return projectFilesInDirectory(filePath);
+}
+
+static void openProjectsInDirectory(const FilePath &filePath)
+{
+ const FilePaths projectFiles = projectsInDirectory(filePath);
+ if (!projectFiles.isEmpty())
+ Core::ICore::openFiles(projectFiles);
+}
+
+static QStringList projectNames(const QVector<FolderNode *> &folders)
+{
+ const QStringList names = Utils::transform<QList>(folders, [](FolderNode *n) {
+ return n->managingProject()->filePath().fileName();
+ });
+ return Utils::filteredUnique(names);
+}
+
+static QVector<FolderNode *> renamableFolderNodes(const FilePath &before, const FilePath &after)
+{
+ QVector<FolderNode *> folderNodes;
+ ProjectTree::forEachNode([&](Node *node) {
+ if (node->asFileNode() && node->filePath() == before && node->parentFolderNode()
+ && node->parentFolderNode()->canRenameFile(before, after)) {
+ folderNodes.append(node->parentFolderNode());
+ }
+ });
+ return folderNodes;
+}
+
+static QVector<FolderNode *> removableFolderNodes(const Utils::FilePath &filePath)
+{
+ QVector<FolderNode *> folderNodes;
+ ProjectTree::forEachNode([&](Node *node) {
+ if (node->asFileNode() && node->filePath() == filePath && node->parentFolderNode()
+ && node->parentFolderNode()->supportsAction(RemoveFile, node)) {
+ folderNodes.append(node->parentFolderNode());
+ }
+ });
+ return folderNodes;
+}
+
ProjectExplorerPlugin::ProjectExplorerPlugin()
{
m_instance = this;
@@ -726,6 +779,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd = new ProjectExplorerPluginPrivate;
+ dd->extendFolderNavigationWidgetFactory();
+
qRegisterMetaType<ProjectExplorer::BuildSystem *>();
qRegisterMetaType<ProjectExplorer::RunControl *>();
qRegisterMetaType<ProjectExplorer::DeployableFile>("ProjectExplorer::DeployableFile");
@@ -1377,7 +1432,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
// add new file action
- dd->m_addNewFileAction = new QAction(this);
+ dd->m_addNewFileAction = new QAction(tr("Add New..."), this);
cmd = ActionManager::registerAction(dd->m_addNewFileAction, Constants::ADDNEWFILE,
projectTreeContext);
mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
@@ -1446,7 +1501,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
// remove file action
- dd->m_removeFileAction = new QAction(this);
+ dd->m_removeFileAction = new QAction(tr("Remove..."), this);
cmd = ActionManager::registerAction(dd->m_removeFileAction, Constants::REMOVEFILE,
projectTreeContext);
cmd->setDefaultKeySequences({QKeySequence::Delete, QKeySequence::Backspace});
@@ -1472,7 +1527,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
// renamefile action
- dd->m_renameFileAction = new QAction(this);
+ dd->m_renameFileAction = new QAction(tr("Rename..."), this);
cmd = ActionManager::registerAction(dd->m_renameFileAction, Constants::RENAMEFILE,
projectTreeContext);
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
@@ -2116,10 +2171,9 @@ void ProjectExplorerPlugin::extensionsInitialized()
dd->m_documentFactory.setOpener([](FilePath filePath) {
if (filePath.isDir()) {
- const QStringList files =
- FolderNavigationWidget::projectFilesInDirectory(filePath.absoluteFilePath().toString());
+ const FilePaths files = projectFilesInDirectory(filePath.absoluteFilePath());
if (!files.isEmpty())
- filePath = FilePath::fromString(files.front());
+ filePath = files.front();
}
OpenProjectResult result = ProjectExplorerPlugin::openProject(filePath);
@@ -2876,11 +2930,76 @@ bool ProjectExplorerPlugin::saveModifiedFiles()
return true;
}
-//NBS handle case where there is no activeBuildConfiguration
-// because someone delete all build configurations
-
-ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate()
-{
+ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() {}
+
+void ProjectExplorerPluginPrivate::extendFolderNavigationWidgetFactory()
+{
+ connect(&m_folderNavigationWidgetFactory,
+ &FolderNavigationWidgetFactory::aboutToShowContextMenu,
+ this,
+ [this](QMenu *menu, const FilePath &filePath, bool isDir) {
+ if (isDir) {
+ QAction *actionOpenProjects = menu->addAction(
+ ProjectExplorerPlugin::tr("Open Project in \"%1\"")
+ .arg(filePath.toUserOutput()));
+ connect(actionOpenProjects, &QAction::triggered, this, [filePath] {
+ openProjectsInDirectory(filePath);
+ });
+ if (projectsInDirectory(filePath).isEmpty())
+ actionOpenProjects->setEnabled(false);
+ } else if (ProjectExplorerPlugin::isProjectFile(filePath)) {
+ QAction *actionOpenAsProject = menu->addAction(
+ tr("Open Project \"%1\"").arg(filePath.toUserOutput()));
+ connect(actionOpenAsProject, &QAction::triggered, this, [filePath] {
+ ProjectExplorerPlugin::openProject(filePath);
+ });
+ }
+ });
+ connect(&m_folderNavigationWidgetFactory,
+ &FolderNavigationWidgetFactory::fileRenamed,
+ this,
+ [](const FilePath &before, const FilePath &after) {
+ const QVector<FolderNode *> folderNodes = renamableFolderNodes(before, after);
+ QVector<FolderNode *> failedNodes;
+ for (FolderNode *folder : folderNodes) {
+ if (!folder->renameFile(before, after))
+ failedNodes.append(folder);
+ }
+ if (!failedNodes.isEmpty()) {
+ const QString projects = projectNames(failedNodes).join(", ");
+ const QString errorMessage
+ = ProjectExplorerPlugin::tr(
+ "The file \"%1\" was renamed to \"%2\", "
+ "but the following projects could not be automatically changed: %3")
+ .arg(before.toUserOutput(), after.toUserOutput(), projects);
+ QTimer::singleShot(0, Core::ICore::instance(), [errorMessage] {
+ QMessageBox::warning(Core::ICore::dialogParent(),
+ ProjectExplorerPlugin::tr("Project Editing Failed"),
+ errorMessage);
+ });
+ }
+ });
+ connect(&m_folderNavigationWidgetFactory,
+ &FolderNavigationWidgetFactory::aboutToRemoveFile,
+ this,
+ [](const FilePath &filePath) {
+ const QVector<FolderNode *> folderNodes = removableFolderNodes(filePath);
+ const QVector<FolderNode *> failedNodes
+ = Utils::filtered(folderNodes, [filePath](FolderNode *folder) {
+ return folder->removeFiles({filePath}) != RemovedFilesFromProject::Ok;
+ });
+ if (!failedNodes.isEmpty()) {
+ const QString projects = projectNames(failedNodes).join(", ");
+ const QString errorMessage
+ = tr("The following projects failed to automatically remove the file: %1")
+ .arg(projects);
+ QTimer::singleShot(0, Core::ICore::instance(), [errorMessage] {
+ QMessageBox::warning(Core::ICore::dialogParent(),
+ tr("Project Editing Failed"),
+ errorMessage);
+ });
+ }
+ });
}
void ProjectExplorerPluginPrivate::runProjectContextMenu()
diff --git a/src/plugins/projectexplorer/projectexplorericons.cpp b/src/plugins/projectexplorer/projectexplorericons.cpp
index 663e16a9ae..e06c9af9ed 100644
--- a/src/plugins/projectexplorer/projectexplorericons.cpp
+++ b/src/plugins/projectexplorer/projectexplorericons.cpp
@@ -94,8 +94,6 @@ const Icon BUILDSTEP_REMOVE({
const Icon DESKTOP_DEVICE({
{":/projectexplorer/images/desktopdevice.png", Theme::IconsBaseColor}});
-const Icon DESKTOP_DEVICE_SMALL({
- {":/utils/images/desktopdevicesmall.png", Theme::PanelTextColorDark}}, Icon::Tint);
const Icon MODE_PROJECT_CLASSIC(":/projectexplorer/images/mode_project.png");
const Icon MODE_PROJECT_FLAT({
diff --git a/src/plugins/projectexplorer/projectexplorericons.h b/src/plugins/projectexplorer/projectexplorericons.h
index 56969e962d..3f39c663d9 100644
--- a/src/plugins/projectexplorer/projectexplorericons.h
+++ b/src/plugins/projectexplorer/projectexplorericons.h
@@ -61,7 +61,6 @@ PROJECTEXPLORER_EXPORT extern const Utils::Icon BUILDSTEP_DISABLE;
PROJECTEXPLORER_EXPORT extern const Utils::Icon BUILDSTEP_REMOVE;
PROJECTEXPLORER_EXPORT extern const Utils::Icon DESKTOP_DEVICE;
-PROJECTEXPLORER_EXPORT extern const Utils::Icon DESKTOP_DEVICE_SMALL;
PROJECTEXPLORER_EXPORT extern const Utils::Icon MODE_PROJECT_CLASSIC;
PROJECTEXPLORER_EXPORT extern const Utils::Icon MODE_PROJECT_FLAT;