forked from qt-creator/qt-creator
QmlDesigner: Improve file filtering of the resourcegenerator
and collect functions to identify images, assets and resources in one spot. Fixes: QDS-12839 Change-Id: I510673b0756dc1e580d753f54831b4c23224056b Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <qmlprojectmanager/buildsystem/qmlbuildsystem.h>
|
#include <qmlprojectmanager/buildsystem/qmlbuildsystem.h>
|
||||||
#include <qmlprojectmanager/qmlprojectconstants.h>
|
#include <qmlprojectmanager/qmlprojectconstants.h>
|
||||||
|
#include <qmlprojectmanager/cmakegen/filetypes.h>
|
||||||
|
|
||||||
#include <qtsupport/qtkitaspect.h>
|
#include <qtsupport/qtkitaspect.h>
|
||||||
|
|
||||||
@@ -143,41 +144,17 @@ void generateMenuEntry(QObject *parent)
|
|||||||
exportMenu->addAction(cmd2, QmlProjectManager::Constants::G_EXPORT_GENERATE);
|
exportMenu->addAction(cmd2, QmlProjectManager::Constants::G_EXPORT_GENERATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool skipSuffix(const QString &fileName)
|
|
||||||
{
|
|
||||||
const QStringList suffixes = {".pri",
|
|
||||||
".pro",
|
|
||||||
".user",
|
|
||||||
".qrc",
|
|
||||||
".qds",
|
|
||||||
"CMakeLists.txt",
|
|
||||||
".db",
|
|
||||||
".tmp",
|
|
||||||
".TMP",
|
|
||||||
".metainfo",
|
|
||||||
".qtds",
|
|
||||||
".db-shm",
|
|
||||||
".db-wal"};
|
|
||||||
|
|
||||||
for (const auto &suffix : suffixes)
|
|
||||||
if (fileName.endsWith(suffix))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList getProjectFileList()
|
QStringList getProjectFileList()
|
||||||
{
|
{
|
||||||
const ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
|
const ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
|
||||||
const FilePaths paths = project->files(ProjectExplorer::Project::AllFiles);
|
const FilePaths paths = project->files(ProjectExplorer::Project::AllFiles);
|
||||||
|
|
||||||
const QDir dir(project->projectFilePath().parentDir().toString());
|
|
||||||
QStringList selectedFileList;
|
QStringList selectedFileList;
|
||||||
|
const Utils::FilePath dir(project->projectFilePath().parentDir());
|
||||||
for (const FilePath &path : paths) {
|
for (const FilePath &path : paths) {
|
||||||
QString relativePath = dir.relativeFilePath(path.toString());
|
const Utils::FilePath relativePath = path.relativePathFrom(dir);
|
||||||
if (!skipSuffix(relativePath))
|
if (QmlProjectManager::isResource(relativePath))
|
||||||
selectedFileList.append(relativePath);
|
selectedFileList.append(relativePath.path());
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedFileList;
|
return selectedFileList;
|
||||||
|
@@ -11,7 +11,6 @@ namespace QmlDesigner::ResourceGenerator {
|
|||||||
|
|
||||||
QMLDESIGNERCOMPONENTS_EXPORT void generateMenuEntry(QObject *parent);
|
QMLDESIGNERCOMPONENTS_EXPORT void generateMenuEntry(QObject *parent);
|
||||||
QMLDESIGNERCOMPONENTS_EXPORT QStringList getProjectFileList();
|
QMLDESIGNERCOMPONENTS_EXPORT QStringList getProjectFileList();
|
||||||
QMLDESIGNERCOMPONENTS_EXPORT bool skipSuffix(const QString &fileName);
|
|
||||||
QMLDESIGNERCOMPONENTS_EXPORT bool createQrcFile(const Utils::FilePath &qrcFilePath);
|
QMLDESIGNERCOMPONENTS_EXPORT bool createQrcFile(const Utils::FilePath &qrcFilePath);
|
||||||
QMLDESIGNERCOMPONENTS_EXPORT bool createQmlrcFile(const Utils::FilePath &qmlrcFilePath);
|
QMLDESIGNERCOMPONENTS_EXPORT bool createQmlrcFile(const Utils::FilePath &qmlrcFilePath);
|
||||||
|
|
||||||
|
@@ -46,19 +46,21 @@ extend_qtc_plugin(QmlProjectManager
|
|||||||
cmakewriter.cpp cmakewriter.h
|
cmakewriter.cpp cmakewriter.h
|
||||||
cmakewriterv0.cpp cmakewriterv0.h
|
cmakewriterv0.cpp cmakewriterv0.h
|
||||||
cmakewriterv1.cpp cmakewriterv1.h
|
cmakewriterv1.cpp cmakewriterv1.h
|
||||||
|
filetypes.cpp filetypes.h
|
||||||
boilerplate.qrc
|
boilerplate.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
add_qtc_library(QmlProjectManagerLib OBJECT
|
add_qtc_library(QmlProjectManagerLib OBJECT
|
||||||
CONDITION Qt6_VERSION VERSION_GREATER_EQUAL 6.4.3
|
CONDITION WITH_TESTS AND Qt6_VERSION VERSION_GREATER_EQUAL 6.4.3
|
||||||
EXCLUDE_FROM_INSTALL
|
EXCLUDE_FROM_INSTALL
|
||||||
|
DEFINES QMLPROJECTMANAGER_STATIC_LIBRARY
|
||||||
DEPENDS
|
DEPENDS
|
||||||
QmlJS Utils ProjectExplorer
|
QmlJS Utils ProjectExplorer
|
||||||
INCLUDES
|
INCLUDES
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/buildsystem
|
|
||||||
SOURCES
|
SOURCES
|
||||||
projectitem/filefilteritems.cpp projectitem/filefilteritems.h
|
buildsystem/projectitem/filefilteritems.cpp buildsystem/projectitem/filefilteritems.h
|
||||||
projectitem/qmlprojectitem.cpp projectitem/qmlprojectitem.h
|
buildsystem/projectitem/qmlprojectitem.cpp buildsystem/projectitem/qmlprojectitem.h
|
||||||
projectitem/converters.cpp projectitem/converters.h
|
buildsystem/projectitem/converters.cpp buildsystem/projectitem/converters.h
|
||||||
|
cmakegen/filetypes.cpp cmakegen/filetypes.h
|
||||||
)
|
)
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "converters.h"
|
#include "converters.h"
|
||||||
#include "utils/algorithm.h"
|
#include "utils/algorithm.h"
|
||||||
|
#include "cmakegen/filetypes.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
@@ -10,17 +11,10 @@ namespace QmlProjectManager::Converters {
|
|||||||
|
|
||||||
const static QStringList qmlFilesFilter{QStringLiteral("*.qml")};
|
const static QStringList qmlFilesFilter{QStringLiteral("*.qml")};
|
||||||
const static QStringList javaScriptFilesFilter{QStringLiteral("*.js"), QStringLiteral("*.ts")};
|
const static QStringList javaScriptFilesFilter{QStringLiteral("*.js"), QStringLiteral("*.ts")};
|
||||||
const static QStringList imageFilesFilter{QStringLiteral("*.jpeg"),
|
|
||||||
QStringLiteral("*.jpg"),
|
const QStringList imageFilesFilter() {
|
||||||
QStringLiteral("*.png"),
|
return imageFiles([](const QString& suffix) { return "*." + suffix; });
|
||||||
QStringLiteral("*.svg"),
|
}
|
||||||
QStringLiteral("*.hdr"),
|
|
||||||
QStringLiteral("*.ktx"),
|
|
||||||
QStringLiteral("*.bmp"),
|
|
||||||
QStringLiteral("*.ttf"),
|
|
||||||
QStringLiteral("*.tiff"),
|
|
||||||
QStringLiteral("*.webp"),
|
|
||||||
QStringLiteral("*.gif")};
|
|
||||||
|
|
||||||
QString jsonValueToString(const QJsonValue &val, int indentationLevel, bool indented);
|
QString jsonValueToString(const QJsonValue &val, int indentationLevel, bool indented);
|
||||||
|
|
||||||
@@ -123,7 +117,7 @@ QString jsonToQmlProject(const QJsonObject &rootObject)
|
|||||||
if (nodeName.toLower() == "qmlfiles") {
|
if (nodeName.toLower() == "qmlfiles") {
|
||||||
filter = qmlFilesFilter;
|
filter = qmlFilesFilter;
|
||||||
} else if (nodeName.toLower() == "imagefiles") {
|
} else if (nodeName.toLower() == "imagefiles") {
|
||||||
filter = imageFilesFilter;
|
filter = imageFilesFilter();
|
||||||
} else if (nodeName.toLower() == "javascriptfiles") {
|
} else if (nodeName.toLower() == "javascriptfiles") {
|
||||||
filter = javaScriptFilesFilter;
|
filter = javaScriptFilesFilter;
|
||||||
}
|
}
|
||||||
@@ -459,7 +453,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
|||||||
} else if (childNodeName == "javascriptfiles") {
|
} else if (childNodeName == "javascriptfiles") {
|
||||||
inserter(javaScriptFilesFilter);
|
inserter(javaScriptFilesFilter);
|
||||||
} else if (childNodeName == "imagefiles") {
|
} else if (childNodeName == "imagefiles") {
|
||||||
inserter(imageFilesFilter);
|
inserter(imageFilesFilter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "cmakegenerator.h"
|
#include "cmakegenerator.h"
|
||||||
|
#include "filetypes.h"
|
||||||
|
|
||||||
#include "qmlprojectmanager/qmlproject.h"
|
#include "qmlprojectmanager/qmlproject.h"
|
||||||
#include "qmlprojectmanager/qmlprojectconstants.h"
|
#include "qmlprojectmanager/qmlprojectconstants.h"
|
||||||
@@ -197,21 +198,6 @@ void CMakeGenerator::update(const QSet<QString> &added, const QSet<QString> &rem
|
|||||||
createSourceFiles();
|
createSourceFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMakeGenerator::isQml(const Utils::FilePath &path) const
|
|
||||||
{
|
|
||||||
const QString suffix = path.suffix();
|
|
||||||
return suffix == "qml" || suffix == "ui.qml";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeGenerator::isResource(const Utils::FilePath &path) const
|
|
||||||
{
|
|
||||||
static const QStringList suffixes = {
|
|
||||||
"json", "mesh", "dae", "qad", "hints", "png", "hdr", "ttf", "jpg",
|
|
||||||
"jpeg", "js", "qsb", "frag", "frag.qsb", "vert", "vert.qsb", "svg",
|
|
||||||
"ktx", "bmp", "gif", "webp", "tiff"};
|
|
||||||
return suffixes.contains(path.suffix(), Qt::CaseInsensitive);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeGenerator::ignore(const Utils::FilePath &path) const
|
bool CMakeGenerator::ignore(const Utils::FilePath &path) const
|
||||||
{
|
{
|
||||||
if (path.isFile()) {
|
if (path.isFile()) {
|
||||||
@@ -386,9 +372,9 @@ bool findFileWithGetter(const Utils::FilePath &file, const NodePtr &node, const
|
|||||||
|
|
||||||
bool CMakeGenerator::findFile(const NodePtr &node, const Utils::FilePath &file) const
|
bool CMakeGenerator::findFile(const NodePtr &node, const Utils::FilePath &file) const
|
||||||
{
|
{
|
||||||
if (isResource(file)) {
|
if (isAssetFile(file)) {
|
||||||
return findFileWithGetter(file, node, [](const NodePtr &n) { return n->resources; });
|
return findFileWithGetter(file, node, [](const NodePtr &n) { return n->assets; });
|
||||||
} else if (isQml(file)) {
|
} else if (isQmlFile(file)) {
|
||||||
if (findFileWithGetter(file, node, [](const NodePtr &n) { return n->files; }))
|
if (findFileWithGetter(file, node, [](const NodePtr &n) { return n->files; }))
|
||||||
return true;
|
return true;
|
||||||
else if (findFileWithGetter(file, node, [](const NodePtr &n) { return n->singletons; }))
|
else if (findFileWithGetter(file, node, [](const NodePtr &n) { return n->singletons; }))
|
||||||
@@ -407,10 +393,10 @@ void CMakeGenerator::insertFile(NodePtr &node, const Utils::FilePath &path) cons
|
|||||||
readQmlDir(path, node);
|
readQmlDir(path, node);
|
||||||
} else if (path.suffix() == "cpp") {
|
} else if (path.suffix() == "cpp") {
|
||||||
node->sources.push_back(path);
|
node->sources.push_back(path);
|
||||||
} else if (isQml(path)) {
|
} else if (isQmlFile(path)) {
|
||||||
node->files.push_back(path);
|
node->files.push_back(path);
|
||||||
} else if (isResource(path)) {
|
} else if (isAssetFile(path)) {
|
||||||
node->resources.push_back(path);
|
node->assets.push_back(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,15 +407,14 @@ void CMakeGenerator::removeFile(NodePtr &node, const Utils::FilePath &path) cons
|
|||||||
node->singletons.clear();
|
node->singletons.clear();
|
||||||
node->uri = "";
|
node->uri = "";
|
||||||
node->name = path.parentDir().fileName();
|
node->name = path.parentDir().fileName();
|
||||||
|
} else if (isQmlFile(path)) {
|
||||||
} else if (isQml(path)) {
|
|
||||||
auto iter = std::find(node->files.begin(), node->files.end(), path);
|
auto iter = std::find(node->files.begin(), node->files.end(), path);
|
||||||
if (iter != node->files.end())
|
if (iter != node->files.end())
|
||||||
node->files.erase(iter);
|
node->files.erase(iter);
|
||||||
} else if (isResource(path)) {
|
} else if (isAssetFile(path)) {
|
||||||
auto iter = std::find(node->resources.begin(), node->resources.end(), path);
|
auto iter = std::find(node->assets.begin(), node->assets.end(), path);
|
||||||
if (iter != node->resources.end())
|
if (iter != node->assets.end())
|
||||||
node->resources.erase(iter);
|
node->assets.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +460,7 @@ void CMakeGenerator::printNodeTree(const NodePtr &generatorNode, size_t indent)
|
|||||||
qDebug() << addIndent(indent) << "directory: " << generatorNode->dir;
|
qDebug() << addIndent(indent) << "directory: " << generatorNode->dir;
|
||||||
qDebug() << addIndent(indent) << "files: " << generatorNode->files;
|
qDebug() << addIndent(indent) << "files: " << generatorNode->files;
|
||||||
qDebug() << addIndent(indent) << "singletons: " << generatorNode->singletons;
|
qDebug() << addIndent(indent) << "singletons: " << generatorNode->singletons;
|
||||||
qDebug() << addIndent(indent) << "resources: " << generatorNode->resources;
|
qDebug() << addIndent(indent) << "assets: " << generatorNode->assets;
|
||||||
qDebug() << addIndent(indent) << "sources: " << generatorNode->sources;
|
qDebug() << addIndent(indent) << "sources: " << generatorNode->sources;
|
||||||
|
|
||||||
for (const auto &child : generatorNode->subdirs)
|
for (const auto &child : generatorNode->subdirs)
|
||||||
@@ -547,7 +532,7 @@ void CMakeGenerator::compareWithFileSystem(const NodePtr &node) const
|
|||||||
if (ignore(next.parentDir()))
|
if (ignore(next.parentDir()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isResource(next) && !findFile(next) && !ignore(next))
|
if (isAssetFile(next) && !findFile(next) && !ignore(next))
|
||||||
files.push_back(next);
|
files.push_back(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,8 +45,6 @@ public:
|
|||||||
void updateMenuAction();
|
void updateMenuAction();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isQml(const Utils::FilePath &path) const;
|
|
||||||
bool isResource(const Utils::FilePath &path) const;
|
|
||||||
bool ignore(const Utils::FilePath &path) const;
|
bool ignore(const Utils::FilePath &path) const;
|
||||||
bool checkUri(const QString& uri, const Utils::FilePath &path) const;
|
bool checkUri(const QString& uri, const Utils::FilePath &path) const;
|
||||||
|
|
||||||
|
@@ -98,9 +98,9 @@ std::vector<Utils::FilePath> CMakeWriter::singletons(const NodePtr &node) const
|
|||||||
return files(node, [](const NodePtr &n) { return n->singletons; });
|
return files(node, [](const NodePtr &n) { return n->singletons; });
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Utils::FilePath> CMakeWriter::resources(const NodePtr &node) const
|
std::vector<Utils::FilePath> CMakeWriter::assets(const NodePtr &node) const
|
||||||
{
|
{
|
||||||
return files(node, [](const NodePtr &n) { return n->resources; });
|
return files(node, [](const NodePtr &n) { return n->assets; });
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Utils::FilePath> CMakeWriter::sources(const NodePtr &node) const
|
std::vector<Utils::FilePath> CMakeWriter::sources(const NodePtr &node) const
|
||||||
@@ -229,7 +229,7 @@ std::tuple<QString, QString> CMakeWriter::makeResourcesBlocks(const NodePtr &nod
|
|||||||
|
|
||||||
QString resourceFiles;
|
QString resourceFiles;
|
||||||
std::vector<QString> bigResources;
|
std::vector<QString> bigResources;
|
||||||
for (const Utils::FilePath &path : resources(node)) {
|
for (const Utils::FilePath &path : assets(node)) {
|
||||||
if (path.fileSize() > 5000000) {
|
if (path.fileSize() > 5000000) {
|
||||||
bigResources.push_back(makeRelative(node, path));
|
bigResources.push_back(makeRelative(node, path));
|
||||||
continue;
|
continue;
|
||||||
|
@@ -32,7 +32,7 @@ struct Node
|
|||||||
std::vector<std::shared_ptr<Node>> subdirs;
|
std::vector<std::shared_ptr<Node>> subdirs;
|
||||||
std::vector<Utils::FilePath> files;
|
std::vector<Utils::FilePath> files;
|
||||||
std::vector<Utils::FilePath> singletons;
|
std::vector<Utils::FilePath> singletons;
|
||||||
std::vector<Utils::FilePath> resources;
|
std::vector<Utils::FilePath> assets;
|
||||||
std::vector<Utils::FilePath> sources;
|
std::vector<Utils::FilePath> sources;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ protected:
|
|||||||
std::vector<Utils::FilePath> files(const NodePtr &node, const FileGetter &getter) const;
|
std::vector<Utils::FilePath> files(const NodePtr &node, const FileGetter &getter) const;
|
||||||
std::vector<Utils::FilePath> qmlFiles(const NodePtr &node) const;
|
std::vector<Utils::FilePath> qmlFiles(const NodePtr &node) const;
|
||||||
std::vector<Utils::FilePath> singletons(const NodePtr &node) const;
|
std::vector<Utils::FilePath> singletons(const NodePtr &node) const;
|
||||||
std::vector<Utils::FilePath> resources(const NodePtr &node) const;
|
std::vector<Utils::FilePath> assets(const NodePtr &node) const;
|
||||||
std::vector<Utils::FilePath> sources(const NodePtr &node) const;
|
std::vector<Utils::FilePath> sources(const NodePtr &node) const;
|
||||||
std::vector<QString> plugins(const NodePtr &node) const;
|
std::vector<QString> plugins(const NodePtr &node) const;
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ CMakeWriterV0::CMakeWriterV0(CMakeGenerator *parent)
|
|||||||
bool CMakeWriterV0::isPlugin(const NodePtr &node) const
|
bool CMakeWriterV0::isPlugin(const NodePtr &node) const
|
||||||
{
|
{
|
||||||
if (node->type == Node::Type::App)
|
if (node->type == Node::Type::App)
|
||||||
return !node->files.empty() || !node->singletons.empty() || !node->resources.empty();
|
return !node->files.empty() || !node->singletons.empty() || !node->assets.empty();
|
||||||
|
|
||||||
return CMakeWriter::isPlugin(node);
|
return CMakeWriter::isPlugin(node);
|
||||||
}
|
}
|
||||||
|
52
src/plugins/qmlprojectmanager/cmakegen/filetypes.cpp
Normal file
52
src/plugins/qmlprojectmanager/cmakegen/filetypes.cpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// Copyright (C) 2024 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#include "filetypes.h"
|
||||||
|
|
||||||
|
namespace QmlProjectManager {
|
||||||
|
|
||||||
|
QStringList imageFiles(const std::function<QString(QString)> &transformer)
|
||||||
|
{
|
||||||
|
static const QStringList suffixes = {
|
||||||
|
"bmp", "dae", "gif", "hdr", "ico",
|
||||||
|
"jpeg", "jpg", "ktx", "pbm", "pgm",
|
||||||
|
"png", "ppm", "svg", "svgz", "tif",
|
||||||
|
"tiff", "ttf", "webp", "xbm", "xpm"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (transformer) {
|
||||||
|
QStringList result;
|
||||||
|
for (const QString& suffix : suffixes)
|
||||||
|
result << transformer(suffix);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return suffixes;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isQmlFile(const Utils::FilePath &path)
|
||||||
|
{
|
||||||
|
const QString suffix = path.suffix();
|
||||||
|
return suffix == "qml" || suffix == "ui.qml";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAssetFile(const Utils::FilePath &path)
|
||||||
|
{
|
||||||
|
static const QStringList suffixes = {
|
||||||
|
"js", "ts", "json", "hints", "mesh", "qad", "qsb", "frag",
|
||||||
|
"frag.qsb", "vert", "vert.qsb", "mng"
|
||||||
|
};
|
||||||
|
return
|
||||||
|
suffixes.contains(path.suffix(), Qt::CaseInsensitive) ||
|
||||||
|
imageFiles().contains(path.suffix(), Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isResource(const Utils::FilePath &path)
|
||||||
|
{
|
||||||
|
auto isOtherFile = [](const Utils::FilePath &p) -> bool {
|
||||||
|
static QStringList suffixes = { "qmlproject", "conf" };
|
||||||
|
return p.fileName() == "qmldir" || suffixes.contains(p.suffix());
|
||||||
|
};
|
||||||
|
return isQmlFile(path) || isAssetFile(path) || isOtherFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace QmlProjectManager.
|
17
src/plugins/qmlprojectmanager/cmakegen/filetypes.h
Normal file
17
src/plugins/qmlprojectmanager/cmakegen/filetypes.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (C) 2024 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#include <qmlprojectmanager/qmlprojectmanager_global.h>
|
||||||
|
|
||||||
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
|
namespace QmlProjectManager {
|
||||||
|
|
||||||
|
QMLPROJECTMANAGER_EXPORT QStringList imageFiles(
|
||||||
|
const std::function<QString(QString)> &transformer = nullptr);
|
||||||
|
|
||||||
|
QMLPROJECTMANAGER_EXPORT bool isQmlFile(const Utils::FilePath &path);
|
||||||
|
QMLPROJECTMANAGER_EXPORT bool isAssetFile(const Utils::FilePath &path);
|
||||||
|
QMLPROJECTMANAGER_EXPORT bool isResource(const Utils::FilePath &path);
|
||||||
|
|
||||||
|
} // namespace QmlProjectManager.
|
@@ -51,6 +51,7 @@ QtcPlugin {
|
|||||||
"cmakewriter.cpp", "cmakewriter.h",
|
"cmakewriter.cpp", "cmakewriter.h",
|
||||||
"cmakewriterv0.cpp", "cmakewriterv0.h",
|
"cmakewriterv0.cpp", "cmakewriterv0.h",
|
||||||
"cmakewriterv1.cpp", "cmakewriterv1.h"
|
"cmakewriterv1.cpp", "cmakewriterv1.h"
|
||||||
|
"filetypes.cpp", "filetypes.h"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,17 +70,26 @@
|
|||||||
"files": [
|
"files": [
|
||||||
],
|
],
|
||||||
"filters": [
|
"filters": [
|
||||||
|
"*.bmp",
|
||||||
|
"*.dae",
|
||||||
|
"*.gif",
|
||||||
|
"*.hdr",
|
||||||
|
"*.ico",
|
||||||
"*.jpeg",
|
"*.jpeg",
|
||||||
"*.jpg",
|
"*.jpg",
|
||||||
"*.png",
|
|
||||||
"*.svg",
|
|
||||||
"*.hdr",
|
|
||||||
"*.ktx",
|
"*.ktx",
|
||||||
"*.bmp",
|
"*.pbm",
|
||||||
"*.ttf",
|
"*.pgm",
|
||||||
|
"*.png",
|
||||||
|
"*.ppm",
|
||||||
|
"*.svg",
|
||||||
|
"*.svgz",
|
||||||
|
"*.tif",
|
||||||
"*.tiff",
|
"*.tiff",
|
||||||
|
"*.ttf",
|
||||||
"*.webp",
|
"*.webp",
|
||||||
"*.gif"
|
"*.xbm",
|
||||||
|
"*.xpm"
|
||||||
],
|
],
|
||||||
"mcuProperties": {
|
"mcuProperties": {
|
||||||
},
|
},
|
||||||
@@ -93,17 +102,26 @@
|
|||||||
"files": [
|
"files": [
|
||||||
],
|
],
|
||||||
"filters": [
|
"filters": [
|
||||||
|
"*.bmp",
|
||||||
|
"*.dae",
|
||||||
|
"*.gif",
|
||||||
|
"*.hdr",
|
||||||
|
"*.ico",
|
||||||
"*.jpeg",
|
"*.jpeg",
|
||||||
"*.jpg",
|
"*.jpg",
|
||||||
"*.png",
|
|
||||||
"*.svg",
|
|
||||||
"*.hdr",
|
|
||||||
"*.ktx",
|
"*.ktx",
|
||||||
"*.bmp",
|
"*.pbm",
|
||||||
"*.ttf",
|
"*.pgm",
|
||||||
|
"*.png",
|
||||||
|
"*.ppm",
|
||||||
|
"*.svg",
|
||||||
|
"*.svgz",
|
||||||
|
"*.tif",
|
||||||
"*.tiff",
|
"*.tiff",
|
||||||
|
"*.ttf",
|
||||||
"*.webp",
|
"*.webp",
|
||||||
"*.gif"
|
"*.xbm",
|
||||||
|
"*.xpm"
|
||||||
],
|
],
|
||||||
"mcuProperties": {
|
"mcuProperties": {
|
||||||
},
|
},
|
||||||
|
@@ -40,17 +40,26 @@
|
|||||||
"files": [
|
"files": [
|
||||||
],
|
],
|
||||||
"filters": [
|
"filters": [
|
||||||
|
"*.bmp",
|
||||||
|
"*.dae",
|
||||||
|
"*.gif",
|
||||||
|
"*.hdr",
|
||||||
|
"*.ico",
|
||||||
"*.jpeg",
|
"*.jpeg",
|
||||||
"*.jpg",
|
"*.jpg",
|
||||||
"*.png",
|
|
||||||
"*.svg",
|
|
||||||
"*.hdr",
|
|
||||||
"*.ktx",
|
"*.ktx",
|
||||||
"*.bmp",
|
"*.pbm",
|
||||||
"*.ttf",
|
"*.pgm",
|
||||||
|
"*.png",
|
||||||
|
"*.ppm",
|
||||||
|
"*.svg",
|
||||||
|
"*.svgz",
|
||||||
|
"*.tif",
|
||||||
"*.tiff",
|
"*.tiff",
|
||||||
|
"*.ttf",
|
||||||
"*.webp",
|
"*.webp",
|
||||||
"*.gif"
|
"*.xbm",
|
||||||
|
"*.xpm"
|
||||||
],
|
],
|
||||||
"mcuProperties": {
|
"mcuProperties": {
|
||||||
},
|
},
|
||||||
|
@@ -70,17 +70,26 @@
|
|||||||
"files": [
|
"files": [
|
||||||
],
|
],
|
||||||
"filters": [
|
"filters": [
|
||||||
|
"*.bmp",
|
||||||
|
"*.dae",
|
||||||
|
"*.gif",
|
||||||
|
"*.hdr",
|
||||||
|
"*.ico",
|
||||||
"*.jpeg",
|
"*.jpeg",
|
||||||
"*.jpg",
|
"*.jpg",
|
||||||
"*.png",
|
|
||||||
"*.svg",
|
|
||||||
"*.hdr",
|
|
||||||
"*.ktx",
|
"*.ktx",
|
||||||
"*.bmp",
|
"*.pbm",
|
||||||
"*.ttf",
|
"*.pgm",
|
||||||
|
"*.png",
|
||||||
|
"*.ppm",
|
||||||
|
"*.svg",
|
||||||
|
"*.svgz",
|
||||||
|
"*.tif",
|
||||||
"*.tiff",
|
"*.tiff",
|
||||||
|
"*.ttf",
|
||||||
"*.webp",
|
"*.webp",
|
||||||
"*.gif"
|
"*.xbm",
|
||||||
|
"*.xpm"
|
||||||
],
|
],
|
||||||
"mcuProperties": {
|
"mcuProperties": {
|
||||||
},
|
},
|
||||||
@@ -93,17 +102,26 @@
|
|||||||
"files": [
|
"files": [
|
||||||
],
|
],
|
||||||
"filters": [
|
"filters": [
|
||||||
|
"*.bmp",
|
||||||
|
"*.dae",
|
||||||
|
"*.gif",
|
||||||
|
"*.hdr",
|
||||||
|
"*.ico",
|
||||||
"*.jpeg",
|
"*.jpeg",
|
||||||
"*.jpg",
|
"*.jpg",
|
||||||
"*.png",
|
|
||||||
"*.svg",
|
|
||||||
"*.hdr",
|
|
||||||
"*.ktx",
|
"*.ktx",
|
||||||
"*.bmp",
|
"*.pbm",
|
||||||
"*.ttf",
|
"*.pgm",
|
||||||
|
"*.png",
|
||||||
|
"*.ppm",
|
||||||
|
"*.svg",
|
||||||
|
"*.svgz",
|
||||||
|
"*.tif",
|
||||||
"*.tiff",
|
"*.tiff",
|
||||||
|
"*.ttf",
|
||||||
"*.webp",
|
"*.webp",
|
||||||
"*.gif"
|
"*.xbm",
|
||||||
|
"*.xpm"
|
||||||
],
|
],
|
||||||
"mcuProperties": {
|
"mcuProperties": {
|
||||||
},
|
},
|
||||||
|
@@ -43,17 +43,26 @@
|
|||||||
"files": [
|
"files": [
|
||||||
],
|
],
|
||||||
"filters": [
|
"filters": [
|
||||||
|
"*.bmp",
|
||||||
|
"*.dae",
|
||||||
|
"*.gif",
|
||||||
|
"*.hdr",
|
||||||
|
"*.ico",
|
||||||
"*.jpeg",
|
"*.jpeg",
|
||||||
"*.jpg",
|
"*.jpg",
|
||||||
"*.png",
|
|
||||||
"*.svg",
|
|
||||||
"*.hdr",
|
|
||||||
"*.ktx",
|
"*.ktx",
|
||||||
"*.bmp",
|
"*.pbm",
|
||||||
"*.ttf",
|
"*.pgm",
|
||||||
|
"*.png",
|
||||||
|
"*.ppm",
|
||||||
|
"*.svg",
|
||||||
|
"*.svgz",
|
||||||
|
"*.tif",
|
||||||
"*.tiff",
|
"*.tiff",
|
||||||
|
"*.ttf",
|
||||||
"*.webp",
|
"*.webp",
|
||||||
"*.gif"
|
"*.xbm",
|
||||||
|
"*.xpm"
|
||||||
],
|
],
|
||||||
"mcuProperties": {
|
"mcuProperties": {
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user