fix(StatusSwitch): Colors adjusted when disabled, cursor shape fixed
Closes: #9212
This commit is contained in:
parent
3136ffb54d
commit
14eb06b158
|
@ -1,4 +1,4 @@
|
||||||
import QtQuick 2.12
|
import QtQuick 2.14
|
||||||
import QtQuick.Controls 2.14
|
import QtQuick.Controls 2.14
|
||||||
import QtGraphicalEffects 1.14
|
import QtGraphicalEffects 1.14
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
|
@ -6,18 +6,29 @@ import StatusQ.Core.Theme 0.1
|
||||||
import StatusQ.Components 0.1
|
import StatusQ.Components 0.1
|
||||||
|
|
||||||
Switch {
|
Switch {
|
||||||
id: statusSwitch
|
id: root
|
||||||
|
|
||||||
indicator: Rectangle {
|
background: MouseArea {
|
||||||
|
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
}
|
||||||
|
|
||||||
|
indicator: Item {
|
||||||
id: oval
|
id: oval
|
||||||
|
|
||||||
implicitWidth: 52
|
implicitWidth: 52
|
||||||
implicitHeight: 28
|
implicitHeight: 28
|
||||||
x: statusSwitch.leftPadding
|
x: root.leftPadding
|
||||||
y: parent.height / 2 - height / 2
|
y: parent.height / 2 - height / 2
|
||||||
radius: 14
|
|
||||||
color: statusSwitch.checked ? Theme.palette.primaryColor1
|
|
||||||
: Theme.palette.directColor8
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
radius: 14
|
||||||
|
color: root.checked ? Theme.palette.primaryColor1
|
||||||
|
: Theme.palette.directColor8
|
||||||
|
opacity: root.enabled ? 1 : 0.2
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: circle
|
id: circle
|
||||||
|
@ -40,12 +51,12 @@ Switch {
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
name: "on"
|
name: "on"
|
||||||
when: statusSwitch.checked
|
when: root.checked
|
||||||
PropertyChanges { target: circle; x: oval.width - circle.width - 4 }
|
PropertyChanges { target: circle; x: oval.width - circle.width - 4 }
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "off"
|
name: "off"
|
||||||
when: !statusSwitch.checked
|
when: !root.checked
|
||||||
PropertyChanges { target: circle; x: 4 }
|
PropertyChanges { target: circle; x: 4 }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -58,9 +69,10 @@ Switch {
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: StatusBaseText {
|
contentItem: StatusBaseText {
|
||||||
text: statusSwitch.text
|
text: root.text
|
||||||
opacity: enabled ? 1.0 : 0.3
|
opacity: enabled ? 1.0 : 0.3
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
leftPadding: !!statusSwitch.text ? statusSwitch.indicator.width + statusSwitch.spacing : statusSwitch.indicator.width
|
leftPadding: !!root.text ? root.indicator.width + root.spacing
|
||||||
|
: root.indicator.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue