forked from qt-creator/qt-creator
AssetExport: Export line height value in pixels
Task-number: QDS-2597 Change-Id: I96db25b08db55c3107931ab31e4b9342be92e644 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -42,7 +42,7 @@ add_qtc_plugin(QmlDesigner
|
|||||||
|
|
||||||
add_qtc_plugin(assetexporterplugin
|
add_qtc_plugin(assetexporterplugin
|
||||||
CONDITION TARGET QmlDesigner
|
CONDITION TARGET QmlDesigner
|
||||||
DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml
|
DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml Qt5::QuickPrivate
|
||||||
PUBLIC_INCLUDES assetexporterplugin
|
PUBLIC_INCLUDES assetexporterplugin
|
||||||
SOURCES
|
SOURCES
|
||||||
assetexporterplugin/assetexportdialog.h assetexporterplugin/assetexportdialog.cpp assetexporterplugin/assetexportdialog.ui
|
assetexporterplugin/assetexportdialog.h assetexporterplugin/assetexportdialog.cpp assetexporterplugin/assetexportdialog.ui
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
QT *= qml quick core widgets
|
QT *= qml quick core widgets
|
||||||
|
QT += quick-private
|
||||||
|
|
||||||
VPATH += $$PWD
|
VPATH += $$PWD
|
||||||
|
|
||||||
|
@@ -10,6 +10,12 @@ QtcProduct {
|
|||||||
Depends { name: "ProjectExplorer" }
|
Depends { name: "ProjectExplorer" }
|
||||||
Depends { name: "QmlDesigner" }
|
Depends { name: "QmlDesigner" }
|
||||||
Depends { name: "Utils" }
|
Depends { name: "Utils" }
|
||||||
|
Depends {
|
||||||
|
name: "Qt"
|
||||||
|
submodules: [
|
||||||
|
"quick-private"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
cpp.includePaths: base.concat([
|
cpp.includePaths: base.concat([
|
||||||
"./",
|
"./",
|
||||||
|
@@ -28,7 +28,11 @@
|
|||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QFontInfo>
|
#include <QFontInfo>
|
||||||
|
#include <QFontMetricsF>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
|
#include <private/qquicktext_p.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QHash<QString, QString> AlignMapping{
|
const QHash<QString, QString> AlignMapping{
|
||||||
@@ -86,6 +90,14 @@ QJsonObject TextNodeParser::json(Component &component) const
|
|||||||
|
|
||||||
textDetails.insert(IsMultilineTag, propertyValue("wrapMode").toString().compare("NoWrap") != 0);
|
textDetails.insert(IsMultilineTag, propertyValue("wrapMode").toString().compare("NoWrap") != 0);
|
||||||
|
|
||||||
|
// Calculate line height in pixels
|
||||||
|
QFontMetricsF fm(font);
|
||||||
|
auto lineHeightMode = propertyValue("lineHeightMode").value<QQuickText::LineHeightMode>();
|
||||||
|
double lineHeight = propertyValue("lineHeight").toDouble();
|
||||||
|
qreal lineHeightPx = (lineHeightMode == QQuickText::FixedHeight) ?
|
||||||
|
lineHeight : qCeil(fm.height()) * lineHeight;
|
||||||
|
textDetails.insert(LineHeightTag, lineHeightPx);
|
||||||
|
|
||||||
QJsonObject metadata = jsonObject.value(MetadataTag).toObject();
|
QJsonObject metadata = jsonObject.value(MetadataTag).toObject();
|
||||||
metadata.insert(TextDetailsTag, textDetails);
|
metadata.insert(TextDetailsTag, textDetails);
|
||||||
jsonObject.insert(MetadataTag, metadata);
|
jsonObject.insert(MetadataTag, metadata);
|
||||||
|
Reference in New Issue
Block a user