diff options
Diffstat (limited to 'src/imports/controls/universal/ComboBox.qml')
-rw-r--r-- | src/imports/controls/universal/ComboBox.qml | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 31a928a3..bb816fc1 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.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 @@ -36,8 +36,9 @@ import QtQuick 2.6 import QtQuick.Window 2.2 -import Qt.labs.templates 1.0 as T -import Qt.labs.controls.universal 1.0 +import QtQuick.Controls 2.0 +import QtQuick.Templates 2.0 as T +import QtQuick.Controls.Universal 2.0 T.ComboBox { id: control @@ -45,37 +46,44 @@ T.ComboBox { implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding) implicitHeight: Math.max(background ? background.implicitHeight : 0, - contentItem.implicitHeight + topPadding + bottomPadding) + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset spacing: 10 - topPadding: 5 - leftPadding: 12 - rightPadding: 10 - bottomPadding: 7 + padding: 12 + topPadding: padding - 7 + rightPadding: padding - 2 + bottomPadding: padding - 5 - //! [delegate] delegate: ItemDelegate { - width: control.width + width: control.popup.width text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData highlighted: control.highlightedIndex === index - pressed: highlighted && control.pressed } - //! [delegate] - //! [contentItem] + indicator: Image { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + source: "image://universal/downarrow/" + (!control.enabled ? control.Universal.baseLowColor : control.Universal.baseMediumHighColor) + sourceSize.width: width + sourceSize.height: height + } + contentItem: Text { + leftPadding: control.mirrored && control.indicator ? control.indicator.width + control.spacing : 0 + rightPadding: !control.mirrored && control.indicator ? control.indicator.width + control.spacing : 0 + text: control.displayText font: control.font - color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight - rightPadding: 12 + control.spacing + + opacity: enabled ? 1.0 : 0.2 + color: control.Universal.foreground } - //! [contentItem] - //! [background] background: Rectangle { implicitWidth: 120 implicitHeight: 32 @@ -92,24 +100,15 @@ T.ComboBox { width: parent.width - 4 height: parent.height - 4 - visible: control.activeFocus && (control.focusReason === Qt.TabFocusReason || control.focusReason === Qt.BacktabFocusReason) + visible: control.visualFocus color: control.Universal.accent opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6 } - - Image { - id: checkmark - x: parent.width - width - control.rightPadding - y: (parent.height - height) / 2 - source: "image://universal/downarrow/" + (!control.enabled ? control.Universal.baseLowColor : control.Universal.baseMediumHighColor) - } } - //! [background] - //! [popup] popup: T.Popup { - implicitWidth: control.width - implicitHeight: Math.min(396, listview.contentHeight) + width: control.width + implicitHeight: Math.min(396, contentItem.implicitHeight) topMargin: 8 bottomMargin: 8 @@ -117,10 +116,12 @@ T.ComboBox { Universal.accent: control.Universal.accent contentItem: ListView { - id: listview clip: true + implicitHeight: contentHeight model: control.popup.visible ? control.delegateModel : null currentIndex: control.highlightedIndex + highlightRangeMode: ListView.ApplyRange + highlightMoveDuration: 0 T.ScrollIndicator.vertical: ScrollIndicator { } } @@ -131,5 +132,4 @@ T.ComboBox { border.width: 1 // FlyoutBorderThemeThickness } } - //! [popup] } |