1 /****************************************************************************************
3 ** Copyright (C) 2013 Jolla Ltd.
4 ** Contact: Bea Lam <bea.lam@jollamobile.com>
5 ** All rights reserved.
7 ** This file is part of Sailfish Silica UI component package.
9 ** You may use this file under the terms of BSD license as follows:
11 ** Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are met:
13 ** * Redistributions of source code must retain the above copyright
14 ** notice, this list of conditions and the following disclaimer.
15 ** * Redistributions in binary form must reproduce the above copyright
16 ** notice, this list of conditions and the following disclaimer in the
17 ** documentation and/or other materials provided with the distribution.
18 ** * Neither the name of the Jolla Ltd nor the
19 ** names of its contributors may be used to endorse or promote products
20 ** derived from this software without specific prior written permission.
22 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
26 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ****************************************************************************************/
35 import Sailfish.Silica 1.0
36 import Sailfish.Silica.theme 1.0
41 property alias label: titleText.text
42 property alias value: valueText.text
44 property alias labelColor: titleText.color
45 property alias valueColor: valueText.color
47 property real labelMargin: Theme.paddingLarge
49 property int _duration: 200
51 width: parent ? parent.width : 0
52 height: contentItem.height
53 contentHeight: visible ? (titleText.height == flow.implicitHeight ? Theme.itemSizeSmall : Theme.itemSizeExtraLarge) : 0
54 opacity: enabled ? 1.0 : 0.4
60 left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter
61 leftMargin: root.labelMargin; rightMargin: Theme.paddingLarge
63 move: Transition { NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: root._duration } }
67 color: root.down ? Theme.highlightColor : Theme.primaryColor
68 width: Math.min(implicitWidth + Theme.paddingSmall, parent.width)
69 truncationMode: TruncationMode.Fade
74 color: Theme.highlightColor
75 width: Math.min(implicitWidth, parent.width)
76 truncationMode: TruncationMode.Fade
77 horizontalAlignment: ((implicitWidth <= (parent.width - titleText.width)) ? Text.AlignLeft : Text.AlignRight)