From 159599e97750ad1a9208a66303552aa8b4f2cdc7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sun, 8 Apr 2018 19:58:03 +0200 Subject: QQuickLabel: fix background resizing setBackground() must resize the item if component construction is already complete. Change-Id: I76cada5b37257473a9c0146ee1f6de8de6c10218 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicklabel.cpp | 30 +++++++++++++++++++----------- src/quicktemplates2/qquicklabel_p_p.h | 2 ++ tests/auto/controls/data/tst_label.qml | 24 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 41b2d93a..8c94ee87 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -94,6 +94,22 @@ QQuickLabelPrivate::~QQuickLabelPrivate() #endif } +void QQuickLabelPrivate::resizeBackground() +{ + Q_Q(QQuickLabel); + if (background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + if (!p->widthValid) { + background->setWidth(q->width()); + p->widthValid = false; + } + if (!p->heightValid) { + background->setHeight(q->height()); + p->heightValid = false; + } + } +} + /*! \internal @@ -279,6 +295,8 @@ void QQuickLabel::setBackground(QQuickItem *background) background->setParentItem(this); if (qFuzzyIsNull(background->z())) background->setZ(-1); + if (isComponentComplete()) + d->resizeBackground(); } if (!d->background.isExecuting()) emit backgroundChanged(); @@ -359,17 +377,7 @@ void QQuickLabel::geometryChanged(const QRectF &newGeometry, const QRectF &oldGe { Q_D(QQuickLabel); QQuickText::geometryChanged(newGeometry, oldGeometry); - if (d->background) { - QQuickItemPrivate *p = QQuickItemPrivate::get(d->background); - if (!p->widthValid) { - d->background->setWidth(newGeometry.width()); - p->widthValid = false; - } - if (!p->heightValid) { - d->background->setHeight(newGeometry.height()); - p->heightValid = false; - } - } + d->resizeBackground(); } QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquicklabel_p_p.h b/src/quicktemplates2/qquicklabel_p_p.h index bcd1aca6..4d6c7de7 100644 --- a/src/quicktemplates2/qquicklabel_p_p.h +++ b/src/quicktemplates2/qquicklabel_p_p.h @@ -74,6 +74,8 @@ public: return static_cast(QObjectPrivate::get(item)); } + void resizeBackground(); + void resolveFont(); void inheritFont(const QFont &font); void updateFont(const QFont &font); diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml index 5618fe07..69d273a7 100644 --- a/tests/auto/controls/data/tst_label.qml +++ b/tests/auto/controls/data/tst_label.qml @@ -65,6 +65,18 @@ TestCase { Label { } } + Component { + id: backgroundLabel + Label { + background: Rectangle { } + } + } + + Component { + id: rectangle + Rectangle { } + } + Component { id: signalSpy SignalSpy { } @@ -115,4 +127,16 @@ TestCase { compare(child.font[data.tag], defaultValue) compare(childSpy.count, 0) } + + function test_background() { + var control = createTemporaryObject(backgroundLabel, testCase, {text: "Label"}) + verify(control) + + compare(control.background.width, control.width) + compare(control.background.height, control.height) + + control.background = rectangle.createObject(control) + compare(control.background.width, control.width) + compare(control.background.height, control.height) + } } -- cgit v1.2.3 From e53908bda45cde0d75d35565c29995aef48bb026 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sun, 8 Apr 2018 18:15:52 +0200 Subject: Fix background size regression caused by deferred execution Same as aca950e4 for QQuickControl. Change-Id: I508bb882cae7dd578349351d1f48919c45ca3d27 Reviewed-by: Mitch Curtis Reviewed-by: Qt CI Bot --- src/quicktemplates2/qquicklabel.cpp | 1 + src/quicktemplates2/qquicktextarea.cpp | 1 + src/quicktemplates2/qquicktextfield.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 8c94ee87..d39006cd 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -347,6 +347,7 @@ void QQuickLabel::componentComplete() Q_D(QQuickLabel); d->executeBackground(true); QQuickText::componentComplete(); + d->resizeBackground(); #if QT_CONFIG(accessibility) if (QAccessible::isActive()) d->accessibilityActiveChanged(true); diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 9a076e83..aca13d5e 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -718,6 +718,7 @@ void QQuickTextArea::componentComplete() Q_D(QQuickTextArea); d->executeBackground(true); QQuickTextEdit::componentComplete(); + d->resizeBackground(); #if QT_CONFIG(quicktemplates2_hover) if (!d->explicitHoverEnabled) setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem)); diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index 49f9b4c8..876ceca6 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -569,6 +569,7 @@ void QQuickTextField::componentComplete() Q_D(QQuickTextField); d->executeBackground(true); QQuickTextInput::componentComplete(); + d->resizeBackground(); #if QT_CONFIG(quicktemplates2_hover) if (!d->explicitHoverEnabled) setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem)); -- cgit v1.2.3 From 80a8317fc43862db4c1dda069a9e4c221113c6e1 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Apr 2018 07:57:50 +0200 Subject: Material: give RadioIndicator a disabled state Task-number: QTBUG-67442 Change-Id: I41d8515763ef3af6da463ab9c1549164de3fafa0 Reviewed-by: J-P Nurmi --- src/imports/controls/material/RadioIndicator.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/imports/controls/material/RadioIndicator.qml b/src/imports/controls/material/RadioIndicator.qml index 47505903..0f6dc930 100644 --- a/src/imports/controls/material/RadioIndicator.qml +++ b/src/imports/controls/material/RadioIndicator.qml @@ -43,7 +43,8 @@ Rectangle { implicitHeight: 20 radius: width / 2 border.width: 2 - border.color: control.checked || control.down ? control.Material.accentColor : control.Material.secondaryTextColor + border.color: control.enabled && (control.checked || control.down) + ? control.Material.accentColor : control.Material.secondaryTextColor color: "transparent" property Item control -- cgit v1.2.3 From 380a984521cc2a45afebde15b65563612ef8f50c Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 9 Apr 2018 13:27:14 +0200 Subject: Fusion: add plugins.qmltypes Even though there are no public QML types in the QtQuick.Controls.Fusion namespace, we must provide plugins.qmltypes to avoid that tooling tries to run qmlplugindump. Because of the internal .impl namespace, running qmlplugindump doesn't work out of the box. The plugins.qmltypes file has been dumped after deleting all .qml files from QT_INSTALL_QML/QtQuick/Controls.2/Fusion and then manually edited to remove all redundant QQC2 type definitions, leaving only the Fusion .impl type definitions, similarly to what we did with the other styles. Task-number: QTBUG-66276 Change-Id: I39ecfa1cd889ec5013a85dcdf96395fa31e92e57 Reviewed-by: Mitch Curtis --- src/imports/controls/fusion/plugins.qmltypes | 146 +++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 src/imports/controls/fusion/plugins.qmltypes diff --git a/src/imports/controls/fusion/plugins.qmltypes b/src/imports/controls/fusion/plugins.qmltypes new file mode 100644 index 00000000..e6c350d6 --- /dev/null +++ b/src/imports/controls/fusion/plugins.qmltypes @@ -0,0 +1,146 @@ +import QtQuick.tooling 1.2 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable QtQuick.Controls.Fusion 2.3' + +Module { + dependencies: [ ] + Component { + name: "QQuickFusionBusyIndicator" + defaultProperty: "data" + prototype: "QQuickPaintedItem" + exports: ["QtQuick.Controls.Fusion.impl/BusyIndicatorImpl 2.3"] + exportMetaObjectRevisions: [0] + Property { name: "color"; type: "QColor" } + Property { name: "running"; type: "bool" } + } + Component { + name: "QQuickFusionDial" + defaultProperty: "data" + prototype: "QQuickPaintedItem" + exports: ["QtQuick.Controls.Fusion.impl/DialImpl 2.3"] + exportMetaObjectRevisions: [0] + Property { name: "highlight"; type: "bool" } + Property { name: "palette"; type: "QPalette" } + } + Component { + name: "QQuickFusionKnob" + defaultProperty: "data" + prototype: "QQuickPaintedItem" + exports: ["QtQuick.Controls.Fusion.impl/KnobImpl 2.3"] + exportMetaObjectRevisions: [0] + Property { name: "palette"; type: "QPalette" } + } + Component { + name: "QQuickFusionStyle" + prototype: "QObject" + exports: ["QtQuick.Controls.Fusion.impl/Fusion 2.3"] + isCreatable: false + isSingleton: true + exportMetaObjectRevisions: [0] + Property { name: "lightShade"; type: "QColor"; isReadonly: true } + Property { name: "darkShade"; type: "QColor"; isReadonly: true } + Property { name: "topShadow"; type: "QColor"; isReadonly: true } + Property { name: "innerContrastLine"; type: "QColor"; isReadonly: true } + Method { + name: "highlight" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + Method { + name: "highlightedText" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + Method { + name: "outline" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + Method { + name: "highlightedOutline" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + Method { + name: "tabFrameColor" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + Method { + name: "buttonColor" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + Parameter { name: "highlighted"; type: "bool" } + Parameter { name: "down"; type: "bool" } + Parameter { name: "hovered"; type: "bool" } + } + Method { + name: "buttonColor" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + Parameter { name: "highlighted"; type: "bool" } + Parameter { name: "down"; type: "bool" } + } + Method { + name: "buttonColor" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + Parameter { name: "highlighted"; type: "bool" } + } + Method { + name: "buttonColor" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + Method { + name: "buttonOutline" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + Parameter { name: "highlighted"; type: "bool" } + Parameter { name: "enabled"; type: "bool" } + } + Method { + name: "buttonOutline" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + Parameter { name: "highlighted"; type: "bool" } + } + Method { + name: "buttonOutline" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + Method { + name: "gradientStart" + type: "QColor" + Parameter { name: "baseColor"; type: "QColor" } + } + Method { + name: "gradientStop" + type: "QColor" + Parameter { name: "baseColor"; type: "QColor" } + } + Method { + name: "mergedColors" + type: "QColor" + Parameter { name: "colorA"; type: "QColor" } + Parameter { name: "colorB"; type: "QColor" } + Parameter { name: "factor"; type: "int" } + } + Method { + name: "mergedColors" + type: "QColor" + Parameter { name: "colorA"; type: "QColor" } + Parameter { name: "colorB"; type: "QColor" } + } + Method { + name: "grooveColor" + type: "QColor" + Parameter { name: "palette"; type: "QPalette" } + } + } +} -- cgit v1.2.3 From cfe00c40127dbe5790e04cd9f810bcc98fee13ed Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Apr 2018 14:13:50 +0200 Subject: Stabilize Popup::test_shortcut() Try to pinpoint the cause of recent flakiness by ensuring that the shortcut is activated. Change-Id: I8bf81dedfd28b0fe66403147228a8452cc3bea2a Reviewed-by: J-P Nurmi --- tests/auto/controls/data/tst_popup.qml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index a6c24cb7..2a6d585c 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1280,11 +1280,13 @@ TestCase { visible: true property alias popup: popup + property alias shortcut: shortcut Popup { id: popup Shortcut { + id: shortcut sequence: "Tab" onActivated: popup.visible = !popup.visible } @@ -1298,11 +1300,17 @@ TestCase { var window = createTemporaryObject(shortcutWindowComponent, testCase) var control = window.popup + var shortcutActivatedSpy = createTemporaryObject(signalSpy, testCase, + { target: window.shortcut, signalName: "activated"} ) + verify(shortcutActivatedSpy.valid) + waitForRendering(window.contentItem) keyClick(Qt.Key_Tab) + compare(shortcutActivatedSpy.count, 1) tryCompare(control, "visible", true) keyClick(Qt.Key_Tab) + compare(shortcutActivatedSpy.count, 2) tryCompare(control, "visible", false) } } -- cgit v1.2.3 From 99b2fbbc90466c79837c7e68ac5d7a15b2f91699 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 10 Apr 2018 11:50:32 +0200 Subject: Material: fix CheckIndicator disabled state Task-number: QTBUG-67573 Change-Id: Iecdc9f6f35f858b962dc9a9e17077a35f56e90dd Reviewed-by: J-P Nurmi --- src/imports/controls/material/CheckIndicator.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/imports/controls/material/CheckIndicator.qml b/src/imports/controls/material/CheckIndicator.qml index 078b1637..71962150 100644 --- a/src/imports/controls/material/CheckIndicator.qml +++ b/src/imports/controls/material/CheckIndicator.qml @@ -43,8 +43,9 @@ Rectangle { implicitWidth: 18 implicitHeight: 18 color: "transparent" - border.color: control.checked && control.enabled ? control.Material.accentColor : control.Material.secondaryTextColor - border.width: control.checked ? width / 2 : 2 + border.color: !control.enabled ? control.Material.hintTextColor + : control.checkState !== Qt.Unchecked ? control.Material.accentColor : control.Material.secondaryTextColor + border.width: control.checkState !== Qt.Unchecked ? width / 2 : 2 radius: 2 property Item control -- cgit v1.2.3 From ca406d69544e6ddf20d940d903c9c97bca07ff90 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 10 Apr 2018 12:02:08 +0200 Subject: Material: fix RadioIndicator disabled state Task-number: QTBUG-67574 Change-Id: I3ab706c3eb6ad3112ed3f0a7dc37d530a179be6f Reviewed-by: J-P Nurmi --- src/imports/controls/material/RadioIndicator.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imports/controls/material/RadioIndicator.qml b/src/imports/controls/material/RadioIndicator.qml index 0f6dc930..7f27dcdc 100644 --- a/src/imports/controls/material/RadioIndicator.qml +++ b/src/imports/controls/material/RadioIndicator.qml @@ -43,8 +43,8 @@ Rectangle { implicitHeight: 20 radius: width / 2 border.width: 2 - border.color: control.enabled && (control.checked || control.down) - ? control.Material.accentColor : control.Material.secondaryTextColor + border.color: !control.enabled ? control.Material.hintTextColor + : control.checked || control.down ? control.Material.accentColor : control.Material.secondaryTextColor color: "transparent" property Item control -- cgit v1.2.3