styled switch
This commit is contained in:
parent
b75a2a12c7
commit
41fe72522b
2 changed files with 39 additions and 0 deletions
38
components/StyledSwitch.qml
Normal file
38
components/StyledSwitch.qml
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
import qs.config
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: control
|
||||||
|
indicator: Item {
|
||||||
|
implicitWidth: 48
|
||||||
|
implicitHeight: 26
|
||||||
|
Rectangle {
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: parent.height - 4
|
||||||
|
x: control.leftPadding
|
||||||
|
y: parent.height / 2 - height / 2
|
||||||
|
radius: 8
|
||||||
|
color: control.checked ? Theme.palette.primary : Theme.palette.base100
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: 150
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
x: control.checked ? parent.width - 3 * width / 4 : width / 4
|
||||||
|
y: parent.height / 2 - height / 2
|
||||||
|
Behavior on x {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 150
|
||||||
|
}
|
||||||
|
}
|
||||||
|
width: 26
|
||||||
|
height: 26
|
||||||
|
radius: 8
|
||||||
|
color: Theme.palette.basecontent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -41,6 +41,7 @@ StyledWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
StyledSwitch {}
|
||||||
Button {
|
Button {
|
||||||
id: toolTipButton
|
id: toolTipButton
|
||||||
text: "Hello world!"
|
text: "Hello world!"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue