Merge pull request #9732 from fieldOfView/fix_style_theme_undefined

Fix floods of QML errors in styles.qml
This commit is contained in:
Jelle Spijker 2021-05-03 10:57:01 +02:00 committed by GitHub
commit 778ab232df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
// Copyright (c) 2018 Ultimaker B.V. // Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher. // Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.10 import QtQuick 2.10
@ -21,49 +21,49 @@ QtObject
{ {
if(control.valueError) if(control.valueError)
{ {
return Theme.getColor("setting_validation_error_background"); return UM.Theme.getColor("setting_validation_error_background");
} }
else if(control.valueWarning) else if(control.valueWarning)
{ {
return Theme.getColor("setting_validation_warning_background"); return UM.Theme.getColor("setting_validation_warning_background");
} }
else else
{ {
return Theme.getColor("setting_control"); return UM.Theme.getColor("setting_control");
} }
} }
else else
{ {
return Theme.getColor("setting_control_disabled"); return UM.Theme.getColor("setting_control_disabled");
} }
} }
radius: UM.Theme.getSize("setting_control_radius").width radius: UM.Theme.getSize("setting_control_radius").width
border.width: Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: border.color:
{ {
if (control.enabled) if (control.enabled)
{ {
if (control.valueError) if (control.valueError)
{ {
return Theme.getColor("setting_validation_error"); return UM.Theme.getColor("setting_validation_error");
} }
else if (control.valueWarning) else if (control.valueWarning)
{ {
return Theme.getColor("setting_validation_warning"); return UM.Theme.getColor("setting_validation_warning");
} }
else if (control.hovered) else if (control.hovered)
{ {
return Theme.getColor("setting_control_border_highlight"); return UM.Theme.getColor("setting_control_border_highlight");
} }
else else
{ {
return Theme.getColor("setting_control_border"); return UM.Theme.getColor("setting_control_border");
} }
} }
else else
{ {
return Theme.getColor("setting_control_disabled_border"); return UM.Theme.getColor("setting_control_disabled_border");
} }
} }
UM.RecolorImage UM.RecolorImage
@ -71,25 +71,25 @@ QtObject
id: downArrow id: downArrow
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Theme.getSize("default_margin").width anchors.rightMargin: UM.Theme.getSize("default_margin").width
width: Theme.getSize("standard_arrow").width width: UM.Theme.getSize("standard_arrow").width
height: Theme.getSize("standard_arrow").height height: UM.Theme.getSize("standard_arrow").height
sourceSize.height: width sourceSize.height: width
color: control.enabled ? Theme.getColor("setting_control_button") : Theme.getColor("setting_category_disabled_text") color: control.enabled ? UM.Theme.getColor("setting_control_button") : UM.Theme.getColor("setting_category_disabled_text")
source: Theme.getIcon("arrow_bottom") source: UM.Theme.getIcon("arrow_bottom")
} }
Label Label
{ {
id: printSetupComboBoxLabel id: printSetupComboBoxLabel
color: control.enabled ? Theme.getColor("setting_control_text") : Theme.getColor("setting_control_disabled_text") color: control.enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
text: control.text; text: control.text;
elide: Text.ElideRight; elide: Text.ElideRight;
anchors.left: parent.left; anchors.left: parent.left;
anchors.leftMargin: Theme.getSize("setting_unit_margin").width anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
anchors.right: downArrow.left; anchors.right: downArrow.left;
anchors.rightMargin: control.rightMargin; anchors.rightMargin: control.rightMargin;
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
font: Theme.getFont("default") font: UM.Theme.getFont("default")
} }
} }
label: Label{} label: Label{}
@ -175,25 +175,25 @@ QtObject
{ {
background: Item background: Item
{ {
implicitWidth: Theme.getSize("button").width implicitWidth: UM.Theme.getSize("button").width
implicitHeight: Theme.getSize("button").height implicitHeight: UM.Theme.getSize("button").height
UM.PointingRectangle UM.PointingRectangle
{ {
id: button_tooltip id: button_tooltip
anchors.left: parent.right anchors.left: parent.right
anchors.leftMargin: Theme.getSize("button_tooltip_arrow").width * 2 anchors.leftMargin: UM.Theme.getSize("button_tooltip_arrow").width * 2
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
target: Qt.point(parent.x, y + Math.round(height/2)) target: Qt.point(parent.x, y + Math.round(height/2))
arrowSize: Theme.getSize("button_tooltip_arrow").width arrowSize: UM.Theme.getSize("button_tooltip_arrow").width
color: Theme.getColor("button_tooltip") color: UM.Theme.getColor("button_tooltip")
opacity: control.hovered ? 1.0 : 0.0; opacity: control.hovered ? 1.0 : 0.0;
visible: control.text != "" visible: control.text != ""
width: control.hovered ? button_tip.width + Theme.getSize("button_tooltip").width : 0 width: control.hovered ? button_tip.width + UM.Theme.getSize("button_tooltip").width : 0
height: Theme.getSize("button_tooltip").height height: UM.Theme.getSize("button_tooltip").height
Behavior on width { NumberAnimation { duration: 100; } } Behavior on width { NumberAnimation { duration: 100; } }
Behavior on opacity { NumberAnimation { duration: 100; } } Behavior on opacity { NumberAnimation { duration: 100; } }
@ -206,8 +206,8 @@ QtObject
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: control.text text: control.text
font: Theme.getFont("default") font: UM.Theme.getFont("default")
color: Theme.getColor("tooltip_text") color: UM.Theme.getColor("tooltip_text")
} }
} }
@ -226,22 +226,22 @@ QtObject
} }
else if(control.checkable && control.checked && control.hovered) else if(control.checkable && control.checked && control.hovered)
{ {
return Theme.getColor("toolbar_button_active_hover") return UM.Theme.getColor("toolbar_button_active_hover")
} }
else if(control.pressed || (control.checkable && control.checked)) else if(control.pressed || (control.checkable && control.checked))
{ {
return Theme.getColor("toolbar_button_active") return UM.Theme.getColor("toolbar_button_active")
} }
else if(control.hovered) else if(control.hovered)
{ {
return Theme.getColor("toolbar_button_hover") return UM.Theme.getColor("toolbar_button_hover")
} }
return Theme.getColor("toolbar_background") return UM.Theme.getColor("toolbar_background")
} }
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? Theme.getSize("default_lining").width : 0 border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? UM.Theme.getSize("default_lining").width : 0
border.color: control.checked ? Theme.getColor("icon") : Theme.getColor("lining") border.color: control.checked ? UM.Theme.getColor("icon") : UM.Theme.getColor("lining")
} }
} }
@ -252,11 +252,11 @@ QtObject
anchors.centerIn: parent anchors.centerIn: parent
opacity: control.enabled ? 1.0 : 0.2 opacity: control.enabled ? 1.0 : 0.2
source: control.iconSource source: control.iconSource
width: Theme.getSize("button_icon").width width: UM.Theme.getSize("button_icon").width
height: Theme.getSize("button_icon").height height: UM.Theme.getSize("button_icon").height
color: Theme.getColor("icon") color: UM.Theme.getColor("icon")
sourceSize: Theme.getSize("button_icon") sourceSize: UM.Theme.getSize("button_icon")
} }
} }
} }
@ -268,10 +268,10 @@ QtObject
{ {
background: Rectangle background: Rectangle
{ {
implicitWidth: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2) implicitWidth: UM.Theme.getSize("message").width - (UM.Theme.getSize("default_margin").width * 2)
implicitHeight: Theme.getSize("progressbar").height implicitHeight: UM.Theme.getSize("progressbar").height
color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : Theme.getColor("progressbar_background") color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : UM.Theme.getColor("progressbar_background")
radius: Theme.getSize("progressbar_radius").width radius: UM.Theme.getSize("progressbar_radius").width
} }
progress: Rectangle progress: Rectangle
{ {
@ -287,22 +287,22 @@ QtObject
} }
else else
{ {
return Theme.getColor("progressbar_control"); return UM.Theme.getColor("progressbar_control");
} }
} }
radius: Theme.getSize("progressbar_radius").width radius: UM.Theme.getSize("progressbar_radius").width
Rectangle Rectangle
{ {
radius: Theme.getSize("progressbar_radius").width radius: UM.Theme.getSize("progressbar_radius").width
color: control.hasOwnProperty("controlColor") ? control.controlColor : Theme.getColor("progressbar_control") color: control.hasOwnProperty("controlColor") ? control.controlColor : UM.Theme.getColor("progressbar_control")
width: Theme.getSize("progressbar_control").width width: UM.Theme.getSize("progressbar_control").width
height: Theme.getSize("progressbar_control").height height: UM.Theme.getSize("progressbar_control").height
visible: control.indeterminate visible: control.indeterminate
SequentialAnimation on x SequentialAnimation on x
{ {
id: xAnim id: xAnim
property int animEndPoint: Theme.getSize("message").width - Math.round((Theme.getSize("default_margin").width * 2.5)) - Theme.getSize("progressbar_control").width property int animEndPoint: UM.Theme.getSize("message").width - Math.round((UM.Theme.getSize("default_margin").width * 2.5)) - UM.Theme.getSize("progressbar_control").width
running: control.indeterminate && control.visible running: control.indeterminate && control.visible
loops: Animation.Infinite loops: Animation.Infinite
NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;} NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
@ -324,18 +324,18 @@ QtObject
scrollBarBackground: Rectangle scrollBarBackground: Rectangle
{ {
implicitWidth: Theme.getSize("scrollbar").width implicitWidth: UM.Theme.getSize("scrollbar").width
radius: Math.round(implicitWidth / 2) radius: Math.round(implicitWidth / 2)
color: Theme.getColor("scrollbar_background") color: UM.Theme.getColor("scrollbar_background")
} }
handle: Rectangle handle: Rectangle
{ {
id: scrollViewHandle id: scrollViewHandle
implicitWidth: Theme.getSize("scrollbar").width implicitWidth: UM.Theme.getSize("scrollbar").width
radius: Math.round(implicitWidth / 2) radius: Math.round(implicitWidth / 2)
color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle") color: styleData.pressed ? UM.Theme.getColor("scrollbar_handle_down") : styleData.hovered ? UM.Theme.getColor("scrollbar_handle_hover") : UM.Theme.getColor("scrollbar_handle")
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
} }
} }
@ -348,14 +348,14 @@ QtObject
background: Rectangle background: Rectangle
{ {
implicitHeight: Theme.getSize("setting_control").height; implicitHeight: UM.Theme.getSize("setting_control").height;
implicitWidth: Theme.getSize("setting_control").width; implicitWidth: UM.Theme.getSize("setting_control").width;
color: control.hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control") color: control.hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
border.width: Theme.getSize("default_lining").width; border.width: UM.Theme.getSize("default_lining").width;
border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border"); border.color: control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border");
radius: UM.Theme.getSize("setting_control_radius").width radius: UM.Theme.getSize("setting_control_radius").width
} }
@ -364,14 +364,14 @@ QtObject
Label Label
{ {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: Theme.getSize("default_lining").width anchors.leftMargin: UM.Theme.getSize("default_lining").width
anchors.right: downArrow.left anchors.right: downArrow.left
anchors.rightMargin: Theme.getSize("default_lining").width anchors.rightMargin: UM.Theme.getSize("default_lining").width
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: control.currentText text: control.currentText
font: Theme.getFont("default"); font: UM.Theme.getFont("default");
color: !enabled ? Theme.getColor("setting_control_disabled_text") : Theme.getColor("setting_control_text") color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
elide: Text.ElideRight elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
@ -381,16 +381,16 @@ QtObject
{ {
id: downArrow id: downArrow
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Theme.getSize("default_lining").width * 2 anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
source: Theme.getIcon("arrow_bottom") source: UM.Theme.getIcon("arrow_bottom")
width: Theme.getSize("standard_arrow").width width: UM.Theme.getSize("standard_arrow").width
height: Theme.getSize("standard_arrow").height height: UM.Theme.getSize("standard_arrow").height
sourceSize.width: width + 5 * screenScaleFactor sourceSize.width: width + 5 * screenScaleFactor
sourceSize.height: width + 5 * screenScaleFactor sourceSize.height: width + 5 * screenScaleFactor
color: Theme.getColor("setting_control_button"); color: UM.Theme.getColor("setting_control_button");
} }
} }
} }
@ -403,16 +403,16 @@ QtObject
background: Item { } background: Item { }
indicator: Rectangle indicator: Rectangle
{ {
implicitWidth: Theme.getSize("checkbox").width implicitWidth: UM.Theme.getSize("checkbox").width
implicitHeight: Theme.getSize("checkbox").height implicitHeight: UM.Theme.getSize("checkbox").height
color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : (control.enabled ? Theme.getColor("checkbox") : Theme.getColor("checkbox_disabled")) color: (control.hovered || control._hovered) ? UM.Theme.getColor("checkbox_hover") : (control.enabled ? UM.Theme.getColor("checkbox") : UM.Theme.getColor("checkbox_disabled"))
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : Theme.getSize("checkbox_radius").width radius: control.exclusiveGroup ? Math.round(UM.Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width
border.width: Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border") border.color: (control.hovered || control._hovered) ? UM.Theme.getColor("checkbox_border_hover") : UM.Theme.getColor("checkbox_border")
UM.RecolorImage UM.RecolorImage
{ {
@ -421,8 +421,8 @@ QtObject
width: Math.round(parent.width / 2.5) width: Math.round(parent.width / 2.5)
height: Math.round(parent.height / 2.5) height: Math.round(parent.height / 2.5)
sourceSize.height: width sourceSize.height: width
color: Theme.getColor("checkbox_mark") color: UM.Theme.getColor("checkbox_mark")
source: control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check") source: control.exclusiveGroup ? UM.Theme.getIcon("dot") : UM.Theme.getIcon("check")
opacity: control.checked opacity: control.checked
Behavior on opacity { NumberAnimation { duration: 100; } } Behavior on opacity { NumberAnimation { duration: 100; } }
} }
@ -430,8 +430,8 @@ QtObject
label: Label label: Label
{ {
text: control.text text: control.text
color: Theme.getColor("checkbox_text") color: UM.Theme.getColor("checkbox_text")
font: Theme.getFont("default") font: UM.Theme.getFont("default")
elide: Text.ElideRight elide: Text.ElideRight
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
@ -445,16 +445,16 @@ QtObject
background: Item { } background: Item { }
indicator: Rectangle indicator: Rectangle
{ {
implicitWidth: Theme.getSize("checkbox").width implicitWidth: UM.Theme.getSize("checkbox").width
implicitHeight: Theme.getSize("checkbox").height implicitHeight: UM.Theme.getSize("checkbox").height
color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox"); color: (control.hovered || control._hovered) ? UM.Theme.getColor("checkbox_hover") : UM.Theme.getColor("checkbox");
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width radius: control.exclusiveGroup ? Math.round(UM.Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width
border.width: Theme.getSize("default_lining").width; border.width: UM.Theme.getSize("default_lining").width;
border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border"); border.color: (control.hovered || control._hovered) ? UM.Theme.getColor("checkbox_border_hover") : UM.Theme.getColor("checkbox_border");
UM.RecolorImage UM.RecolorImage
{ {
@ -463,16 +463,16 @@ QtObject
width: Math.round(parent.width / 2.5) width: Math.round(parent.width / 2.5)
height: Math.round(parent.height / 2.5) height: Math.round(parent.height / 2.5)
sourceSize.height: width sourceSize.height: width
color: Theme.getColor("checkbox_mark") color: UM.Theme.getColor("checkbox_mark")
source: source:
{ {
if (control.checkbox_state == 2) if (control.checkbox_state == 2)
{ {
return Theme.getIcon("solid"); return UM.Theme.getIcon("solid");
} }
else else
{ {
return control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check"); return control.exclusiveGroup ? UM.Theme.getIcon("dot") : UM.Theme.getIcon("check");
} }
} }
opacity: control.checked opacity: control.checked
@ -482,8 +482,8 @@ QtObject
label: Label label: Label
{ {
text: control.text text: control.text
color: Theme.getColor("checkbox_text") color: UM.Theme.getColor("checkbox_text")
font: Theme.getFont("default") font: UM.Theme.getFont("default")
} }
} }
} }
@ -492,30 +492,30 @@ QtObject
{ {
TextFieldStyle TextFieldStyle
{ {
textColor: Theme.getColor("setting_control_text") textColor: UM.Theme.getColor("setting_control_text")
placeholderTextColor: Theme.getColor("setting_control_text") placeholderTextColor: UM.Theme.getColor("setting_control_text")
font: Theme.getFont("default") font: UM.Theme.getFont("default")
background: Rectangle background: Rectangle
{ {
implicitHeight: control.height; implicitHeight: control.height;
implicitWidth: control.width; implicitWidth: control.width;
border.width: Theme.getSize("default_lining").width; border.width: UM.Theme.getSize("default_lining").width;
border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border"); border.color: control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border");
radius: UM.Theme.getSize("setting_control_radius").width radius: UM.Theme.getSize("setting_control_radius").width
color: Theme.getColor("setting_validation_ok"); color: UM.Theme.getColor("setting_validation_ok");
Label Label
{ {
anchors.right: parent.right; anchors.right: parent.right;
anchors.rightMargin: Theme.getSize("setting_unit_margin").width; anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width;
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
text: control.unit ? control.unit : "" text: control.unit ? control.unit : ""
color: Theme.getColor("setting_unit"); color: UM.Theme.getColor("setting_unit");
font: Theme.getFont("default"); font: UM.Theme.getFont("default");
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
} }