forked from qt-creator/qt-creator
CMakePM: Add directory icon overlay for know source groups
This way the CMake Project Manager will behave in the same way as QMake Project Manager! Change-Id: I3c4bd6b2f4f0f5d4dfc73edb2049d6e251154d54 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/fsengine/fileiconprovider.h>
|
|
||||||
#include <utils/mimeconstants.h>
|
#include <utils/mimeconstants.h>
|
||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
@@ -635,7 +634,6 @@ static FolderNode *createSourceGroupNode(const QString &sourceGroupName,
|
|||||||
if (!existingNode) {
|
if (!existingNode) {
|
||||||
auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p);
|
auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p);
|
||||||
node->setListInProject(false);
|
node->setListInProject(false);
|
||||||
node->setIcon([] { return FileIconProvider::icon(QFileIconProvider::Folder); });
|
|
||||||
|
|
||||||
existingNode = node.get();
|
existingNode = node.get();
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
@@ -27,6 +28,21 @@ bool defaultCMakeSourceGroupFolder(const QString &displayName)
|
|||||||
|| displayName == "State charts";
|
|| displayName == "State charts";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QIcon iconForSourceGroup(const QString &sourceGroup)
|
||||||
|
{
|
||||||
|
static const QHash<QString, QString> sourceGroupToOverlay = {
|
||||||
|
{"Forms", ProjectExplorer::Constants::FILEOVERLAY_UI},
|
||||||
|
{"Header Files", ProjectExplorer::Constants::FILEOVERLAY_H},
|
||||||
|
{"Resources", ProjectExplorer::Constants::FILEOVERLAY_QRC},
|
||||||
|
{"State charts", ProjectExplorer::Constants::FILEOVERLAY_SCXML},
|
||||||
|
{"Source Files", ProjectExplorer::Constants::FILEOVERLAY_CPP},
|
||||||
|
};
|
||||||
|
|
||||||
|
return sourceGroupToOverlay.contains(sourceGroup)
|
||||||
|
? FileIconProvider::directoryIcon(sourceGroupToOverlay.value(sourceGroup))
|
||||||
|
: FileIconProvider::icon(QFileIconProvider::Folder);
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
|
std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
|
||||||
int priority,
|
int priority,
|
||||||
const QString &displayName)
|
const QString &displayName)
|
||||||
@@ -34,6 +50,7 @@ std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
|
|||||||
auto newFolder = std::make_unique<VirtualFolderNode>(basePath);
|
auto newFolder = std::make_unique<VirtualFolderNode>(basePath);
|
||||||
newFolder->setPriority(priority);
|
newFolder->setPriority(priority);
|
||||||
newFolder->setDisplayName(displayName);
|
newFolder->setDisplayName(displayName);
|
||||||
|
newFolder->setIcon([displayName] { return iconForSourceGroup(displayName); });
|
||||||
newFolder->setIsSourcesOrHeaders(defaultCMakeSourceGroupFolder(displayName));
|
newFolder->setIsSourcesOrHeaders(defaultCMakeSourceGroupFolder(displayName));
|
||||||
return newFolder;
|
return newFolder;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user