Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / components / ValueButtonAlignRight.qml
1 /****************************************************************************************
2 **
3 ** Copyright (C) 2013 Jolla Ltd.
4 ** Contact: Bea Lam <bea.lam@jollamobile.com>
5 ** All rights reserved.
6 **
7 ** This file is part of Sailfish Silica UI component package.
8 **
9 ** You may use this file under the terms of BSD license as follows:
10 **
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.
21 **
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.
32 **
33 ****************************************************************************************/
34 import QtQuick 2.0
35 import Sailfish.Silica 1.0
36 import Sailfish.Silica.theme 1.0
37
38 BackgroundItem {
39     id: root
40
41     property alias label: titleText.text
42     property alias value: valueText.text
43
44     property alias labelColor: titleText.color
45     property alias valueColor: valueText.color
46
47     property real labelMargin: Theme.paddingLarge
48
49     property int _duration: 200
50
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
55
56     Flow {
57         id: flow
58
59         anchors {
60             left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter
61             leftMargin: root.labelMargin; rightMargin: Theme.paddingLarge
62         }
63         move: Transition { NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: root._duration } }
64
65         Label {
66             id: titleText
67             color: root.down ? Theme.highlightColor : Theme.primaryColor
68             width: Math.min(implicitWidth + Theme.paddingSmall, parent.width)
69             truncationMode: TruncationMode.Fade
70         }
71
72         Label {
73             id: valueText
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)
78         }
79     }
80 }