diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-05-13 15:31:37 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-08-10 08:55:06 +0000 |
commit | e01bea8999d2f58add58874bd3e6792f509b131b (patch) | |
tree | 7acfa6aff3116b0c986bc1654a9a4c39b2db3f51 /src | |
parent | c1667cd7277cd48e26a97ea5d10d6bcab0ef576e (diff) |
Font matching by font stylename
Some fonts may have styles that does not directly match to QFont
properties. To support those QFontDatabase supports matching by style
name. This patch exposes that to QML.
Change-Id: I9896f2e3d9f6b56fb51f5694b018b456bcd05ed6
Task-number: QTBUG-30851
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/qtquick2/plugins.qmltypes | 1 | ||||
-rw-r--r-- | src/quick/items/qquicktext.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 11 | ||||
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 10 | ||||
-rw-r--r-- | src/quick/util/qquickglobal.cpp | 5 | ||||
-rw-r--r-- | src/quick/util/qquickvaluetypes.cpp | 10 | ||||
-rw-r--r-- | src/quick/util/qquickvaluetypes_p.h | 4 |
7 files changed, 51 insertions, 0 deletions
diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes index d98e9e6981..050d0f78cd 100644 --- a/src/imports/qtquick2/plugins.qmltypes +++ b/src/imports/qtquick2/plugins.qmltypes @@ -1728,6 +1728,7 @@ Module { } } Property { name: "family"; type: "string" } + Property { name: "styleName"; type: "string" } Property { name: "bold"; type: "bool" } Property { name: "weight"; type: "FontWeight" } Property { name: "italic"; type: "bool" } diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 2475d19c8d..a91e6b47c2 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1444,6 +1444,16 @@ QQuickText::~QQuickText() */ /*! + \qmlproperty string QtQuick::Text::font.styleName + \since 5.6 + + Sets the style name of the font. + + The style name is case insensitive. If set, the font will be matched against style name instead + of the font properties \l weight, \l bold and \l italic. +*/ + +/*! \qmlproperty bool QtQuick::Text::font.bold Sets whether the font weight is bold. diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 2887dad8ce..cf7e91ffec 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -206,6 +206,17 @@ QString QQuickTextEdit::text() const */ /*! + \qmlproperty string QtQuick::TextEdit::font.styleName + \since 5.6 + + Sets the style name of the font. + + The style name is case insensitive. If set, the font will be matched against style name instead + of the font properties \l weight, \l bold and \l italic. +*/ + + +/*! \qmlproperty bool QtQuick::TextEdit::font.bold Sets whether the font weight is bold. diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index b458f80ce7..31549451ab 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -229,6 +229,16 @@ QString QQuickTextInputPrivate::realText() const */ /*! + \qmlproperty string QtQuick::TextInput::font.styleName + \since 5.6 + + Sets the style name of the font. + + The style name is case insensitive. If set, the font will be matched against style name instead + of the font properties \l weight, \l bold and \l italic. +*/ + +/*! \qmlproperty bool QtQuick::TextInput::font.bold Sets whether the font weight is bold. diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 6aa7bedc5b..0680a49d6d 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -285,6 +285,7 @@ public: QV4::ScopedValue vbold(scope, obj->get((s = v4->newString(QStringLiteral("bold"))))); QV4::ScopedValue vcap(scope, obj->get((s = v4->newString(QStringLiteral("capitalization"))))); QV4::ScopedValue vfam(scope, obj->get((s = v4->newString(QStringLiteral("family"))))); + QV4::ScopedValue vstyle(scope, obj->get((s = v4->newString(QStringLiteral("styleName"))))); QV4::ScopedValue vital(scope, obj->get((s = v4->newString(QStringLiteral("italic"))))); QV4::ScopedValue vlspac(scope, obj->get((s = v4->newString(QStringLiteral("letterSpacing"))))); QV4::ScopedValue vpixsz(scope, obj->get((s = v4->newString(QStringLiteral("pixelSize"))))); @@ -307,6 +308,10 @@ public: retn.setFamily(vfam->toQString()); if (ok) *ok = true; } + if (vstyle->isString()) { + retn.setStyleName(vstyle->toQString()); + if (ok) *ok = true; + } if (vital->isBoolean()) { retn.setItalic(vital->booleanValue()); if (ok) *ok = true; diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp index fef6dfd1d0..1f0d54e4e7 100644 --- a/src/quick/util/qquickvaluetypes.cpp +++ b/src/quick/util/qquickvaluetypes.cpp @@ -533,6 +533,16 @@ void QQuickFontValueType::setFamily(const QString &family) v.setFamily(family); } +QString QQuickFontValueType::styleName() const +{ + return v.styleName(); +} + +void QQuickFontValueType::setStyleName(const QString &style) +{ + v.setStyleName(style); +} + bool QQuickFontValueType::bold() const { return v.bold(); diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h index 1436d8e310..7a2e8888b7 100644 --- a/src/quick/util/qquickvaluetypes_p.h +++ b/src/quick/util/qquickvaluetypes_p.h @@ -268,6 +268,7 @@ class QQuickFontValueType Q_GADGET Q_PROPERTY(QString family READ family WRITE setFamily FINAL) + Q_PROPERTY(QString styleName READ styleName WRITE setStyleName FINAL) Q_PROPERTY(bool bold READ bold WRITE setBold FINAL) Q_PROPERTY(FontWeight weight READ weight WRITE setWeight FINAL) Q_PROPERTY(bool italic READ italic WRITE setItalic FINAL) @@ -303,6 +304,9 @@ public: QString family() const; void setFamily(const QString &); + QString styleName() const; + void setStyleName(const QString &); + bool bold() const; void setBold(bool b); |