forked from qt-creator/qt-creator
QML Project Manager: Add FontFiles category
Added a dedicated FontFiles category in qmlproject files, analogously to ImageFiles, JavaScriptFiles, etc. Updated tests and templates accordingly. User-defined filters are no longer appended with the default filters. Default filters will still be used if there are no user-defined ones. Fixes: QDS-15035 Change-Id: Iad91f4b04f2e831a866be61ecd775f71c9f6e313 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -37,7 +37,7 @@ Project {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Files {
|
||||
FontFiles {
|
||||
filter: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ Project {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Files {
|
||||
FontFiles {
|
||||
filter: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,27 @@ namespace QmlProjectManager::Converters {
|
||||
|
||||
const static QStringList qmlFilesFilter{QStringLiteral("*.qml")};
|
||||
const static QStringList javaScriptFilesFilter{QStringLiteral("*.js"), QStringLiteral("*.ts")};
|
||||
const static QStringList fontFilesFilter{
|
||||
QStringLiteral("*.afm"),
|
||||
QStringLiteral("*.bdf"),
|
||||
QStringLiteral("*.ccc"),
|
||||
QStringLiteral("*.cff"),
|
||||
QStringLiteral("*.fmp"),
|
||||
QStringLiteral("*.fnt"),
|
||||
QStringLiteral("*.otc"),
|
||||
QStringLiteral("*.otf"),
|
||||
QStringLiteral("*.pcf"),
|
||||
QStringLiteral("*.pfa"),
|
||||
QStringLiteral("*.pfb"),
|
||||
QStringLiteral("*.pfm"),
|
||||
QStringLiteral("*.pfr"),
|
||||
QStringLiteral("*.ttc"),
|
||||
QStringLiteral("*.ttcf"),
|
||||
QStringLiteral("*.tte"),
|
||||
QStringLiteral("*.ttf"),
|
||||
QStringLiteral("*.woff"),
|
||||
QStringLiteral("*.woff2"),
|
||||
};
|
||||
|
||||
const QStringList imageFilesFilter() {
|
||||
return imageFiles([](const QString& suffix) { return "*." + suffix; });
|
||||
@@ -466,6 +487,9 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
||||
// if directory is empty, then the files are prefixed with the project directory
|
||||
if (childNodeFiles.empty()) {
|
||||
auto inserter = [&childNodeFilters](const QStringList &filterSource) {
|
||||
if (!childNodeFilters.empty())
|
||||
return;
|
||||
|
||||
std::for_each(filterSource.begin(),
|
||||
filterSource.end(),
|
||||
[&childNodeFilters](const auto &value) {
|
||||
@@ -475,7 +499,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
||||
});
|
||||
};
|
||||
|
||||
// Those 3 file groups are the special ones
|
||||
// Those 4 file groups are the special ones
|
||||
// that have a default set of filters.
|
||||
// The default filters are written to the
|
||||
// qmlproject file after conversion
|
||||
@@ -485,6 +509,8 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
||||
inserter(javaScriptFilesFilter);
|
||||
} else if (childNodeName == "imagefiles") {
|
||||
inserter(imageFilesFilter());
|
||||
} else if (childNodeName == "fontfiles") {
|
||||
inserter(fontFilesFilter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -69,7 +69,8 @@ INSTANTIATE_TEST_SUITE_P(QmlProjectItem,
|
||||
QString("test-set-2"),
|
||||
QString("test-set-3"),
|
||||
QString("test-set-mcu-1"),
|
||||
QString("test-set-mcu-2")));
|
||||
QString("test-set-mcu-2"),
|
||||
QString("test-set-font-files")));
|
||||
|
||||
TEST_P(QmlProjectConverter, qml_project_to_json)
|
||||
{
|
||||
@@ -83,7 +84,7 @@ TEST_P(QmlProjectConverter, qml_project_to_json)
|
||||
|
||||
// THEN
|
||||
QString convertedContent{QString::fromLatin1(QJsonDocument(jsonObject).toJson())};
|
||||
ASSERT_THAT(convertedContent, Eq(targetContent));
|
||||
ASSERT_EQ(convertedContent, targetContent);
|
||||
}
|
||||
|
||||
TEST_P(QmlProjectConverter, json_to_qml_project)
|
||||
@@ -98,7 +99,7 @@ TEST_P(QmlProjectConverter, json_to_qml_project)
|
||||
|
||||
// THEN
|
||||
QString convertedContent = QmlProjectManager::Converters::jsonToQmlProject(jsonObject);
|
||||
ASSERT_THAT(convertedContent, Eq(targetContent));
|
||||
ASSERT_EQ(convertedContent, targetContent);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -0,0 +1,47 @@
|
||||
// prop: json-converted
|
||||
// prop: auto-generated
|
||||
|
||||
import QmlProject
|
||||
|
||||
Project {
|
||||
mainFile: "content/App.qml"
|
||||
mainUiFile: "content/Screen01.ui.qml"
|
||||
widgetApp: false
|
||||
|
||||
qt6Project: false
|
||||
qtForMCUs: false
|
||||
|
||||
FontFiles {
|
||||
filter: "*.otf"
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
directory: "fonts1"
|
||||
filter: "*.otf;*.ttf"
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
directory: "fonts2"
|
||||
files: [
|
||||
"test1.ttf",
|
||||
"test2.ttf"
|
||||
]
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
filter: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
directory: "fonts3"
|
||||
filter: "*.otf;*.ttf"
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
directory: "fonts3"
|
||||
files: [
|
||||
"test3.ttf",
|
||||
"test4.ttf"
|
||||
]
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
import QmlProject
|
||||
|
||||
Project {
|
||||
QDS.mainFile: "content/App.qml"
|
||||
QDS.mainUiFile: "content/Screen01.ui.qml"
|
||||
|
||||
QDS.FontFiles {
|
||||
filter: "*.otf"
|
||||
}
|
||||
|
||||
QDS.FontFiles {
|
||||
directory: "fonts1"
|
||||
filter: "*.otf;*.ttf"
|
||||
}
|
||||
|
||||
QDS.FontFiles {
|
||||
directory: "fonts2"
|
||||
files: [
|
||||
"test1.ttf",
|
||||
"test2.ttf"
|
||||
]
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
filter: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
directory: "fonts3"
|
||||
filter: "*.otf;*.ttf"
|
||||
}
|
||||
|
||||
FontFiles {
|
||||
directory: "fonts3"
|
||||
files: [
|
||||
"test3.ttf",
|
||||
"test4.ttf"
|
||||
]
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"deployment": {
|
||||
},
|
||||
"fileGroups": [
|
||||
{
|
||||
"directory": "",
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.otf"
|
||||
],
|
||||
"mcuProperties": {
|
||||
},
|
||||
"otherProperties": {
|
||||
},
|
||||
"type": "Font"
|
||||
},
|
||||
{
|
||||
"directory": "fonts1",
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.otf",
|
||||
"*.ttf"
|
||||
],
|
||||
"mcuProperties": {
|
||||
},
|
||||
"otherProperties": {
|
||||
},
|
||||
"type": "Font"
|
||||
},
|
||||
{
|
||||
"directory": "fonts2",
|
||||
"files": [
|
||||
"test1.ttf",
|
||||
"test2.ttf"
|
||||
],
|
||||
"filters": [
|
||||
],
|
||||
"mcuProperties": {
|
||||
},
|
||||
"otherProperties": {
|
||||
},
|
||||
"type": "Font"
|
||||
},
|
||||
{
|
||||
"directory": "",
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.ttf",
|
||||
"*.otf"
|
||||
],
|
||||
"mcuProperties": {
|
||||
},
|
||||
"otherProperties": {
|
||||
},
|
||||
"type": "Font"
|
||||
},
|
||||
{
|
||||
"directory": "fonts3",
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.otf",
|
||||
"*.ttf"
|
||||
],
|
||||
"mcuProperties": {
|
||||
},
|
||||
"otherProperties": {
|
||||
},
|
||||
"type": "Font"
|
||||
},
|
||||
{
|
||||
"directory": "fonts3",
|
||||
"files": [
|
||||
"test3.ttf",
|
||||
"test4.ttf"
|
||||
],
|
||||
"filters": [
|
||||
],
|
||||
"mcuProperties": {
|
||||
},
|
||||
"otherProperties": {
|
||||
},
|
||||
"type": "Font"
|
||||
}
|
||||
],
|
||||
"fileVersion": 1,
|
||||
"language": {
|
||||
},
|
||||
"mcu": {
|
||||
"config": {
|
||||
},
|
||||
"enabled": false,
|
||||
"module": {
|
||||
}
|
||||
},
|
||||
"otherProperties": {
|
||||
},
|
||||
"qmlprojectDependencies": [
|
||||
],
|
||||
"runConfig": {
|
||||
"fileSelectors": [
|
||||
],
|
||||
"mainFile": "content/App.qml",
|
||||
"mainUiFile": "content/Screen01.ui.qml"
|
||||
},
|
||||
"versions": {
|
||||
"qt": "5"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user