Your phone in Your Devices will now be dim if it's only paired,
[profile/ivi/hfdialer.git] / qml / DeviceDelegateActive.qml
1 /*
2  * Copyright 2012 Intel Corporation.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  */
8
9 import Qt 4.7
10 Item {
11     id: root
12     property string deviceName
13     property string address
14     property string icon: ""
15     property string alias: ""
16     property string dbuspath: ""
17     property variant uuids: []
18
19     property int containerHeight: 80
20     height: containerHeight
21     width: parent.width
22     signal clicked()
23     signal close()
24
25     Connections {
26         target: adapter
27         onModemOnlineChanged: {
28
29             //If the modem gets powered down for any reason, attempt to power it again to maintain connection
30             if (!adapter.modemOnline)
31             {
32                 mainText.color = "grey"
33                 availableBluetoothItem.source = "/usr/share/hfdialer/images/ivi_btn-list-inactive.png"
34             }
35             else
36             {
37                 mainText.color = "white"
38                 availableBluetoothItem.source = "/usr/share/hfdialer/images/ivi_btn-list.png"
39             }
40          }
41     }
42
43     Image {
44         id: availableBluetoothItem
45
46         source: !adapter.modemOnline? "/usr/share/hfdialer/images/ivi_btn-list-inactive.png" : availableBluetoothItem.source = "/usr/share/hfdialer/images/ivi_btn-list.png"
47         anchors {fill: parent; leftMargin: 8; rightMargin: 8; topMargin: 8}
48
49         MouseArea {
50           id: clickArea
51           anchors.fill: parent
52
53
54            onPressed: {
55                  availableBluetoothItem.source = "/usr/share/hfdialer/images/ivi_btn-list.png"            
56             }
57
58             onReleased: {
59                  availableBluetoothItem.source = "/usr/share/hfdialer/images/ivi_btn-list-inactive.png"      
60             }
61
62             onClicked: {
63                 adapter.modemOnline = true
64             }
65         }
66
67         Text {
68             id: mainText
69
70             anchors {left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 15}
71             width: parent.width * 0.75
72
73             verticalAlignment: Text.AlignVCenter
74             height:  availableBluetoothItem.containerHeight
75             font.pixelSize: parent.height / 2
76             style: Text.Outline
77             styleColor: "#3B3A39"
78             color: !adapter.modemOnline? "grey" : "white"
79             text: root.deviceName
80             elide: Text.ElideRight
81         }
82
83         Image {
84             id: closeButton
85             source: "/usr/share/hfdialer/images/ivi_icon-list-delete.png"
86             anchors { left: mainText.right; right: parent.right; top: parent.top; bottom: parent.bottom}
87
88             MouseArea {
89                 id: closeArea
90                   anchors.fill: parent
91
92             onPressed: {
93                 closeButton.source = "/usr/share/hfdialer/images/ivi_icon-list-delete-active.png"
94             }
95
96             onReleased: {
97                 closeButton.source = "/usr/share/hfdialer/images/ivi_icon-list-delete.png"
98             }
99
100             onClicked: {
101                 console.log("CLOSE BUTTON CLICKED")
102                 root.close()
103                 }
104             }
105         }
106     }
107 }