diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-04-28 12:37:58 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-04-28 11:56:14 +0000 |
commit | c6e700d59a66ee648548a93fc7235e06423216cb (patch) | |
tree | 2a0f340598b022da121f86e3a96f84a3b6fedbf9 /src/imports/controls/ComboBox.qml | |
parent | 23706b974f443b96bf1da86b264349e51d6d0d05 (diff) |
ComboBox: separate indicator
This makes it possible to hide or replace either ComboBox background
or content item without losing the built-in indicator.
Change-Id: I308bbaa8190eba04ff3048a20c2d2ed0431a24f2
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/imports/controls/ComboBox.qml')
-rw-r--r-- | src/imports/controls/ComboBox.qml | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 0ab7bf24..23729775 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -42,8 +42,11 @@ import QtQuick.Templates 2.0 as T T.ComboBox { id: control - implicitWidth: (background ? background.implicitWidth : contentItem.implicitWidth) + leftPadding + rightPadding - implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding) + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset spacing: 8 @@ -62,15 +65,25 @@ T.ComboBox { } //! [delegate] + //! [indicator] + indicator: Image { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + source: "image://default/double-arrow/" + (control.visualFocus ? "#0066ff" : "#353637") + } + //! [indicator] + //! [contentItem] 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.visualFocus ? "#0066ff" : "#353637" horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight - rightPadding: 18 + control.spacing } //! [contentItem] @@ -83,12 +96,6 @@ T.ComboBox { (control.pressed || popup.visible ? "#d6d6d6" : "#f6f6f6") border.color: control.visualFocus ? "#0066ff" : "#353637" border.width: control.visualFocus ? 2 : 1 - - Image { - x: parent.width - width - 4 - y: (parent.height - height) / 2 - source: "image://default/double-arrow/" + (control.visualFocus ? "#0066ff" : "#353637") - } } //! [background] |