Linked key and ca file configuration to vpn execution. Added option to
[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
43     property alias labelColor: titleText.color
44     property alias valueColor: valueText.color
45
46     property real labelMargin: Theme.paddingLarge
47
48     property int _duration: 200
49     property string value
50     property string placeholderText
51
52     width: parent ? parent.width : 0
53     height: contentItem.height
54     contentHeight: visible ? (titleText.height == flow.implicitHeight ? Theme.itemSizeSmall : Theme.itemSizeExtraLarge) : 0
55     opacity: enabled ? 1.0 : 0.4
56
57     Flow {
58         id: flow
59
60         anchors {
61             left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter
62             leftMargin: root.labelMargin; rightMargin: Theme.paddingLarge
63         }
64         move: Transition { NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: root._duration } }
65
66         Label {
67             id: titleText
68             color: root.down ? Theme.highlightColor : Theme.primaryColor
69             width: Math.min(implicitWidth + Theme.paddingSmall, parent.width)
70             truncationMode: TruncationMode.Fade
71         }
72
73         Label {
74             id: valueText
75             color: Theme.highlightColor
76             width: Math.min(implicitWidth, parent.width)
77             truncationMode: TruncationMode.Fade
78             horizontalAlignment: ((implicitWidth <= (parent.width - titleText.width)) ? Text.AlignLeft : Text.AlignRight)
79             text: (value != "" ? value : placeholderText)
80         }
81     }
82 }