diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-12 14:08:28 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-19 09:39:53 +0000 |
commit | 65247c0bbd340f4be89e0ae284b865fd8ba235ce (patch) | |
tree | a4c5b04f1c52b1f5ebf3130d450d8c1cbc863871 /src/imports/controls/universal/SwitchDelegate.qml | |
parent | ce0a6e5d78fa6edca573e5d48b5448647ba7642d (diff) |
SwitchDelegate: add support for icons
Task-number: QTBUG-49820
Change-Id: I9cafe09ae56afa14a55748e13405dd0364f9dcb2
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/controls/universal/SwitchDelegate.qml')
-rw-r--r-- | src/imports/controls/universal/SwitchDelegate.qml | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/imports/controls/universal/SwitchDelegate.qml b/src/imports/controls/universal/SwitchDelegate.qml index 49482d05..af7f403e 100644 --- a/src/imports/controls/universal/SwitchDelegate.qml +++ b/src/imports/controls/universal/SwitchDelegate.qml @@ -36,6 +36,8 @@ import QtQuick 2.9 import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 import QtQuick.Controls.Universal 2.3 T.SwitchDelegate { @@ -54,25 +56,29 @@ T.SwitchDelegate { topPadding: padding - 1 bottomPadding: padding + 1 + icon.width: 20 + icon.height: 20 + icon.color: enabled ? undefined : Color.transparent(Universal.foreground, 0.2) + indicator: SwitchIndicator { 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 } - contentItem: Text { + contentItem: IconLabel { leftPadding: !control.mirrored ? 0 : control.indicator.width + control.spacing rightPadding: control.mirrored ? 0 : control.indicator.width + control.spacing + 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 - elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - - opacity: enabled ? 1.0 : 0.2 - color: control.Universal.foreground + color: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2) } background: Rectangle { |