diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-14 13:25:19 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-15 22:12:01 +0000 |
commit | 495ef4fbb9766a766dcc6390636f785bf7bb09d9 (patch) | |
tree | 09d63b03bdc1670ac23547bb286b4cce95d918cb | |
parent | 54a2a35f17d5e5d1793af63b76993a583e10ab41 (diff) |
Store explicit and resolved font separately
Change-Id: I80bd45244077cd75f24c4ca1af6485f4c6a23b39
Task-number: QTBUG-50984
Task-number: QTBUG-51696
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/templates/qquickcontrol.cpp | 74 | ||||
-rw-r--r-- | src/templates/qquickcontrol_p_p.h | 6 | ||||
-rw-r--r-- | src/templates/qquicklabel.cpp | 38 | ||||
-rw-r--r-- | src/templates/qquicklabel_p_p.h | 2 | ||||
-rw-r--r-- | src/templates/qquicktextarea.cpp | 38 | ||||
-rw-r--r-- | src/templates/qquicktextarea_p_p.h | 2 | ||||
-rw-r--r-- | src/templates/qquicktextfield.cpp | 38 | ||||
-rw-r--r-- | src/templates/qquicktextfield_p_p.h | 2 | ||||
-rw-r--r-- | tests/auto/material/data/tst_material.qml | 76 | ||||
-rw-r--r-- | tests/auto/universal/data/tst_universal.qml | 44 |
10 files changed, 181 insertions, 139 deletions
diff --git a/src/templates/qquickcontrol.cpp b/src/templates/qquickcontrol.cpp index 49c45e24..824f7053 100644 --- a/src/templates/qquickcontrol.cpp +++ b/src/templates/qquickcontrol.cpp @@ -219,33 +219,24 @@ void QQuickControl::accessibilityActiveChanged(bool active) */ QFont QQuickControlPrivate::naturalControlFont(const QQuickItem *q) { - QFont naturalFont = themeFont(QPlatformTheme::SystemFont); - if (const QQuickControl *qc = qobject_cast<const QQuickControl *>(q)) { - naturalFont = qc->defaultFont(); - } else if (const QQuickLabel *label = qobject_cast<const QQuickLabel *>(q)) { - Q_UNUSED(label); - naturalFont = themeFont(QPlatformTheme::LabelFont); - } - QQuickItem *p = q->parentItem(); - bool found = false; while (p) { - if (QQuickControl *qc = qobject_cast<QQuickControl *>(p)) { - naturalFont = qc->font(); - found = true; - break; - } + if (QQuickControl *control = qobject_cast<QQuickControl *>(p)) + return control->font(); + else if (QQuickLabel *label = qobject_cast<QQuickLabel *>(p)) + return label->font(); + else if (QQuickTextField *textField = qobject_cast<QQuickTextField *>(p)) + return textField->font(); + else if (QQuickTextArea *textArea = qobject_cast<QQuickTextArea *>(p)) + return textArea->font(); p = p->parentItem(); } - if (!found) { - if (QQuickApplicationWindow *w = qobject_cast<QQuickApplicationWindow *>(q->window())) - naturalFont = w->font(); - } + if (QQuickApplicationWindow *window = qobject_cast<QQuickApplicationWindow *>(q->window())) + return window->font(); - naturalFont.resolve(0); - return naturalFont; + return themeFont(QPlatformTheme::SystemFont); } QFont QQuickControlPrivate::themeFont(QPlatformTheme::Font type) @@ -272,9 +263,19 @@ QFont QQuickControlPrivate::themeFont(QPlatformTheme::Font type) */ void QQuickControlPrivate::resolveFont() { - Q_Q(const QQuickControl); - QFont naturalFont = QQuickControlPrivate::naturalControlFont(q); - QFont resolvedFont = font.resolve(naturalFont); + Q_Q(QQuickControl); + inheritFont(naturalControlFont(q)); +} + +void QQuickControlPrivate::inheritFont(const QFont &f) +{ + Q_Q(QQuickControl); + QFont parentFont = font.resolve(f); + parentFont.resolve(font.resolve() | f.resolve()); + + const QFont defaultFont = q->defaultFont(); + const QFont resolvedFont = parentFont.resolve(defaultFont); + setFont_helper(resolvedFont); } @@ -286,8 +287,8 @@ void QQuickControlPrivate::resolveFont() void QQuickControlPrivate::updateFont(const QFont &f) { Q_Q(QQuickControl); - const bool changed = font != f; - font = f; + const bool changed = resolvedFont != f; + resolvedFont = f; QQuickControlPrivate::updateFontRecur(q, f); @@ -299,13 +300,13 @@ void QQuickControlPrivate::updateFontRecur(QQuickItem *item, const QFont &f) { foreach (QQuickItem *child, item->childItems()) { if (QQuickControl *control = qobject_cast<QQuickControl *>(child)) - QQuickControlPrivate::get(control)->resolveFont(); + QQuickControlPrivate::get(control)->inheritFont(f); else if (QQuickLabel *label = qobject_cast<QQuickLabel *>(child)) - QQuickLabelPrivate::get(label)->resolveFont(); + QQuickLabelPrivate::get(label)->inheritFont(f); else if (QQuickTextArea *textArea = qobject_cast<QQuickTextArea *>(child)) - QQuickTextAreaPrivate::get(textArea)->resolveFont(); + QQuickTextAreaPrivate::get(textArea)->inheritFont(f); else if (QQuickTextField *textField = qobject_cast<QQuickTextField *>(child)) - QQuickTextFieldPrivate::get(textField)->resolveFont(); + QQuickTextFieldPrivate::get(textField)->inheritFont(f); else QQuickControlPrivate::updateFontRecur(child, f); } @@ -399,22 +400,17 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem:: QFont QQuickControl::font() const { Q_D(const QQuickControl); - return d->font; + return d->resolvedFont; } -void QQuickControl::setFont(const QFont &f) +void QQuickControl::setFont(const QFont &font) { Q_D(QQuickControl); - if (d->font.resolve() == f.resolve() && d->font == f) + if (d->font.resolve() == font.resolve() && d->font == font) return; - // Determine which font is inherited from this control's ancestors and - // QGuiApplication::font, resolve this against \a font (attributes from the - // inherited font are copied over). Then propagate this font to this - // control's children. - QFont naturalFont = QQuickControlPrivate::naturalControlFont(this); - QFont resolvedFont = f.resolve(naturalFont); - d->setFont_helper(resolvedFont); + d->font = font; + d->resolveFont(); } void QQuickControl::resetFont() diff --git a/src/templates/qquickcontrol_p_p.h b/src/templates/qquickcontrol_p_p.h index d7821ec7..cd7a9fb9 100644 --- a/src/templates/qquickcontrol_p_p.h +++ b/src/templates/qquickcontrol_p_p.h @@ -95,18 +95,22 @@ public: void updateFont(const QFont &); static void updateFontRecur(QQuickItem *item, const QFont &); inline void setFont_helper(const QFont &f) { - if (font.resolve() == f.resolve() && font == f) + if (resolvedFont.resolve() == f.resolve() && resolvedFont == f) return; updateFont(f); } void resolveFont(); + void inheritFont(const QFont &f); static QFont naturalControlFont(const QQuickItem *); static QFont themeFont(QPlatformTheme::Font type); + void updateLocale(const QLocale &l, bool e); static void updateLocaleRecur(QQuickItem *item, const QLocale &l); static QLocale calcLocale(QQuickItem *); + // TODO: QLazilyAllocated<ExtraData> QFont font; + QFont resolvedFont; bool hasTopPadding; bool hasLeftPadding; bool hasRightPadding; diff --git a/src/templates/qquicklabel.cpp b/src/templates/qquicklabel.cpp index 7de520d9..4eec06b3 100644 --- a/src/templates/qquicklabel.cpp +++ b/src/templates/qquicklabel.cpp @@ -108,15 +108,20 @@ QQuickLabelPrivate::~QQuickLabelPrivate() void QQuickLabelPrivate::resolveFont() { Q_Q(QQuickLabel); - QFont naturalFont = QQuickControlPrivate::naturalControlFont(q); - QFont resolvedFont = sourceFont.resolve(naturalFont); - if (sourceFont.resolve() == resolvedFont.resolve() && sourceFont == resolvedFont) - return; + inheritFont(QQuickControlPrivate::naturalControlFont(q)); +} + +void QQuickLabelPrivate::inheritFont(const QFont &f) +{ + Q_Q(QQuickLabel); + QFont parentFont = font.resolve(f); + parentFont.resolve(font.resolve() | f.resolve()); - const bool changed = sourceFont != resolvedFont; + const QFont defaultFont = QQuickControlPrivate::themeFont(QPlatformTheme::LabelFont); + const QFont resolvedFont = parentFont.resolve(defaultFont); + const bool changed = resolvedFont != sourceFont; q->QQuickText::setFont(resolvedFont); - if (changed) emit q->fontChanged(); } @@ -161,24 +166,11 @@ QFont QQuickLabel::font() const void QQuickLabel::setFont(const QFont &font) { Q_D(QQuickLabel); - if (d->sourceFont.resolve() == font.resolve() && d->sourceFont == font) + if (d->font.resolve() == font.resolve() && d->font == font) return; - // Determine which font is inherited from this control's ancestors and - // QGuiApplication::font, resolve this against \a font (attributes from the - // inherited font are copied over). Then propagate this font to this - // control's children. - QFont naturalFont = QQuickControlPrivate::naturalControlFont(this); - QFont resolvedFont = font.resolve(naturalFont); - if (d->sourceFont.resolve() == resolvedFont.resolve() && d->sourceFont == resolvedFont) - return; - - const bool changed = d->sourceFont != resolvedFont; - - QQuickText::setFont(font); - - if (changed) - emit fontChanged(); + d->font = font; + d->resolveFont(); } /*! @@ -224,7 +216,7 @@ void QQuickLabel::itemChange(QQuickItem::ItemChange change, const QQuickItem::It { Q_D(QQuickLabel); QQuickText::itemChange(change, value); - if (change == ItemParentHasChanged && isComponentComplete()) + if (change == ItemParentHasChanged && value.item) d->resolveFont(); } diff --git a/src/templates/qquicklabel_p_p.h b/src/templates/qquicklabel_p_p.h index a4e9f4e5..94d74132 100644 --- a/src/templates/qquicklabel_p_p.h +++ b/src/templates/qquicklabel_p_p.h @@ -74,6 +74,7 @@ public: void resizeBackground(); void resolveFont(); + void inheritFont(const QFont &f); void _q_textChanged(const QString &text); @@ -82,6 +83,7 @@ public: QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE; #endif + QFont font; QQuickItem *background; QQuickAccessibleAttached *accessibleAttached; }; diff --git a/src/templates/qquicktextarea.cpp b/src/templates/qquicktextarea.cpp index 97eff350..fce74338 100644 --- a/src/templates/qquicktextarea.cpp +++ b/src/templates/qquicktextarea.cpp @@ -161,15 +161,20 @@ QQuickTextArea::~QQuickTextArea() void QQuickTextAreaPrivate::resolveFont() { Q_Q(QQuickTextArea); - QFont naturalFont = QQuickControlPrivate::naturalControlFont(q); - QFont resolvedFont = sourceFont.resolve(naturalFont); - if (sourceFont.resolve() == resolvedFont.resolve() && sourceFont == resolvedFont) - return; + inheritFont(QQuickControlPrivate::naturalControlFont(q)); +} + +void QQuickTextAreaPrivate::inheritFont(const QFont &f) +{ + Q_Q(QQuickTextArea); + QFont parentFont = font.resolve(f); + parentFont.resolve(font.resolve() | f.resolve()); - const bool changed = sourceFont != resolvedFont; + const QFont defaultFont = QQuickControlPrivate::themeFont(QPlatformTheme::SystemFont); + const QFont resolvedFont = parentFont.resolve(defaultFont); + const bool changed = resolvedFont != sourceFont; q->QQuickTextEdit::setFont(resolvedFont); - if (changed) emit q->fontChanged(); } @@ -215,24 +220,11 @@ QFont QQuickTextArea::font() const void QQuickTextArea::setFont(const QFont &font) { Q_D(QQuickTextArea); - if (d->sourceFont.resolve() == font.resolve() && d->sourceFont == font) + if (d->font.resolve() == font.resolve() && d->font == font) return; - // Determine which font is inherited from this control's ancestors and - // QGuiApplication::font, resolve this against \a font (attributes from the - // inherited font are copied over). Then propagate this font to this - // control's children. - QFont naturalFont = QQuickControlPrivate::naturalControlFont(this); - QFont resolvedFont = font.resolve(naturalFont); - if (d->sourceFont.resolve() == resolvedFont.resolve() && d->sourceFont == resolvedFont) - return; - - const bool changed = d->sourceFont != resolvedFont; - - QQuickTextEdit::setFont(font); - - if (changed) - emit fontChanged(); + d->font = font; + d->resolveFont(); } /*! @@ -338,7 +330,7 @@ void QQuickTextArea::itemChange(QQuickItem::ItemChange change, const QQuickItem: { Q_D(QQuickTextArea); QQuickTextEdit::itemChange(change, value); - if (change == ItemParentHasChanged && isComponentComplete()) + if (change == ItemParentHasChanged && value.item) d->resolveFont(); } diff --git a/src/templates/qquicktextarea_p_p.h b/src/templates/qquicktextarea_p_p.h index 2a16e5cc..f93eb968 100644 --- a/src/templates/qquicktextarea_p_p.h +++ b/src/templates/qquicktextarea_p_p.h @@ -77,6 +77,7 @@ public: void resizeBackground(); void resolveFont(); + void inheritFont(const QFont &f); qreal getImplicitWidth() const Q_DECL_OVERRIDE; qreal getImplicitHeight() const Q_DECL_OVERRIDE; @@ -91,6 +92,7 @@ public: QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE; #endif + QFont font; QQuickItem *background; QString placeholder; Qt::FocusReason focusReason; diff --git a/src/templates/qquicktextfield.cpp b/src/templates/qquicktextfield.cpp index 06a2f8e0..b04940f0 100644 --- a/src/templates/qquicktextfield.cpp +++ b/src/templates/qquicktextfield.cpp @@ -175,15 +175,20 @@ QQuickTextField::~QQuickTextField() void QQuickTextFieldPrivate::resolveFont() { Q_Q(QQuickTextField); - QFont naturalFont = QQuickControlPrivate::naturalControlFont(q); - QFont resolvedFont = sourceFont.resolve(naturalFont); - if (sourceFont.resolve() == resolvedFont.resolve() && sourceFont == resolvedFont) - return; + inheritFont(QQuickControlPrivate::naturalControlFont(q)); +} + +void QQuickTextFieldPrivate::inheritFont(const QFont &f) +{ + Q_Q(QQuickTextField); + QFont parentFont = font.resolve(f); + parentFont.resolve(font.resolve() | f.resolve()); - const bool changed = sourceFont != resolvedFont; + const QFont defaultFont = QQuickControlPrivate::themeFont(QPlatformTheme::SystemFont); + const QFont resolvedFont = parentFont.resolve(defaultFont); + const bool changed = resolvedFont != sourceFont; q->QQuickTextInput::setFont(resolvedFont); - if (changed) emit q->fontChanged(); } @@ -240,24 +245,11 @@ QFont QQuickTextField::font() const void QQuickTextField::setFont(const QFont &font) { Q_D(QQuickTextField); - if (d->sourceFont.resolve() == font.resolve() && d->sourceFont == font) + if (d->font.resolve() == font.resolve() && d->font == font) return; - // Determine which font is inherited from this control's ancestors and - // QGuiApplication::font, resolve this against \a font (attributes from the - // inherited font are copied over). Then propagate this font to this - // control's children. - QFont naturalFont = QQuickControlPrivate::naturalControlFont(this); - QFont resolvedFont = font.resolve(naturalFont); - if (d->sourceFont.resolve() == resolvedFont.resolve() && d->sourceFont == resolvedFont) - return; - - const bool changed = d->sourceFont != resolvedFont; - - QQuickTextInput::setFont(font); - - if (changed) - emit fontChanged(); + d->font = font; + d->resolveFont(); } /*! @@ -363,7 +355,7 @@ void QQuickTextField::itemChange(QQuickItem::ItemChange change, const QQuickItem { Q_D(QQuickTextField); QQuickTextInput::itemChange(change, value); - if (change == ItemParentHasChanged && isComponentComplete()) + if (change == ItemParentHasChanged && value.item) d->resolveFont(); } diff --git a/src/templates/qquicktextfield_p_p.h b/src/templates/qquicktextfield_p_p.h index 29b01f15..6cf0805e 100644 --- a/src/templates/qquicktextfield_p_p.h +++ b/src/templates/qquicktextfield_p_p.h @@ -77,6 +77,7 @@ public: void resizeBackground(); void resolveFont(); + void inheritFont(const QFont &f); qreal getImplicitWidth() const Q_DECL_OVERRIDE; qreal getImplicitHeight() const Q_DECL_OVERRIDE; @@ -92,6 +93,7 @@ public: QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE; #endif + QFont font; QQuickItem *background; QString placeholder; Qt::FocusReason focusReason; diff --git a/tests/auto/material/data/tst_material.qml b/tests/auto/material/data/tst_material.qml index e8ee47ca..fbb6e279 100644 --- a/tests/auto/material/data/tst_material.qml +++ b/tests/auto/material/data/tst_material.qml @@ -127,6 +127,17 @@ TestCase { } } + Component { + id: windowPane + ApplicationWindow { + width: 200 + height: 200 + visible: true + property alias pane: pane + Pane { id: pane } + } + } + function test_defaults() { var control = button.createObject(testCase) verify(control) @@ -376,42 +387,61 @@ TestCase { function test_font_data() { return [ - {tag: "Button:pixelSize", type: "Button", attribute: "pixelSize", value: 14}, - {tag: "Button:weight", type: "Button", attribute: "weight", value: Font.Medium}, - {tag: "Button:capitalization", type: "Button", attribute: "capitalization", value: Font.AllUppercase}, + {tag: "Button:pixelSize", type: "Button", attribute: "pixelSize", value: 14, window: 20, pane: 10}, + {tag: "Button:weight", type: "Button", attribute: "weight", value: Font.Medium, window: Font.Black, pane: Font.Bold}, + {tag: "Button:capitalization", type: "Button", attribute: "capitalization", value: Font.AllUppercase, window: Font.Capitalize, pane: Font.AllLowercase}, - {tag: "TabButton:pixelSize", type: "TabButton", attribute: "pixelSize", value: 14}, - {tag: "TabButton:weight", type: "TabButton", attribute: "weight", value: Font.Medium}, - {tag: "TabButton:capitalization", type: "TabButton", attribute: "capitalization", value: Font.AllUppercase}, + {tag: "TabButton:pixelSize", type: "TabButton", attribute: "pixelSize", value: 14, window: 20, pane: 10}, + {tag: "TabButton:weight", type: "TabButton", attribute: "weight", value: Font.Medium, window: Font.Black, pane: Font.Bold}, + {tag: "TabButton:capitalization", type: "TabButton", attribute: "capitalization", value: Font.AllUppercase, window: Font.Capitalize, pane: Font.AllLowercase}, - {tag: "ToolButton:pixelSize", type: "ToolButton", attribute: "pixelSize", value: 14}, - {tag: "ToolButton:weight", type: "ToolButton", attribute: "weight", value: Font.Normal}, - {tag: "ToolButton:capitalization", type: "ToolButton", attribute: "capitalization", value: Font.AllUppercase}, + {tag: "ToolButton:pixelSize", type: "ToolButton", attribute: "pixelSize", value: 14, window: 20, pane: 10}, + {tag: "ToolButton:weight", type: "ToolButton", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, + {tag: "ToolButton:capitalization", type: "ToolButton", attribute: "capitalization", value: Font.AllUppercase, window: Font.Capitalize, pane: Font.AllLowercase}, - {tag: "ItemDelegate:pixelSize", type: "ItemDelegate", attribute: "pixelSize", value: 14}, - {tag: "ItemDelegate:weight", type: "ItemDelegate", attribute: "weight", value: Font.Medium}, - {tag: "ItemDelegate:capitalization", type: "ItemDelegate", attribute: "capitalization", value: Font.MixedCase}, + {tag: "ItemDelegate:pixelSize", type: "ItemDelegate", attribute: "pixelSize", value: 14, window: 20, pane: 10}, + {tag: "ItemDelegate:weight", type: "ItemDelegate", attribute: "weight", value: Font.Medium, window: Font.Black, pane: Font.Bold}, + {tag: "ItemDelegate:capitalization", type: "ItemDelegate", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase}, - {tag: "CheckBox:pixelSize", type: "CheckBox", attribute: "pixelSize", value: 16}, - {tag: "CheckBox:weight", type: "CheckBox", attribute: "weight", value: Font.Normal}, - {tag: "CheckBox:capitalization", type: "CheckBox", attribute: "capitalization", value: Font.MixedCase}, + {tag: "CheckBox:pixelSize", type: "CheckBox", attribute: "pixelSize", value: 16, window: 20, pane: 10}, + {tag: "CheckBox:weight", type: "CheckBox", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, + {tag: "CheckBox:capitalization", type: "CheckBox", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase}, - {tag: "RadioButton:pixelSize", type: "RadioButton", attribute: "pixelSize", value: 16}, - {tag: "RadioButton:weight", type: "RadioButton", attribute: "weight", value: Font.Normal}, - {tag: "RadioButton:capitalization", type: "RadioButton", attribute: "capitalization", value: Font.MixedCase}, + {tag: "RadioButton:pixelSize", type: "RadioButton", attribute: "pixelSize", value: 16, window: 20, pane: 10}, + {tag: "RadioButton:weight", type: "RadioButton", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, + {tag: "RadioButton:capitalization", type: "RadioButton", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase}, - {tag: "MenuItem:pixelSize", type: "MenuItem", attribute: "pixelSize", value: 16}, - {tag: "MenuItem:weight", type: "MenuItem", attribute: "weight", value: Font.Normal}, - {tag: "MenuItem:capitalization", type: "MenuItem", attribute: "capitalization", value: Font.MixedCase} + {tag: "MenuItem:pixelSize", type: "MenuItem", attribute: "pixelSize", value: 16, window: 20, pane: 10}, + {tag: "MenuItem:weight", type: "MenuItem", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, + {tag: "MenuItem:capitalization", type: "MenuItem", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase} ] } function test_font(data) { - var control = Qt.createQmlObject("import Qt.labs.controls 1.0; " + data.type + " { }", testCase) + var window = windowPane.createObject(testCase) + verify(window) + verify(window.pane) + + var control = Qt.createQmlObject("import Qt.labs.controls 1.0; " + data.type + " { }", window.pane) verify(control) compare(control.font[data.attribute], data.value) - control.destroy() + window.font[data.attribute] = data.window + compare(window.font[data.attribute], data.window) + compare(window.pane.font[data.attribute], data.window) + compare(control.font[data.attribute], data.window) + + window.pane.font[data.attribute] = data.pane + compare(window.font[data.attribute], data.window) + compare(window.pane.font[data.attribute], data.pane) + compare(control.font[data.attribute], data.pane) + + window.pane.font = undefined + compare(window.font[data.attribute], data.window) + compare(window.pane.font[data.attribute], data.window) + compare(control.font[data.attribute], data.window) + + window.destroy() } } diff --git a/tests/auto/universal/data/tst_universal.qml b/tests/auto/universal/data/tst_universal.qml index 82c07b23..27ffae9e 100644 --- a/tests/auto/universal/data/tst_universal.qml +++ b/tests/auto/universal/data/tst_universal.qml @@ -123,6 +123,17 @@ TestCase { } } + Component { + id: windowPane + ApplicationWindow { + width: 200 + height: 200 + visible: true + property alias pane: pane + Pane { id: pane } + } + } + function test_defaults() { var control = button.createObject(testCase) verify(control) @@ -336,22 +347,41 @@ TestCase { function test_font_data() { return [ - {tag: "Control:pixelSize", type: "Control", attribute: "pixelSize", value: 15}, + {tag: "Control:pixelSize", type: "Control", attribute: "pixelSize", value: 15, window: 20, pane: 10}, - {tag: "GroupBox:pixelSize", type: "GroupBox", attribute: "pixelSize", value: 15}, - {tag: "GroupBox:weight", type: "GroupBox", attribute: "weight", value: Font.DemiBold}, + {tag: "GroupBox:pixelSize", type: "GroupBox", attribute: "pixelSize", value: 15, window: 20, pane: 10}, + {tag: "GroupBox:weight", type: "GroupBox", attribute: "weight", value: Font.DemiBold, window: Font.Light, pane: Font.Medium}, - {tag: "TabButton:pixelSize", type: "TabButton", attribute: "pixelSize", value: 24}, - {tag: "TabButton:weight", type: "TabButton", attribute: "weight", value: Font.Light}, + {tag: "TabButton:pixelSize", type: "TabButton", attribute: "pixelSize", value: 24, window: 20, pane: 10}, + {tag: "TabButton:weight", type: "TabButton", attribute: "weight", value: Font.Light, window: Font.Black, pane: Font.Bold} ] } function test_font(data) { - var control = Qt.createQmlObject("import Qt.labs.controls 1.0; " + data.type + " { }", testCase) + var window = windowPane.createObject(testCase) + verify(window) + verify(window.pane) + + var control = Qt.createQmlObject("import Qt.labs.controls 1.0; " + data.type + " { }", window.pane) verify(control) compare(control.font[data.attribute], data.value) - control.destroy() + window.font[data.attribute] = data.window + compare(window.font[data.attribute], data.window) + compare(window.pane.font[data.attribute], data.window) + compare(control.font[data.attribute], data.window) + + window.pane.font[data.attribute] = data.pane + compare(window.font[data.attribute], data.window) + compare(window.pane.font[data.attribute], data.pane) + compare(control.font[data.attribute], data.pane) + + window.pane.font = undefined + compare(window.font[data.attribute], data.window) + compare(window.pane.font[data.attribute], data.window) + compare(control.font[data.attribute], data.window) + + window.destroy() } } |