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
|
||||
CONDITION TARGET QmlDesigner
|
||||
DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml
|
||||
DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml Qt5::QuickPrivate
|
||||
PUBLIC_INCLUDES assetexporterplugin
|
||||
SOURCES
|
||||
assetexporterplugin/assetexportdialog.h assetexporterplugin/assetexportdialog.cpp assetexporterplugin/assetexportdialog.ui
|
||||
|
@@ -1,4 +1,5 @@
|
||||
QT *= qml quick core widgets
|
||||
QT += quick-private
|
||||
|
||||
VPATH += $$PWD
|
||||
|
||||
|
@@ -10,6 +10,12 @@ QtcProduct {
|
||||
Depends { name: "ProjectExplorer" }
|
||||
Depends { name: "QmlDesigner" }
|
||||
Depends { name: "Utils" }
|
||||
Depends {
|
||||
name: "Qt"
|
||||
submodules: [
|
||||
"quick-private"
|
||||
]
|
||||
}
|
||||
|
||||
cpp.includePaths: base.concat([
|
||||
"./",
|
||||
|
@@ -28,7 +28,11 @@
|
||||
|
||||
#include <QColor>
|
||||
#include <QFontInfo>
|
||||
#include <QFontMetricsF>
|
||||
#include <QHash>
|
||||
#include <QtMath>
|
||||
|
||||
#include <private/qquicktext_p.h>
|
||||
|
||||
namespace {
|
||||
const QHash<QString, QString> AlignMapping{
|
||||
@@ -86,6 +90,14 @@ QJsonObject TextNodeParser::json(Component &component) const
|
||||
|
||||
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();
|
||||
metadata.insert(TextDetailsTag, textDetails);
|
||||
jsonObject.insert(MetadataTag, metadata);
|
||||
|
Reference in New Issue
Block a user