1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef BTUIICONUTIL_H |
|
19 #define BTUIICONUTIL_H |
|
20 |
|
21 #include <qglobal.h> |
|
22 #include <bt_sock.h> |
|
23 #include <HbIcon> |
|
24 //#include "btdevicemodel.h" |
|
25 #include "btuidevtypemap.h" |
|
26 |
|
27 enum BtuiIconCorner { |
|
28 BtuiNoCorners = 0x00, // No badge needed |
|
29 BtuiBottomLeft = 0x01, // Badge for : Paired, Paired & Authorized, Blocked |
|
30 BtuiBottomRight = 0x02, // Badge for : Connected |
|
31 BtuiTopLeft = 0x04, // Badge for : Signal strength |
|
32 BtuiTopRight = 0x08 // Badge for : Battery low |
|
33 }; |
|
34 |
|
35 /*! |
|
36 Creates a HbIcon according to the type of the CBTDevice dev, |
|
37 Creates badges in the icon's 4 corners according to the parameters |
|
38 passed to the function |
|
39 bottom left corner: Paired, Paired & Authorized, Blocked |
|
40 bottom right corner: Connected |
|
41 top right corner: Battery low |
|
42 top left corner: signal strength |
|
43 */ |
|
44 |
|
45 inline void setBadging(HbIcon &deviceIcon, int majorProperty, int corners) |
|
46 { |
|
47 if (corners & BtuiBottomLeft) { |
|
48 if (majorProperty & BtuiDevProperty::Trusted ) { |
|
49 HbIcon badge("qtg_small_authorised"); |
|
50 badge.setIconName("qtg_small_authorised"); |
|
51 deviceIcon.addBadge(Qt::AlignLeft|Qt::AlignBottom, badge); |
|
52 } |
|
53 else if (majorProperty & BtuiDevProperty::Bonded) { |
|
54 HbIcon badge("qtg_small_pair"); |
|
55 badge.setIconName("qtg_small_pair"); |
|
56 deviceIcon.addBadge(Qt::AlignLeft|Qt::AlignBottom, badge); |
|
57 } |
|
58 else if (majorProperty & BtuiDevProperty::Blocked) { |
|
59 HbIcon badge("qtg_small_blocked"); |
|
60 badge.setIconName("qtg_small_blocked"); |
|
61 deviceIcon.addBadge(Qt::AlignLeft|Qt::AlignBottom, badge); |
|
62 } |
|
63 } |
|
64 if (corners & BtuiBottomRight) { |
|
65 if (majorProperty & BtuiDevProperty::Connected) { |
|
66 HbIcon badge("qtg_small_connection"); |
|
67 badge.setIconName("qtg_small_connection"); |
|
68 deviceIcon.addBadge(Qt::AlignRight|Qt::AlignBottom, badge); |
|
69 } |
|
70 } |
|
71 if (corners & BtuiTopRight) { |
|
72 //ToDo: when power level added to model |
|
73 } |
|
74 if (corners & BtuiTopLeft) { |
|
75 //ToDo: add signal strength. |
|
76 } |
|
77 } |
|
78 |
|
79 |
|
80 /*! |
|
81 * builds device icon based on device type, including badging with connection info, etc. |
|
82 * |
|
83 * \param cod the integer value of the CoD. |
|
84 * \param majorProperty the major property consisting of BtuiDevProperty::DevMajorProperty bits |
|
85 * \param corners specifies which corners of primary icon |
|
86 * should be badged with connectivity, pairing, trust, etc information |
|
87 * \return an HbIcon |
|
88 * |
|
89 */ |
|
90 inline HbIcon getBadgedDeviceTypeIcon(int cod, int majorProperty = 0, int corners = BtuiNoCorners) |
|
91 { |
|
92 int uiMajorDevice; |
|
93 int uiMinorDevice; |
|
94 // device type is mapped according to CoD: |
|
95 BtuiDevProperty::mapDeiveType(uiMajorDevice, uiMinorDevice, cod); |
|
96 |
|
97 // Set icon according to the device category |
|
98 QString name; |
|
99 if (uiMajorDevice & BtuiDevProperty::Phone) { |
|
100 name = QString("qtg_large_mobile"); |
|
101 } |
|
102 else if (uiMajorDevice & BtuiDevProperty::Computer) { |
|
103 name = QString("qtg_large_computer"); |
|
104 } |
|
105 else if (uiMajorDevice & BtuiDevProperty::AVDev) { |
|
106 name = QString("qtg_large_generic_audio"); |
|
107 } |
|
108 else if (uiMajorDevice & BtuiDevProperty::Peripheral) { |
|
109 // todo: map to keyboard & mouse from uiMinorDevice |
|
110 name = QString("qtg_large_input_device"); |
|
111 } |
|
112 else { |
|
113 name = QString("qtg_large_generic_bluetooth"); |
|
114 } |
|
115 HbIcon icon(name); |
|
116 if (corners > BtuiNoCorners) { |
|
117 setBadging(icon, majorProperty, corners); |
|
118 } |
|
119 return icon; |
|
120 } |
|
121 |
|
122 /* |
|
123 * returns device type as a translated string based on |
|
124 * Class of Device (CoD) parameter |
|
125 */ |
|
126 inline QString getDeviceTypeString( int cod ) |
|
127 { |
|
128 int uiMajorDevice; |
|
129 int uiMinorDevice; |
|
130 // device type is mapped according to CoD: |
|
131 BtuiDevProperty::mapDeiveType(uiMajorDevice, uiMinorDevice, cod); |
|
132 |
|
133 // Set icon according to the device category |
|
134 if (uiMajorDevice & BtuiDevProperty::Phone) { |
|
135 return hbTrId("txt_bt_list_phone"); |
|
136 } |
|
137 else if (uiMajorDevice & BtuiDevProperty::Computer) { |
|
138 return hbTrId("txt_bt_list_computer"); |
|
139 } |
|
140 else if (uiMajorDevice & BtuiDevProperty::AVDev) { |
|
141 return hbTrId("txt_bt_list_audio_device"); |
|
142 } |
|
143 else if (uiMajorDevice & BtuiDevProperty::Peripheral) { |
|
144 // todo: map to keyboard & mouse |
|
145 return hbTrId("txt_bt_list_input_device"); |
|
146 } |
|
147 else { |
|
148 return hbTrId("txt_bt_list_other"); |
|
149 } |
|
150 } |
|
151 |
|
152 #endif // BTUIMODELUTIL_H |
|