Qt5's QFont::fromString() isn't compatible with Qt6's QFont::toString().
Cover more cases.
This commit is contained in:
parent
1e2f1f7708
commit
633bd18899
|
@ -871,9 +871,7 @@ auto VPLayoutFileReader::ReadLabelLines() -> VTextManager
|
||||||
QVector<TextLine> lines;
|
QVector<TextLine> lines;
|
||||||
|
|
||||||
QXmlStreamAttributes attribs = attributes();
|
QXmlStreamAttributes attribs = attributes();
|
||||||
QFont f;
|
text.SetFont(FontFromString(ReadAttributeEmptyString(attribs, ML::AttrFont)));
|
||||||
f.fromString(ReadAttributeEmptyString(attribs, ML::AttrFont));
|
|
||||||
text.SetFont(f);
|
|
||||||
|
|
||||||
QStringList svgFontData = ReadAttributeEmptyString(attribs, ML::AttrSVGFont).split(',');
|
QStringList svgFontData = ReadAttributeEmptyString(attribs, ML::AttrSVGFont).split(',');
|
||||||
if (!svgFontData.isEmpty())
|
if (!svgFontData.isEmpty())
|
||||||
|
|
|
@ -104,7 +104,7 @@ auto VWatermark::GetWatermark() const -> VWatermarkData
|
||||||
data.showText = GetParametrBool(text, AttrShow, trueStr);
|
data.showText = GetParametrBool(text, AttrShow, trueStr);
|
||||||
data.text = GetParametrEmptyString(text, AttrText);
|
data.text = GetParametrEmptyString(text, AttrText);
|
||||||
data.textRotation = GetParametrInt(text, AttrRotation, QChar('0'));
|
data.textRotation = GetParametrInt(text, AttrRotation, QChar('0'));
|
||||||
data.font.fromString(GetParametrEmptyString(text, AttrFont));
|
data.font = FontFromString(GetParametrEmptyString(text, AttrFont));
|
||||||
QColor color(GetParametrString(text, AttrColor, QColor(Qt::black).name()));
|
QColor color(GetParametrString(text, AttrColor, QColor(Qt::black).name()));
|
||||||
if (not color.isValid())
|
if (not color.isValid())
|
||||||
{
|
{
|
||||||
|
|
|
@ -429,4 +429,31 @@ inline auto Front(const QString &str) -> QChar
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline auto FontFromString(const QString &descrip) -> QFont
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
|
||||||
|
if (!descrip.isEmpty())
|
||||||
|
{
|
||||||
|
// Qt 6's QFont::toString returns a value with 17 fields, e.g.
|
||||||
|
// Ubuntu,11,-1,5,400,0,0,0,0,0,0,0,0,0,0,1
|
||||||
|
// Qt 5's QFont::fromString expects a value with 11 fields, e.g.
|
||||||
|
// Ubuntu,10,-1,5,50,0,0,0,0,0
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
const auto l = descrip.split(QLatin1Char(','));
|
||||||
|
// Qt5's QFont::fromString() isn't compatible with Qt6's QFont::toString().
|
||||||
|
// If we were built with Qt5, don't try to process a font preference that
|
||||||
|
// was created by Qt6.
|
||||||
|
if (l.count() <= 11)
|
||||||
|
{
|
||||||
|
font.fromString(descrip);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
font.fromString(descrip);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // COMPATIBILITY_H
|
#endif // COMPATIBILITY_H
|
||||||
|
|
|
@ -1191,30 +1191,7 @@ auto VCommonSettings::GetDefaultSeamAllowance() -> double
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VCommonSettings::GetLabelFont() const -> QFont
|
auto VCommonSettings::GetLabelFont() const -> QFont
|
||||||
{
|
{
|
||||||
QString fontStr = value(*settingPatternLabelFont, QApplication::font().toString()).toString();
|
return FontFromString(value(*settingPatternLabelFont, QApplication::font().toString()).toString());
|
||||||
|
|
||||||
QFont font;
|
|
||||||
|
|
||||||
if (!fontStr.isEmpty())
|
|
||||||
{
|
|
||||||
// Qt 6's QFont::toString returns a value with 17 fields, e.g.
|
|
||||||
// Ubuntu,11,-1,5,400,0,0,0,0,0,0,0,0,0,0,1
|
|
||||||
// Qt 5's QFont::fromString expects a value with 11 fields, e.g.
|
|
||||||
// Ubuntu,10,-1,5,50,0,0,0,0,0
|
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
|
||||||
const auto l = fontStr.split(QLatin1Char(','));
|
|
||||||
// Qt5's QFont::fromString() isn't compatible with Qt6's QFont::toString().
|
|
||||||
// If we were built with Qt5, don't try to process a font preference that
|
|
||||||
// was created by Qt6.
|
|
||||||
if (l.count() <= 11)
|
|
||||||
{
|
|
||||||
font.fromString(fontStr);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
font.fromString(fontStr);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return font;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user