Fix codestyle and change faux-"hovered" property mechanism

hovered_ex was a bool property that was set in onEntered and onExited, and has been replaced with an alias to the mouseArea.containsMouse that necessitated the clutch.

CURA-790
This commit is contained in:
fieldOfView 2016-06-01 22:21:12 +02:00
parent ffa6a0376d
commit c6dd9d2c8c
2 changed files with 28 additions and 31 deletions

View File

@ -85,7 +85,7 @@ Item
{ {
return UM.Theme.getColor("setting_control_selected") return UM.Theme.getColor("setting_control_selected")
} }
else if(mousearea.containsMouse) else if(infillMouseArea.containsMouse)
{ {
return UM.Theme.getColor("setting_control_border_highlight") return UM.Theme.getColor("setting_control_border_highlight")
} }
@ -106,7 +106,7 @@ Item
} }
MouseArea { MouseArea {
id: mousearea id: infillMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: { onClicked: {
@ -196,7 +196,7 @@ Item
CheckBox{ CheckBox{
id: brimCheckBox id: brimCheckBox
property bool hovered_ex: false property alias _hovered: brimMouseArea.containsMouse
anchors.top: parent.top anchors.top: parent.top
anchors.left: adhesionHelperLabel.right anchors.left: adhesionHelperLabel.right
@ -209,6 +209,7 @@ Item
checked: platformAdhesionType.properties.value == "brim" checked: platformAdhesionType.properties.value == "brim"
MouseArea { MouseArea {
id: brimMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: onClicked:
@ -217,13 +218,11 @@ Item
} }
onEntered: onEntered:
{ {
parent.hovered_ex = true
base.showTooltip(brimCheckBox, Qt.point(-brimCheckBox.x, 0), base.showTooltip(brimCheckBox, Qt.point(-brimCheckBox.x, 0),
catalog.i18nc("@label", "Enable printing a brim. This will add a single-layer-thick flat area around your object which is easy to cut off afterwards.")); catalog.i18nc("@label", "Enable printing a brim. This will add a single-layer-thick flat area around your object which is easy to cut off afterwards."));
} }
onExited: onExited:
{ {
parent.hovered_ex = false
base.hideTooltip(); base.hideTooltip();
} }
} }
@ -244,7 +243,7 @@ Item
CheckBox{ CheckBox{
id: supportCheckBox id: supportCheckBox
visible: machineExtruderCount.properties.value <= 1 visible: machineExtruderCount.properties.value <= 1
property bool hovered_ex: false property alias _hovered: supportMouseArea.containsMouse
anchors.top: brimCheckBox.bottom anchors.top: brimCheckBox.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.topMargin: UM.Theme.getSize("default_margin").height
@ -257,6 +256,7 @@ Item
checked: supportEnabled.properties.value == "True" checked: supportEnabled.properties.value == "True"
MouseArea { MouseArea {
id: supportMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: onClicked:
@ -265,13 +265,11 @@ Item
} }
onEntered: onEntered:
{ {
parent.hovered_ex = true
base.showTooltip(supportCheckBox, Qt.point(-supportCheckBox.x, 0), base.showTooltip(supportCheckBox, Qt.point(-supportCheckBox.x, 0),
catalog.i18nc("@label", "Enable printing support structures. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); catalog.i18nc("@label", "Enable printing support structures. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air."));
} }
onExited: onExited:
{ {
parent.hovered_ex = false
base.hideTooltip(); base.hideTooltip();
} }
} }
@ -289,7 +287,7 @@ Item
width: parent.width / 100 * 45 width: parent.width / 100 * 45
style: UM.Theme.styles.combobox style: UM.Theme.styles.combobox
property bool hovered_ex: false property alias _hovered: supportExtruderMouseArea.containsMouse
currentIndex: supportEnabled.properties.value == "True" ? parseFloat(supportExtruderNr.properties.value) + 1 : 0 currentIndex: supportEnabled.properties.value == "True" ? parseFloat(supportExtruderNr.properties.value) + 1 : 0
onActivated: { onActivated: {
@ -301,18 +299,17 @@ Item
} }
} }
MouseArea { MouseArea {
id: supportExtruderMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
onEntered: onEntered:
{ {
parent.hovered_ex = true
base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0),
catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air."));
} }
onExited: onExited:
{ {
parent.hovered_ex = false
base.hideTooltip(); base.hideTooltip();
} }
} }

View File

@ -283,14 +283,14 @@ QtObject {
property Component combobox: Component { property Component combobox: Component {
ComboBoxStyle { ComboBoxStyle {
background: Rectangle { background: Rectangle {
implicitHeight: UM.Theme.getSize("setting_control").height; implicitHeight: Theme.getSize("setting_control").height;
implicitWidth: UM.Theme.getSize("setting_control").width; implicitWidth: Theme.getSize("setting_control").width;
color: (control.hovered || control.hovered_ex) ? Theme.getColor("setting_control_highlight") : Theme.getColor("setting_control"); color: (control.hovered || control._hovered) ? Theme.getColor("setting_control_highlight") : 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: Theme.getSize("default_lining").width;
border.color: (control.hovered || control.hovered_ex) ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border"); border.color: (control.hovered || control._hovered) ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
} }
label: Item { label: Item {
Label { Label {
@ -301,7 +301,7 @@ QtObject {
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
text: control.currentText; text: control.currentText;
font: UM.Theme.getFont("default"); font: Theme.getFont("default");
color: !enabled ? Theme.getColor("setting_control_disabled_text") : Theme.getColor("setting_control_text"); color: !enabled ? Theme.getColor("setting_control_disabled_text") : Theme.getColor("setting_control_text");
elide: Text.ElideRight; elide: Text.ElideRight;
@ -314,9 +314,9 @@ QtObject {
anchors.rightMargin: Theme.getSize("default_lining").width * 2; anchors.rightMargin: Theme.getSize("default_lining").width * 2;
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
source: UM.Theme.getIcon("arrow_bottom") source: Theme.getIcon("arrow_bottom")
width: UM.Theme.getSize("standard_arrow").width width: Theme.getSize("standard_arrow").width
height: UM.Theme.getSize("standard_arrow").height height: Theme.getSize("standard_arrow").height
sourceSize.width: width + 5 sourceSize.width: width + 5
sourceSize.height: width + 5 sourceSize.height: width + 5
@ -333,13 +333,13 @@ QtObject {
implicitWidth: Theme.getSize("checkbox").width; implicitWidth: Theme.getSize("checkbox").width;
implicitHeight: Theme.getSize("checkbox").height; implicitHeight: Theme.getSize("checkbox").height;
color: (control.hovered || control.hovered_ex) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox"); color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox");
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
radius: control.exclusiveGroup ? Theme.getSize("checkbox").width / 2 : 0 radius: control.exclusiveGroup ? Theme.getSize("checkbox").width / 2 : 0
border.width: Theme.getSize("default_lining").width; border.width: Theme.getSize("default_lining").width;
border.color: (control.hovered || control.hovered_ex) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border"); border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border");
UM.RecolorImage { UM.RecolorImage {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter