From e8f1c609bf612c39bd45778bd22b693c39e3d059 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 29 Jan 2016 19:37:45 +0100 Subject: CheckBox: support partially checked state for Default & Universal Change-Id: Id2614c2f441718ef21445ef42c7d64ff64e072ce Task-number: QTBUG-49961 Reviewed-by: J-P Nurmi --- src/imports/controls/CheckBox.qml | 11 ++++++++++- src/imports/controls/material/CheckBox.qml | 22 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index 20d8ef1c..4b7af3b1 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -67,7 +67,16 @@ T.CheckBox { x: (parent.width - width) / 2 y: (parent.height - height) / 2 source: "qrc:/qt-project.org/imports/Qt/labs/controls/images/check.png" - visible: control.checked + visible: control.checkState === Qt.Checked + } + + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: 16 + height: 3 + color: "#353637" + visible: control.checkState === Qt.PartiallyChecked } } //! [indicator] diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml index 1c3e254b..5becfc5c 100644 --- a/src/imports/controls/material/CheckBox.qml +++ b/src/imports/controls/material/CheckBox.qml @@ -100,15 +100,29 @@ T.CheckBox { source: "qrc:/qt-project.org/imports/Qt/labs/controls/material/images/check.png" fillMode: Image.PreserveAspectFit - scale: control.checked ? 1 : 0 + scale: control.checkState === Qt.Checked ? 1 : 0 Behavior on scale { NumberAnimation { duration: 100 } } } - states: State { - name: "checked" - when: control.checked + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: 12 + height: 3 + visible: control.checkState === Qt.PartiallyChecked } + states: [ + State { + name: "checked" + when: control.checkState === Qt.Checked + }, + State { + name: "partiallychecked" + when: control.checkState === Qt.PartiallyChecked + } + ] + transitions: Transition { SequentialAnimation { NumberAnimation { -- cgit v1.2.3