qtdeclarative/tests/manual/quickcontrols/fonts/main.qml

122 lines
3.7 KiB
QML
Raw Normal View History

// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
import QtQuick.Dialogs
import QtQuick.Layouts
ApplicationWindow {
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
id: window
visible: true
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
width: 640
height: 640
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
title: qsTr("Font and Color Inheritance Test")
font.pointSize: pointSizeSlider.value
font.family: fontDialog.selectedFont.family
palette.text: textColorDialog.selectedColor
palette.buttonText: buttonTextColorDialog.selectedColor
SystemPalette { id: systemPalette }
header: ToolBar {
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
RowLayout {
width: parent.width
Slider {
id: pointSizeSlider
from: 6
to: 48
value: 12
stepSize: 1
Layout.fillWidth: false
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
}
Label {
text: pointSizeSlider.value + " pt " + font.family
}
Button {
text: "Font…"
palette.buttonText: systemPalette.buttonText
Layout.fillWidth: false
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
onClicked: fontDialog.open()
FontDialog { id: fontDialog }
Component.onCompleted: fontDialog.selectedFont = window.font
}
Item { Layout.fillWidth: true }
Button {
text: "Text…"
palette.buttonText: textColorDialog.selectedColor
Layout.fillWidth: false
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
onClicked: textColorDialog.open()
ColorDialog { id: textColorDialog }
Component.onCompleted: textColorDialog.selectedColor = systemPalette.text
Layout.margins: 3
Layout.alignment: Qt.AlignRight
}
Button {
text: "Buttons…"
Layout.fillWidth: false
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
onClicked: buttonTextColorDialog.open()
ColorDialog { id: buttonTextColorDialog }
Component.onCompleted: buttonTextColorDialog.selectedColor = systemPalette.buttonText
Layout.margins: 3
Layout.alignment: Qt.AlignRight
}
}
}
Flickable {
anchors.fill: parent
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
contentWidth: layout.implicitWidth + 40
contentHeight: layout.implicitHeight + 40
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
ColumnLayout {
id: layout
anchors.fill: parent
anchors.margins: 20
Label {
text: "Label with **Bold** *Italics* _Underline_ ~~Strikethrough~~ `Mono`"
textFormat: Label.MarkdownText
}
Button {
text: "Button"
Layout.fillWidth: false
}
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
GroupBox {
title: "GroupBox"
Layout.fillWidth: false
Layout.fillHeight: false
Let Controls inherit palettes and fonts from parents The Item's palette property and Control's font property returns the resolved value; its resolveMask is inherited from parent object, when the return value is used in the qml. For example: ApplicationWindow { id: window palette { window: "blue"; windowText: "blue" } Control { id: control } Button { onClicked: { control.palette.window = "red" window.palette.windowText = "red" console.log(control.palette.windowText) } } } In Button.onClicked, `control.palette` is the `resolvedPalette` of Control, it's resolveMask is not 0. Next, the new value is assigned to the control, then the control's "requestedPalette" will change to the new value, and it's resolveMask also is not 0. Next, `window.palette.windowText = "red"` changes the `windowText` palette for the window; QQuickPaletteColorProvider::inheritPalette() will be called. Because the resolveMask of `requestedPalette` is equal to the new palette, the control will not inherit any colors from its parent. So `console.log(control.palette.windowText)` was printing `qml: #0000ff`, but the right result is `qml: #ff0000`. When PaletteProvider is missing the inherited struct, fallbackPalette is now used as parentPalette. [ChangeLog][Controls] Controls now inherit palette and font from parents. Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-With: yeshanshan <yeshanshan@uniontech.com> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Pick-to: 6.4 Fixes: QTBUG-101480 Change-Id: Ibe400f647512331352bf34dee42f908fb7a8d914 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-03-07 09:36:48 +00:00
ColumnLayout {
RadioButton { text: "RadioButton" }
CheckBox { text: "CheckBox" }
}
}
Switch {
text: "Switch"
Layout.fillWidth: false
}
TabButton {
text: "TabButton"
Layout.fillWidth: false
}
TextField {
placeholderText: "TextField"
Layout.fillWidth: false
}
TextArea {
placeholderText: "TextArea"
Layout.fillWidth: false
Layout.fillHeight: false
}
ToolButton {
text: "ToolButton"
}
Tumbler {
model: 3
Layout.fillWidth: false
Layout.fillHeight: false
}
}
ScrollBar.vertical: ScrollBar { }
}
}