diff options
Diffstat (limited to 'src/imports/controls/ItemDelegate.qml')
-rw-r--r-- | src/imports/controls/ItemDelegate.qml | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/src/imports/controls/ItemDelegate.qml b/src/imports/controls/ItemDelegate.qml index b5dfb4b6..519ef3bf 100644 --- a/src/imports/controls/ItemDelegate.qml +++ b/src/imports/controls/ItemDelegate.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,29 +35,24 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.templates 1.0 as T +import QtQuick.Templates 2.0 as T T.ItemDelegate { 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: 12 spacing: 12 - //! [label] - label: Text { - x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding - y: control.topPadding - width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0) - height: control.availableHeight + contentItem: Text { + leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 text: control.text font: control.font @@ -67,24 +62,11 @@ T.ItemDelegate { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - //! [label] - //! [indicator] - indicator: Image { - x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding - y: control.topPadding + (control.availableHeight - height) / 2 - - visible: control.checked - source: control.checkable ? "qrc:/qt-project.org/imports/Qt/labs/controls/images/check.png" : "" - } - //! [indicator] - - //! [background] background: Rectangle { implicitWidth: 100 implicitHeight: 40 - visible: control.pressed || control.highlighted - color: control.pressed ? "#bdbebf" : "#eeeeee" + visible: control.down || control.highlighted || control.visualFocus + color: control.visualFocus ? (control.pressed ? "#cce0ff" : "#e5efff") : (control.down ? "#bdbebf" : "#eeeeee") } - //! [background] } |