diff options
Diffstat (limited to 'src/imports/controls/material/MenuItem.qml')
-rw-r--r-- | src/imports/controls/material/MenuItem.qml | 108 |
1 files changed, 18 insertions, 90 deletions
diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml index 89867e15..27c2922c 100644 --- a/src/imports/controls/material/MenuItem.qml +++ b/src/imports/controls/material/MenuItem.qml @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** -** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL3$ ** Commercial License Usage @@ -35,105 +35,35 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.templates 1.0 as T -import Qt.labs.controls.material 1.0 +import QtQuick.Templates 2.0 as T +import QtQuick.Controls.Material 2.0 +import QtQuick.Controls.Material.impl 2.0 T.MenuItem { id: control implicitWidth: Math.max(background ? background.implicitWidth : 0, - (label ? label.implicitWidth : 0) + - (indicator ? indicator.implicitWidth : 0) + - (label && indicator ? spacing : 0) + leftPadding + rightPadding) + contentItem.implicitWidth + leftPadding + rightPadding) implicitHeight: Math.max(background ? background.implicitHeight : 0, - Math.max(label ? label.implicitHeight : 0, + Math.max(contentItem.implicitHeight, indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) - baselineOffset: label ? label.y + label.baselineOffset : 0 + baselineOffset: contentItem.y + contentItem.baselineOffset padding: 16 + topPadding: 12 + bottomPadding: 12 spacing: 16 - //! [indicator] - indicator: Rectangle { - id: indicatorItem + 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 - 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 - } - } - } + control: control } - //! [indicator] - //! [label] - label: Text { - x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing) - y: control.topPadding - width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0) - height: control.availableHeight + contentItem: Text { + leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0 text: control.text font: control.font @@ -143,13 +73,11 @@ T.MenuItem { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - //! [label] - //! [background] background: Rectangle { implicitWidth: 200 - visible: control.pressed || control.highlighted - color: control.pressed ? control.Material.flatButtonPressColor : control.Material.listHighlightColor + implicitHeight: 48 + visible: control.down || control.highlighted + color: control.down ? control.Material.buttonPressColor : control.Material.listHighlightColor } - //! [background] } |