Fix codestyle issues

Boyscouting
This commit is contained in:
Jaime van Kessel 2018-11-27 15:00:57 +01:00
parent 352bfb15ce
commit 4fab546425

View File

@ -15,23 +15,31 @@ Button
anchors.leftMargin: UM.Theme.getSize("thick_margin").width anchors.leftMargin: UM.Theme.getSize("thick_margin").width
anchors.rightMargin: UM.Theme.getSize("thick_margin").width anchors.rightMargin: UM.Theme.getSize("thick_margin").width
hoverEnabled: true hoverEnabled: true
background: Rectangle background: Rectangle
{ {
id: backgroundRectangle id: backgroundRectangle
implicitHeight: UM.Theme.getSize("section").height implicitHeight: UM.Theme.getSize("section").height
color: { color:
if (base.color) { {
return base.color; if (base.color)
} else if (!base.enabled) { {
return UM.Theme.getColor("setting_category_disabled"); return base.color
} else if (base.hovered && base.checkable && base.checked) { } else if (!base.enabled)
return UM.Theme.getColor("setting_category_active_hover"); {
} else if (base.pressed || (base.checkable && base.checked)) { return UM.Theme.getColor("setting_category_disabled")
return UM.Theme.getColor("setting_category_active"); } else if (base.hovered && base.checkable && base.checked)
} else if (base.hovered) { {
return UM.Theme.getColor("setting_category_hover"); return UM.Theme.getColor("setting_category_active_hover")
} else { } else if (base.pressed || (base.checkable && base.checked))
return UM.Theme.getColor("setting_category"); {
return UM.Theme.getColor("setting_category_active")
} else if (base.hovered)
{
return UM.Theme.getColor("setting_category_hover")
} else
{
return UM.Theme.getColor("setting_category")
} }
} }
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
@ -41,17 +49,23 @@ Button
height: UM.Theme.getSize("default_lining").height height: UM.Theme.getSize("default_lining").height
width: parent.width width: parent.width
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
color: { color:
if (!base.enabled) { {
return UM.Theme.getColor("setting_category_disabled_border"); if (!base.enabled)
} else if ((base.hovered || base.activeFocus) && base.checkable && base.checked) { {
return UM.Theme.getColor("setting_category_active_hover_border"); return UM.Theme.getColor("setting_category_disabled_border")
} else if (base.pressed || (base.checkable && base.checked)) { } else if ((base.hovered || base.activeFocus) && base.checkable && base.checked)
return UM.Theme.getColor("setting_category_active_border"); {
} else if (base.hovered || base.activeFocus) { return UM.Theme.getColor("setting_category_active_hover_border")
return UM.Theme.getColor("setting_category_hover_border"); } else if (base.pressed || (base.checkable && base.checked))
} else { {
return UM.Theme.getColor("setting_category_border"); return UM.Theme.getColor("setting_category_active_border")
} else if (base.hovered || base.activeFocus)
{
return UM.Theme.getColor("setting_category_hover_border")
} else
{
return UM.Theme.getColor("setting_category_border")
} }
} }
} }
@ -66,18 +80,19 @@ Button
property var focusItem: base property var focusItem: base
contentItem: Item { contentItem: Item
{
anchors.fill: parent anchors.fill: parent
anchors.left: parent.left
Label { Label
{
id: settingNameLabel id: settingNameLabel
anchors anchors
{ {
left: parent.left left: parent.left
leftMargin: 2 * UM.Theme.getSize("default_margin").width + UM.Theme.getSize("section_icon").width leftMargin: 2 * UM.Theme.getSize("default_margin").width + UM.Theme.getSize("section_icon").width
right: parent.right; right: parent.right
verticalCenter: parent.verticalCenter; verticalCenter: parent.verticalCenter
} }
text: definition.label text: definition.label
textFormat: Text.PlainText textFormat: Text.PlainText
@ -85,21 +100,27 @@ Button
font: UM.Theme.getFont("setting_category") font: UM.Theme.getFont("setting_category")
color: color:
{ {
if (!base.enabled) { if (!base.enabled)
return UM.Theme.getColor("setting_category_disabled_text"); {
} else if ((base.hovered || base.activeFocus) && base.checkable && base.checked) { return UM.Theme.getColor("setting_category_disabled_text")
return UM.Theme.getColor("setting_category_active_hover_text"); } else if ((base.hovered || base.activeFocus) && base.checkable && base.checked)
} else if (base.pressed || (base.checkable && base.checked)) { {
return UM.Theme.getColor("setting_category_active_text"); return UM.Theme.getColor("setting_category_active_hover_text")
} else if (base.hovered || base.activeFocus) { } else if (base.pressed || (base.checkable && base.checked))
return UM.Theme.getColor("setting_category_hover_text"); {
} else { return UM.Theme.getColor("setting_category_active_text")
return UM.Theme.getColor("setting_category_text"); } else if (base.hovered || base.activeFocus)
{
return UM.Theme.getColor("setting_category_hover_text")
} else
{
return UM.Theme.getColor("setting_category_text")
} }
} }
fontSizeMode: Text.HorizontalFit fontSizeMode: Text.HorizontalFit
minimumPointSize: 8 minimumPointSize: 8
} }
UM.RecolorImage UM.RecolorImage
{ {
id: category_arrow id: category_arrow
@ -112,16 +133,21 @@ Button
sourceSize.height: width sourceSize.height: width
color: color:
{ {
if (!base.enabled) { if (!base.enabled)
return UM.Theme.getColor("setting_category_disabled_text"); {
} else if ((base.hovered || base.activeFocus) && base.checkable && base.checked) { return UM.Theme.getColor("setting_category_disabled_text")
return UM.Theme.getColor("setting_category_active_hover_text"); } else if ((base.hovered || base.activeFocus) && base.checkable && base.checked)
} else if (base.pressed || (base.checkable && base.checked)) { {
return UM.Theme.getColor("setting_category_active_text"); return UM.Theme.getColor("setting_category_active_hover_text")
} else if (base.hovered || base.activeFocus) { } else if (base.pressed || (base.checkable && base.checked))
return UM.Theme.getColor("setting_category_hover_text"); {
} else { return UM.Theme.getColor("setting_category_active_text")
return UM.Theme.getColor("setting_category_text"); } else if (base.hovered || base.activeFocus)
{
return UM.Theme.getColor("setting_category_hover_text")
} else
{
return UM.Theme.getColor("setting_category_text")
} }
} }
source: base.checked ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") source: base.checked ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
@ -136,21 +162,26 @@ Button
anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.leftMargin: UM.Theme.getSize("default_margin").width
color: color:
{ {
if (!base.enabled) { if (!base.enabled)
return UM.Theme.getColor("setting_category_disabled_text"); {
} else if((base.hovered || base.activeFocus) && base.checkable && base.checked) { return UM.Theme.getColor("setting_category_disabled_text")
return UM.Theme.getColor("setting_category_active_hover_text"); } else if((base.hovered || base.activeFocus) && base.checkable && base.checked)
} else if(base.pressed || (base.checkable && base.checked)) { {
return UM.Theme.getColor("setting_category_active_text"); return UM.Theme.getColor("setting_category_active_hover_text")
} else if(base.hovered || base.activeFocus) { } else if(base.pressed || (base.checkable && base.checked))
return UM.Theme.getColor("setting_category_hover_text"); {
} else { return UM.Theme.getColor("setting_category_active_text")
return UM.Theme.getColor("setting_category_text"); } else if(base.hovered || base.activeFocus)
{
return UM.Theme.getColor("setting_category_hover_text")
} else
{
return UM.Theme.getColor("setting_category_text")
} }
} }
source: UM.Theme.getIcon(definition.icon) source: UM.Theme.getIcon(definition.icon)
width: UM.Theme.getSize("section_icon").width; width: UM.Theme.getSize("section_icon").width
height: UM.Theme.getSize("section_icon").height; height: UM.Theme.getSize("section_icon").height
sourceSize.width: width + 15 * screenScaleFactor sourceSize.width: width + 15 * screenScaleFactor
sourceSize.height: width + 15 * screenScaleFactor sourceSize.height: width + 15 * screenScaleFactor
} }
@ -160,31 +191,26 @@ Button
onClicked: onClicked:
{ {
if (definition.expanded) { if (definition.expanded)
settingDefinitionsModel.collapse(definition.key); {
settingDefinitionsModel.collapse(definition.key)
} else { } else {
settingDefinitionsModel.expandRecursive(definition.key); settingDefinitionsModel.expandRecursive(definition.key)
} }
//Set focus so that tab navigation continues from this point on. //Set focus so that tab navigation continues from this point on.
//NB: This must be set AFTER collapsing/expanding the category so that the scroll position is correct. //NB: This must be set AFTER collapsing/expanding the category so that the scroll position is correct.
forceActiveFocus(); forceActiveFocus()
} }
onActiveFocusChanged: onActiveFocusChanged:
{ {
if(activeFocus) if(activeFocus)
{ {
base.focusReceived(); base.focusReceived()
} }
} }
Keys.onTabPressed: Keys.onTabPressed: base.setActiveFocusToNextSetting(true)
{ Keys.onBacktabPressed: base.setActiveFocusToNextSetting(false)
base.setActiveFocusToNextSetting(true)
}
Keys.onBacktabPressed:
{
base.setActiveFocusToNextSetting(false)
}
UM.SimpleButton UM.SimpleButton
{ {
@ -194,9 +220,10 @@ Button
height: Math.round(base.height * 0.6) height: Math.round(base.height * 0.6)
width: Math.round(base.height * 0.6) width: Math.round(base.height * 0.6)
anchors { anchors
{
right: inheritButton.visible ? inheritButton.left : parent.right right: inheritButton.visible ? inheritButton.left : parent.right
// use 1.9 as the factor because there is a 0.1 difference between the settings and inheritance warning icons // Use 1.9 as the factor because there is a 0.1 difference between the settings and inheritance warning icons
rightMargin: inheritButton.visible ? Math.round(UM.Theme.getSize("default_margin").width / 2) : category_arrow.width + Math.round(UM.Theme.getSize("default_margin").width * 1.9) rightMargin: inheritButton.visible ? Math.round(UM.Theme.getSize("default_margin").width / 2) : category_arrow.width + Math.round(UM.Theme.getSize("default_margin").width * 1.9)
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
@ -205,9 +232,7 @@ Button
hoverColor: UM.Theme.getColor("setting_control_button_hover") hoverColor: UM.Theme.getColor("setting_control_button_hover")
iconSource: UM.Theme.getIcon("settings") iconSource: UM.Theme.getIcon("settings")
onClicked: { onClicked: Cura.Actions.configureSettingVisibility.trigger(definition)
Cura.Actions.configureSettingVisibility.trigger(definition)
}
} }
UM.SimpleButton UM.SimpleButton
@ -240,24 +265,18 @@ Button
onClicked: onClicked:
{ {
settingDefinitionsModel.expandRecursive(definition.key); settingDefinitionsModel.expandRecursive(definition.key)
base.checked = true; base.checked = true
base.showAllHiddenInheritedSettings(definition.key); base.showAllHiddenInheritedSettings(definition.key)
} }
color: UM.Theme.getColor("setting_control_button") color: UM.Theme.getColor("setting_control_button")
hoverColor: UM.Theme.getColor("setting_control_button_hover") hoverColor: UM.Theme.getColor("setting_control_button_hover")
iconSource: UM.Theme.getIcon("notice") iconSource: UM.Theme.getIcon("notice")
onEntered: onEntered: base.showTooltip(catalog.i18nc("@label","Some hidden settings use values different from their normal calculated value.\n\nClick to make these settings visible."))
{
base.showTooltip(catalog.i18nc("@label","Some hidden settings use values different from their normal calculated value.\n\nClick to make these settings visible."))
}
onExited: onExited: base.hideTooltip()
{
base.hideTooltip();
}
UM.I18nCatalog { id: catalog; name: "cura" } UM.I18nCatalog { id: catalog; name: "cura" }
} }