2023-11-30 18:28:55 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2022-05-13 13:12:05 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2020-03-26 16:01:51 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Templates as T
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2017-03-13 07:42:48 +00:00
|
|
|
T.Switch {
|
2016-12-17 03:20:45 +00:00
|
|
|
id: control
|
|
|
|
|
2023-11-30 18:28:55 +00:00
|
|
|
implicitWidth: 64
|
|
|
|
implicitHeight: 34
|
2017-03-13 07:42:48 +00:00
|
|
|
|
2016-12-17 03:20:45 +00:00
|
|
|
indicator: Rectangle {
|
2023-11-30 18:28:55 +00:00
|
|
|
x: 2 + control.visualPosition * (control.width - width - 4)
|
2017-03-13 07:42:48 +00:00
|
|
|
y: (control.height - height) / 2
|
2023-11-30 18:28:55 +00:00
|
|
|
width: height
|
|
|
|
height: parent.height - 4
|
|
|
|
radius: height / 2
|
|
|
|
|
|
|
|
color: control.down ? UIStyle.buttonGrayPressed : UIStyle.buttonGray
|
|
|
|
border.color: UIStyle.buttonGrayOutLine
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
radius: parent.radius
|
|
|
|
gradient: Gradient {
|
|
|
|
GradientStop { position: 0.0; color: UIStyle.gradientOverlay1 }
|
|
|
|
GradientStop { position: 1.0; color: UIStyle.gradientOverlay2 }
|
|
|
|
}
|
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
|
2017-03-13 07:42:48 +00:00
|
|
|
Behavior on x {
|
|
|
|
enabled: !control.pressed
|
|
|
|
SmoothedAnimation { velocity: 200 }
|
2016-12-17 03:20:45 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-13 07:42:48 +00:00
|
|
|
|
|
|
|
background: Rectangle {
|
2023-11-30 18:28:55 +00:00
|
|
|
radius: 17
|
|
|
|
color: control.checked ? UIStyle.buttonProgress : UIStyle.buttonBackground
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
radius: parent.radius
|
|
|
|
gradient: Gradient {
|
|
|
|
GradientStop { position: 0.0; color: UIStyle.gradientOverlay1 }
|
|
|
|
GradientStop { position: 1.0; color: UIStyle.gradientOverlay2 }
|
|
|
|
}
|
|
|
|
}
|
2017-03-13 07:42:48 +00:00
|
|
|
}
|
2016-12-17 03:20:45 +00:00
|
|
|
}
|
2017-03-13 07:42:48 +00:00
|
|
|
|