aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls/SwitchDelegate.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/controls/SwitchDelegate.qml')
-rw-r--r--src/imports/controls/SwitchDelegate.qml58
1 files changed, 45 insertions, 13 deletions
diff --git a/src/imports/controls/SwitchDelegate.qml b/src/imports/controls/SwitchDelegate.qml
index 49e0fad2..08a9d641 100644
--- a/src/imports/controls/SwitchDelegate.qml
+++ b/src/imports/controls/SwitchDelegate.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.9
-import QtQuick.Templates 2.2 as T
-import QtQuick.Controls 2.2
-import QtQuick.Controls.impl 2.2
+import QtQuick 2.10
+import QtQuick.Templates 2.3 as T
+import QtQuick.Controls 2.3
+import QtQuick.Controls.impl 2.3
T.SwitchDelegate {
id: control
@@ -52,27 +52,59 @@ T.SwitchDelegate {
padding: 12
spacing: 12
- indicator: SwitchIndicator {
+ icon.width: 24
+ icon.height: 24
+ icon.color: control.palette.text
+
+ indicator: PaddedRectangle {
+ implicitWidth: 56
+ implicitHeight: 28
+
x: text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2
y: control.topPadding + (control.availableHeight - height) / 2
- control: control
+
+ radius: 8
+ leftPadding: 0
+ rightPadding: 0
+ padding: (height - 16) / 2
+ color: control.checked ? control.palette.dark : control.palette.midlight
+
+ Rectangle {
+ x: Math.max(0, Math.min(parent.width - width, control.visualPosition * parent.width - (width / 2)))
+ y: (parent.height - height) / 2
+ width: 28
+ height: 28
+ radius: 16
+ color: control.down ? control.palette.light : control.palette.window
+ border.width: control.visualFocus ? 2 : 1
+ border.color: control.visualFocus ? control.palette.highlight : control.enabled ? control.palette.mid : control.palette.midlight
+
+ Behavior on x {
+ enabled: !control.down
+ SmoothedAnimation { velocity: 200 }
+ }
+ }
}
- contentItem: Text {
- leftPadding: control.indicator && !control.mirrored ? 0 : control.indicator.width + control.spacing
- rightPadding: control.indicator && control.mirrored ? 0 : control.indicator.width + control.spacing
+ contentItem: IconLabel {
+ leftPadding: control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: !control.mirrored ? control.indicator.width + control.spacing : 0
+
+ spacing: control.spacing
+ mirrored: control.mirrored
+ display: control.display
+ alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
+ icon: control.icon
text: control.text
font: control.font
- color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
- elide: Text.ElideRight
- verticalAlignment: Text.AlignVCenter
+ color: control.palette.text
}
background: Rectangle {
implicitWidth: 100
implicitHeight: 40
visible: control.down || control.highlighted
- color: control.down ? Default.delegatePressedColor : Default.delegateColor
+ color: control.down ? control.palette.midlight : control.palette.light
}
}