From 1acb34a40ea0fbc0c0730cdc81dcfd46bdeb4ef7 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 29 Mar 2016 18:26:16 +0200 Subject: Add CheckDelegate CheckDelegate is an item delegate that is used in lists, and can be checked and unchecked. It derives from QQuickItemDelegate and hence has background press effects. The order of the indicator and text is reversed (compared to CheckBox) to reflect what is most commonly seen on mobile. Change-Id: I6fdac226fe87247052389b2e49f6cf20d7be44fb Task-number: QTBUG-52208 Reviewed-by: J-P Nurmi --- src/imports/controls/CheckBox.qml | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'src/imports/controls/CheckBox.qml') diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index f6f62ed3..fd0b5f8b 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -36,6 +36,7 @@ import QtQuick 2.6 import Qt.labs.templates 1.0 as T +import Qt.labs.controls.impl 1.0 T.CheckBox { id: control @@ -52,31 +53,10 @@ T.CheckBox { opacity: enabled ? 1 : 0.2 //! [indicator] - indicator: Rectangle { - implicitWidth: 28 - implicitHeight: 28 + indicator: CheckIndicator { x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 - - color: control.enabled ? (control.pressed ? (control.activeKeyFocus ? "#cce0ff" : "#e4e4e4") : "#f6f6f6") : "#353637" - border.width: control.activeKeyFocus ? 2 : 1 - border.color: control.enabled ? (control.activeKeyFocus ? "#0066ff" : (control.pressed ? "#26282a" : "#353637")) : "transparent" - - Image { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - source: "qrc:/qt-project.org/imports/Qt/labs/controls/images/check" + (control.activeKeyFocus ? "-focus.png" : ".png") - visible: control.checkState === Qt.Checked - } - - Rectangle { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - width: 16 - height: 3 - color: control.activeKeyFocus ? "#0066ff" : "#353637" - visible: control.checkState === Qt.PartiallyChecked - } + control: control } //! [indicator] -- cgit v1.2.3