diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2016-02-29 15:56:03 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-04-13 09:07:38 +0000 |
commit | 7a8f055c6ee274292f2585f59ff6bac4383d6b01 (patch) | |
tree | 4c7b3537d40c8dd50284e21622d36d28db67d501 /src/imports/controls/material/ItemDelegate.qml | |
parent | 4ae3a828ad972e24802ea711fc12e12883cc28be (diff) |
Expose checkable where necessary, instead of in QQuickAbstractButton
QQuickCheckBox, QQuickRadioButton and QQuickSwitch are inherently
checkable, so having this property available to QML doesn't make
sense.
QQuickButton and QQuickMenuItem are the two classes that need
to expose the property.
Change-Id: Ic421c195295c4bef0fc934c98fa9e781d98c9b67
Task-number: QTBUG-51554
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports/controls/material/ItemDelegate.qml')
-rw-r--r-- | src/imports/controls/material/ItemDelegate.qml | 80 |
1 files changed, 2 insertions, 78 deletions
diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml index 132cce3d..e3ec6bd9 100644 --- a/src/imports/controls/material/ItemDelegate.qml +++ b/src/imports/controls/material/ItemDelegate.qml @@ -37,7 +37,6 @@ import QtQuick 2.6 import Qt.labs.templates 1.0 as T import Qt.labs.controls.material 1.0 -import Qt.labs.controls.material.impl 1.0 T.ItemDelegate { id: control @@ -52,85 +51,10 @@ T.ItemDelegate { padding: 16 spacing: 16 - //! [indicator] - indicator: Rectangle { - id: indicatorItem - x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 - y: control.topPadding + (control.availableHeight - height) / 2 - implicitWidth: 20 - implicitHeight: 20 - color: "transparent" - border.color: control.checked ? control.Material.accentColor : control.Material.secondaryTextColor - border.width: control.checked ? width / 2 : 2 - radius: 2 - - visible: control.checkable - - Behavior on border.width { - NumberAnimation { - duration: 100 - easing.type: Easing.OutCubic - } - } - - Behavior on border.color { - ColorAnimation { - duration: 100 - easing.type: Easing.OutCubic - } - } - - Ripple { - width: parent.width - height: width - control: control - colored: control.checked - opacity: control.pressed ? 1 : 0 - } - - // TODO: This needs to be transparent - Image { - id: checkImage - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - width: 16 - height: 16 - source: "qrc:/qt-project.org/imports/Qt/labs/controls/material/images/check.png" - fillMode: Image.PreserveAspectFit - - scale: control.checked ? 1 : 0 - Behavior on scale { NumberAnimation { duration: 100 } } - } - - states: State { - name: "checked" - when: control.checked - } - - transitions: Transition { - SequentialAnimation { - NumberAnimation { - target: indicatorItem - property: "scale" - // Go down 2 pixels in size. - to: 1 - 2 / indicatorItem.width - duration: 120 - } - NumberAnimation { - target: indicatorItem - property: "scale" - to: 1 - duration: 120 - } - } - } - } - //! [indicator] - //! [contentItem] contentItem: Text { - leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0 - rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0 + leftPadding: control.checkable && !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + rightPadding: control.checkable && control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 text: control.text font: control.font |