author | mickeyl <mickeyl> | 2005-01-04 23:03:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-04 23:03:23 (UTC) |
commit | 49683b3396a2e93cf49ac1726eafca6e8798be81 (patch) (unidiff) | |
tree | 6aaa08205dbf55a214655c275c11cd7ef8a27bdd | |
parent | b41e4499d41fc92cc1ed4ed487e57d0a002c1a02 (diff) | |
download | opie-49683b3396a2e93cf49ac1726eafca6e8798be81.zip opie-49683b3396a2e93cf49ac1726eafca6e8798be81.tar.gz opie-49683b3396a2e93cf49ac1726eafca6e8798be81.tar.bz2 |
catch up with proper inclusion of OLedBox into libopieui
-rw-r--r-- | core/applets/volumeapplet/config.in | 2 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 7 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 8 | ||||
-rw-r--r-- | core/applets/volumeapplet/volumeapplet.pro | 7 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.h | 4 |
6 files changed, 17 insertions, 13 deletions
diff --git a/core/applets/volumeapplet/config.in b/core/applets/volumeapplet/config.in index b18cd54..7ab1a27 100644 --- a/core/applets/volumeapplet/config.in +++ b/core/applets/volumeapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config VOLUMEAPPLET | 1 | config VOLUMEAPPLET |
2 | boolean "opie-volumeapplet (set volume for microphone and speaker)" | 2 | boolean "opie-volumeapplet (set volume for microphone and speaker)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI |
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 45c106a..23c847d 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,780 +1,783 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "volume.h" | 21 | #include "volume.h" |
22 | 22 | ||
23 | /* OPIE */ | ||
23 | #include <opie2/oledbox.h> | 24 | #include <opie2/oledbox.h> |
24 | #include <opie2/odevice.h> | 25 | #include <opie2/odevice.h> |
25 | #include <opie2/otaskbarapplet.h> | 26 | #include <opie2/otaskbarapplet.h> |
26 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
27 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
29 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | using namespace Opie::Core; | ||
32 | using namespace Opie::Ui; | ||
30 | 33 | ||
34 | /* QT */ | ||
31 | #include <qpainter.h> | 35 | #include <qpainter.h> |
32 | #include <qcheckbox.h> | 36 | #include <qcheckbox.h> |
33 | #include <qslider.h> | 37 | #include <qslider.h> |
34 | #include <qlayout.h> | 38 | #include <qlayout.h> |
35 | #include <qvbox.h> | 39 | #include <qvbox.h> |
36 | #include <qlabel.h> | 40 | #include <qlabel.h> |
37 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
38 | #include <qtimer.h> | 42 | #include <qtimer.h> |
39 | 43 | ||
44 | /* STD */ | ||
40 | #include <stdio.h> | 45 | #include <stdio.h> |
41 | 46 | ||
42 | using namespace Opie::Core; | ||
43 | |||
44 | #define RATE_TIMER_INTERVAL 100 | 47 | #define RATE_TIMER_INTERVAL 100 |
45 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 48 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time |
46 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. | 49 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
47 | 50 | ||
48 | 51 | ||
49 | /* XPM */ | 52 | /* XPM */ |
50 | using namespace Opie::Ui; | 53 | using namespace Opie::Ui; |
51 | static const char * vol_xpm[] = { | 54 | static const char * vol_xpm[] = { |
52 | "20 20 3 1", | 55 | "20 20 3 1", |
53 | " c None", | 56 | " c None", |
54 | ". c #0000FF", | 57 | ". c #0000FF", |
55 | "+ c #000000", | 58 | "+ c #000000", |
56 | " ", | 59 | " ", |
57 | " . ", | 60 | " . ", |
58 | " . . . . ", | 61 | " . . . . ", |
59 | " . . . . . . ", | 62 | " . . . . . . ", |
60 | " . . . . . . . ", | 63 | " . . . . . . . ", |
61 | " . . ..... . . ", | 64 | " . . ..... . . ", |
62 | " . ... ..... ... ", | 65 | " . ... ..... ... ", |
63 | " ........... .... ", | 66 | " ........... .... ", |
64 | " ................. ", | 67 | " ................. ", |
65 | "++++++++++++++++++++", | 68 | "++++++++++++++++++++", |
66 | " .................. ", | 69 | " .................. ", |
67 | " . ............. . ", | 70 | " . ............. . ", |
68 | " . ..... ....... ", | 71 | " . ..... ....... ", |
69 | " . ... ..... . ", | 72 | " . ... ..... . ", |
70 | " . ... ..... . ", | 73 | " . ... ..... . ", |
71 | " . ... ..... ", | 74 | " . ... ..... ", |
72 | " . . . . . ", | 75 | " . . . . . ", |
73 | " . . . ", | 76 | " . . . ", |
74 | " . . . ", | 77 | " . . . ", |
75 | " "}; | 78 | " "}; |
76 | /* XPM */ | 79 | /* XPM */ |
77 | static const char * mic_xpm[] = { | 80 | static const char * mic_xpm[] = { |
78 | "20 20 21 1", | 81 | "20 20 21 1", |
79 | " c None", | 82 | " c None", |
80 | ". c #000000", | 83 | ". c #000000", |
81 | "+ c #EEEEEE", | 84 | "+ c #EEEEEE", |
82 | "@ c #B4B6B4", | 85 | "@ c #B4B6B4", |
83 | "# c #8B8D8B", | 86 | "# c #8B8D8B", |
84 | "$ c #D5D6D5", | 87 | "$ c #D5D6D5", |
85 | "% c #E6E6E6", | 88 | "% c #E6E6E6", |
86 | "& c #9C9D9C", | 89 | "& c #9C9D9C", |
87 | "* c #6A696A", | 90 | "* c #6A696A", |
88 | "= c #E6E2E6", | 91 | "= c #E6E2E6", |
89 | "- c #F6F2F6", | 92 | "- c #F6F2F6", |
90 | "; c #CDC6CD", | 93 | "; c #CDC6CD", |
91 | "> c #737573", | 94 | "> c #737573", |
92 | ", c #4A484A", | 95 | ", c #4A484A", |
93 | "' c #DEDEDE", | 96 | "' c #DEDEDE", |
94 | ") c #F6EEF6", | 97 | ") c #F6EEF6", |
95 | "! c #414041", | 98 | "! c #414041", |
96 | "~ c #202020", | 99 | "~ c #202020", |
97 | "{ c #ACAEAC", | 100 | "{ c #ACAEAC", |
98 | "] c #838583", | 101 | "] c #838583", |
99 | "^ c #6A656A", | 102 | "^ c #6A656A", |
100 | " ", | 103 | " ", |
101 | " .... ", | 104 | " .... ", |
102 | " .+@+#. ", | 105 | " .+@+#. ", |
103 | " ..$%&%*. ", | 106 | " ..$%&%*. ", |
104 | " .=-.;=>=,. ", | 107 | " .=-.;=>=,. ", |
105 | " .'+).&+!+. ", | 108 | " .'+).&+!+. ", |
106 | " .+;+;.~+~. ", | 109 | " .+;+;.~+~. ", |
107 | " ..%{%,.... ", | 110 | " ..%{%,.... ", |
108 | " ..&=>=~.. ", | 111 | " ..&=>=~.. ", |
109 | " .+..]^,.. ", | 112 | " .+..]^,.. ", |
110 | " .+....... ", | 113 | " .+....... ", |
111 | " .%... ", | 114 | " .%... ", |
112 | " .=... ", | 115 | " .=... ", |
113 | " .+... ", | 116 | " .+... ", |
114 | " .+... ", | 117 | " .+... ", |
115 | " .... ", | 118 | " .... ", |
116 | " .... ", | 119 | " .... ", |
117 | " .. ", | 120 | " .. ", |
118 | " . ", | 121 | " . ", |
119 | ". "}; | 122 | ". "}; |
120 | 123 | ||
121 | 124 | ||
122 | static const char * bass_xpm[] = { | 125 | static const char * bass_xpm[] = { |
123 | "20 20 3 1", | 126 | "20 20 3 1", |
124 | " c None", | 127 | " c None", |
125 | ". c #000000", | 128 | ". c #000000", |
126 | "+ c #0000FF", | 129 | "+ c #0000FF", |
127 | " ", | 130 | " ", |
128 | " ", | 131 | " ", |
129 | " ", | 132 | " ", |
130 | "..... +++ ......", | 133 | "..... +++ ......", |
131 | " +++++++ ", | 134 | " +++++++ ", |
132 | " ++ ++ ", | 135 | " ++ ++ ", |
133 | "... ++ ... ++ ++ .", | 136 | "... ++ ... ++ ++ .", |
134 | " +++ ++ ++ ", | 137 | " +++ ++ ++ ", |
135 | " ++++ ++ ", | 138 | " ++++ ++ ", |
136 | "... ++++ .. ++ .....", | 139 | "... ++++ .. ++ .....", |
137 | " ++ ++ ", | 140 | " ++ ++ ", |
138 | " ++ ++ ", | 141 | " ++ ++ ", |
139 | "..........++ ++ .", | 142 | "..........++ ++ .", |
140 | " ++ ", | 143 | " ++ ", |
141 | " ++ ", | 144 | " ++ ", |
142 | "...... ++ .........", | 145 | "...... ++ .........", |
143 | " + ", | 146 | " + ", |
144 | " ", | 147 | " ", |
145 | " ", | 148 | " ", |
146 | " "}; | 149 | " "}; |
147 | 150 | ||
148 | 151 | ||
149 | static const char * treble_xpm[] = { | 152 | static const char * treble_xpm[] = { |
150 | "20 20 3 1", | 153 | "20 20 3 1", |
151 | " c None", | 154 | " c None", |
152 | ". c #0000FF", | 155 | ". c #0000FF", |
153 | "+ c #000000", | 156 | "+ c #000000", |
154 | " .. ", | 157 | " .. ", |
155 | " . .. ", | 158 | " . .. ", |
156 | " . .. ", | 159 | " . .. ", |
157 | "++++++++ . .. ++++++", | 160 | "++++++++ . .. ++++++", |
158 | " . . ", | 161 | " . . ", |
159 | " ... ", | 162 | " ... ", |
160 | "++++++++ . +++++++", | 163 | "++++++++ . +++++++", |
161 | " .. ", | 164 | " .. ", |
162 | " .. . ", | 165 | " .. . ", |
163 | "+++ .. ... +++++++", | 166 | "+++ .. ... +++++++", |
164 | " .. .. .. ", | 167 | " .. .. .. ", |
165 | " .. . . .. ", | 168 | " .. . . .. ", |
166 | "+++ .. . . + . +++++", | 169 | "+++ .. . . + . +++++", |
167 | " .. . .. ", | 170 | " .. . .. ", |
168 | " .. . .. ", | 171 | " .. . .. ", |
169 | "++++ ...... +++++++", | 172 | "++++ ...... +++++++", |
170 | " . ", | 173 | " . ", |
171 | " .. . ", | 174 | " .. . ", |
172 | " .. . ", | 175 | " .. . ", |
173 | " .. "}; | 176 | " .. "}; |
174 | 177 | ||
175 | 178 | ||
176 | 179 | ||
177 | 180 | ||
178 | /* XPM */ | 181 | /* XPM */ |
179 | static const char * alarm_xpm[] = { | 182 | static const char * alarm_xpm[] = { |
180 | "20 20 33 1", | 183 | "20 20 33 1", |
181 | " c None", | 184 | " c None", |
182 | ". c #080602", | 185 | ". c #080602", |
183 | "+ c #AAA602", | 186 | "+ c #AAA602", |
184 | "@ c #252002", | 187 | "@ c #252002", |
185 | "# c #434202", | 188 | "# c #434202", |
186 | "$ c #795602", | 189 | "$ c #795602", |
187 | "% c #C3C20D", | 190 | "% c #C3C20D", |
188 | "& c #DADAC2", | 191 | "& c #DADAC2", |
189 | "* c #826002", | 192 | "* c #826002", |
190 | "= c #740502", | 193 | "= c #740502", |
191 | "- c #D6D602", | 194 | "- c #D6D602", |
192 | "; c #322E02", | 195 | "; c #322E02", |
193 | "> c #826A02", | 196 | "> c #826A02", |
194 | ", c #F1F195", | 197 | ", c #F1F195", |
195 | "' c #959215", | 198 | "' c #959215", |
196 | ") c #423602", | 199 | ") c #423602", |
197 | "! c #4B0302", | 200 | "! c #4B0302", |
198 | "~ c #844315", | 201 | "~ c #844315", |
199 | "{ c #AAAA2A", | 202 | "{ c #AAAA2A", |
200 | "] c #E2DE42", | 203 | "] c #E2DE42", |
201 | "^ c #BA7E04", | 204 | "^ c #BA7E04", |
202 | "/ c #7F7502", | 205 | "/ c #7F7502", |
203 | "( c #828276", | 206 | "( c #828276", |
204 | "_ c #FEFE4E", | 207 | "_ c #FEFE4E", |
205 | ": c #7D1902", | 208 | ": c #7D1902", |
206 | "< c #989656", | 209 | "< c #989656", |
207 | "[ c #260B02", | 210 | "[ c #260B02", |
208 | "} c #F7F7D8", | 211 | "} c #F7F7D8", |
209 | "| c #DCDA5A", | 212 | "| c #DCDA5A", |
210 | "1 c #823102", | 213 | "1 c #823102", |
211 | "2 c #B1AC6B", | 214 | "2 c #B1AC6B", |
212 | "3 c #F7F710", | 215 | "3 c #F7F710", |
213 | "4 c #838204", | 216 | "4 c #838204", |
214 | " ", | 217 | " ", |
215 | " ", | 218 | " ", |
216 | " 4'4/ ", | 219 | " 4'4/ ", |
217 | " /-^= ", | 220 | " /-^= ", |
218 | " 42{4>4 ", | 221 | " 42{4>4 ", |
219 | " '2|+*$44 ", | 222 | " '2|+*$44 ", |
220 | " +2&3+$1*44 ", | 223 | " +2&3+$1*44 ", |
221 | " (%_}_+/$:>/4 ", | 224 | " (%_}_+/$:>/4 ", |
222 | " 4%_}3+#;>:*4 ", | 225 | " 4%_}3+#;>:*4 ", |
223 | " 4%_}&+#[1$/4 ", | 226 | " 4%_}&+#[1$/4 ", |
224 | " 4%_,2')[~~>4 ", | 227 | " 4%_,2')[~~>4 ", |
225 | " 4%33'4#@~1>4 ", | 228 | " 4%33'4#@~1>4 ", |
226 | " 4%3344#[:>/4 ", | 229 | " 4%3344#[:>/4 ", |
227 | " 42&_3'4#@>:*44 ", | 230 | " 42&_3'4#@>:*44 ", |
228 | " 42|}}3'4#[;$)$44 ", | 231 | " 42|}}3'4#[;$)$44 ", |
229 | "444{]]2^~~:!!#.@##/ ", | 232 | "444{]]2^~~:!!#.@##/ ", |
230 | "4444-%*:==!!=...../ ", | 233 | "4444-%*:==!!=...../ ", |
231 | " /:[.. ", | 234 | " /:[.. ", |
232 | " /@. ", | 235 | " /@. ", |
233 | " "}; | 236 | " "}; |
234 | 237 | ||
235 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 238 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
236 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 239 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
237 | { | 240 | { |
238 | m_icon = icon; | 241 | m_icon = icon; |
239 | 242 | ||
240 | bool has_wav_alarm = true; | 243 | bool has_wav_alarm = true; |
241 | bool has_bass = true; | 244 | bool has_bass = true; |
242 | bool has_treble = true; | 245 | bool has_treble = true; |
243 | 246 | ||
244 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually | 247 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
245 | case Model_Zaurus_SL5000: | 248 | case Model_Zaurus_SL5000: |
246 | has_wav_alarm = false; //poor guys probably feeling left out... | 249 | has_wav_alarm = false; //poor guys probably feeling left out... |
247 | break; | 250 | break; |
248 | default: | 251 | default: |
249 | break; | 252 | break; |
250 | } | 253 | } |
251 | 254 | ||
252 | if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { | 255 | if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { |
253 | has_bass = false; | 256 | has_bass = false; |
254 | has_treble = false; | 257 | has_treble = false; |
255 | } | 258 | } |
256 | 259 | ||
257 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 260 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
258 | 261 | ||
259 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 262 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
260 | grid-> setSpacing ( 4 ); | 263 | grid-> setSpacing ( 4 ); |
261 | grid-> setMargin ( 6 ); | 264 | grid-> setMargin ( 6 ); |
262 | 265 | ||
263 | QVBoxLayout *vbox; | 266 | QVBoxLayout *vbox; |
264 | QLabel *l; | 267 | QLabel *l; |
265 | 268 | ||
266 | vbox = new QVBoxLayout ( ); | 269 | vbox = new QVBoxLayout ( ); |
267 | vbox-> setSpacing ( 4 ); | 270 | vbox-> setSpacing ( 4 ); |
268 | grid-> addLayout ( vbox, 1, 0 ); | 271 | grid-> addLayout ( vbox, 1, 0 ); |
269 | 272 | ||
270 | upButton = new QPushButton ( this ); | 273 | upButton = new QPushButton ( this ); |
271 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 274 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
272 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | 275 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); |
273 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 276 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
274 | 277 | ||
275 | vbox-> addWidget ( upButton ); | 278 | vbox-> addWidget ( upButton ); |
276 | 279 | ||
277 | downButton = new QPushButton ( this ); | 280 | downButton = new QPushButton ( this ); |
278 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 281 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
279 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | 282 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); |
280 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 283 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
281 | 284 | ||
282 | vbox-> addWidget ( downButton ); | 285 | vbox-> addWidget ( downButton ); |
283 | 286 | ||
284 | volSlider = new QSlider ( this ); | 287 | volSlider = new QSlider ( this ); |
285 | volSlider-> setRange ( 0, 100 ); | 288 | volSlider-> setRange ( 0, 100 ); |
286 | volSlider-> setTickmarks ( QSlider::Both ); | 289 | volSlider-> setTickmarks ( QSlider::Both ); |
287 | volSlider-> setTickInterval ( 20 ); | 290 | volSlider-> setTickInterval ( 20 ); |
288 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 291 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
289 | 292 | ||
290 | l = new QLabel ( this ); | 293 | l = new QLabel ( this ); |
291 | l-> setPixmap ( QPixmap ( vol_xpm )); | 294 | l-> setPixmap ( QPixmap ( vol_xpm )); |
292 | 295 | ||
293 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 296 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
294 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 297 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
295 | 298 | ||
296 | volLed = new OLedBox ( green, this ); | 299 | volLed = new OLedBox ( green, this ); |
297 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 300 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
298 | volLed-> setFixedSize ( 16, 16 ); | 301 | volLed-> setFixedSize ( 16, 16 ); |
299 | 302 | ||
300 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 303 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
301 | 304 | ||
302 | QVBox *basstrebleBox = new QVBox( this ); | 305 | QVBox *basstrebleBox = new QVBox( this ); |
303 | 306 | ||
304 | trebleSlider = new QSlider ( basstrebleBox ); | 307 | trebleSlider = new QSlider ( basstrebleBox ); |
305 | trebleSlider-> setRange ( 0, 100 ); | 308 | trebleSlider-> setRange ( 0, 100 ); |
306 | trebleSlider-> setTickmarks ( QSlider::Both ); | 309 | trebleSlider-> setTickmarks ( QSlider::Both ); |
307 | trebleSlider-> setTickInterval ( 20 ); | 310 | trebleSlider-> setTickInterval ( 20 ); |
308 | trebleSlider->setMaximumHeight( 40 ); | 311 | trebleSlider->setMaximumHeight( 40 ); |
309 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); | 312 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); |
310 | 313 | ||
311 | bassSlider = new QSlider ( basstrebleBox ); | 314 | bassSlider = new QSlider ( basstrebleBox ); |
312 | bassSlider-> setRange ( 0, 100 ); | 315 | bassSlider-> setRange ( 0, 100 ); |
313 | bassSlider-> setTickmarks ( QSlider::Both ); | 316 | bassSlider-> setTickmarks ( QSlider::Both ); |
314 | bassSlider-> setTickInterval ( 20 ); | 317 | bassSlider-> setTickInterval ( 20 ); |
315 | bassSlider->setMaximumHeight( 40 ); | 318 | bassSlider->setMaximumHeight( 40 ); |
316 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); | 319 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); |
317 | 320 | ||
318 | QLabel *bassLabel = new QLabel ( this ); | 321 | QLabel *bassLabel = new QLabel ( this ); |
319 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); | 322 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); |
320 | 323 | ||
321 | QLabel *trebleLabel = new QLabel( this ); | 324 | QLabel *trebleLabel = new QLabel( this ); |
322 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); | 325 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); |
323 | 326 | ||
324 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); | 327 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); |
325 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); | 328 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); |
326 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); | 329 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); |
327 | 330 | ||
328 | if ( !has_bass ) { | 331 | if ( !has_bass ) { |
329 | bassSlider->hide(); | 332 | bassSlider->hide(); |
330 | bassLabel->hide(); | 333 | bassLabel->hide(); |
331 | } | 334 | } |
332 | 335 | ||
333 | if ( !has_treble ) { | 336 | if ( !has_treble ) { |
334 | trebleSlider->hide(); | 337 | trebleSlider->hide(); |
335 | trebleLabel->hide(); | 338 | trebleLabel->hide(); |
336 | } | 339 | } |
337 | 340 | ||
338 | micSlider = new QSlider ( this ); | 341 | micSlider = new QSlider ( this ); |
339 | micSlider-> setRange ( 0, 100 ); | 342 | micSlider-> setRange ( 0, 100 ); |
340 | micSlider-> setTickmarks ( QSlider::Both ); | 343 | micSlider-> setTickmarks ( QSlider::Both ); |
341 | micSlider-> setTickInterval ( 20 ); | 344 | micSlider-> setTickInterval ( 20 ); |
342 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 345 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
343 | 346 | ||
344 | l = new QLabel ( this ); | 347 | l = new QLabel ( this ); |
345 | l-> setPixmap ( QPixmap ( mic_xpm )); | 348 | l-> setPixmap ( QPixmap ( mic_xpm )); |
346 | 349 | ||
347 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 350 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
348 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 351 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
349 | 352 | ||
350 | micLed = new OLedBox ( red, this ); | 353 | micLed = new OLedBox ( red, this ); |
351 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 354 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
352 | micLed-> setFixedSize ( 16, 16 ); | 355 | micLed-> setFixedSize ( 16, 16 ); |
353 | 356 | ||
354 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 357 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
355 | 358 | ||
356 | alarmSlider = new QSlider ( this ); | 359 | alarmSlider = new QSlider ( this ); |
357 | alarmSlider-> setRange ( 0, 100 ); | 360 | alarmSlider-> setRange ( 0, 100 ); |
358 | alarmSlider-> setTickmarks ( QSlider::Both ); | 361 | alarmSlider-> setTickmarks ( QSlider::Both ); |
359 | alarmSlider-> setTickInterval ( 20 ); | 362 | alarmSlider-> setTickInterval ( 20 ); |
360 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 363 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
361 | 364 | ||
362 | QLabel *alarmLabel = new QLabel ( this ); | 365 | QLabel *alarmLabel = new QLabel ( this ); |
363 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 366 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
364 | 367 | ||
365 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 368 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
366 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 369 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
367 | 370 | ||
368 | alarmLed = new OLedBox ( yellow, this ); | 371 | alarmLed = new OLedBox ( yellow, this ); |
369 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 372 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
370 | alarmLed-> setFixedSize ( 16, 16 ); | 373 | alarmLed-> setFixedSize ( 16, 16 ); |
371 | 374 | ||
372 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 375 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
373 | 376 | ||
374 | if ( !has_wav_alarm ) { | 377 | if ( !has_wav_alarm ) { |
375 | alarmSlider-> hide ( ); | 378 | alarmSlider-> hide ( ); |
376 | alarmLabel-> hide ( ); | 379 | alarmLabel-> hide ( ); |
377 | alarmLed-> hide ( ); | 380 | alarmLed-> hide ( ); |
378 | } | 381 | } |
379 | 382 | ||
380 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); | 383 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
381 | 384 | ||
382 | vbox = new QVBoxLayout ( ); | 385 | vbox = new QVBoxLayout ( ); |
383 | vbox-> setSpacing ( 4 ); | 386 | vbox-> setSpacing ( 4 ); |
384 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); | 387 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
385 | 388 | ||
386 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 389 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
387 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 390 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
388 | 391 | ||
389 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 392 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
390 | 393 | ||
391 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 394 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
392 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 395 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
393 | 396 | ||
394 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 397 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
395 | 398 | ||
396 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 399 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
397 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 400 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
398 | 401 | ||
399 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 402 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
400 | 403 | ||
401 | if ( has_wav_alarm ) { | 404 | if ( has_wav_alarm ) { |
402 | alarmBox-> hide ( ); | 405 | alarmBox-> hide ( ); |
403 | } | 406 | } |
404 | 407 | ||
405 | vbox-> addStretch ( 100 ); | 408 | vbox-> addStretch ( 100 ); |
406 | 409 | ||
407 | setFixedSize ( sizeHint ( )); | 410 | setFixedSize ( sizeHint ( )); |
408 | setFocusPolicy ( QWidget::NoFocus ); | 411 | setFocusPolicy ( QWidget::NoFocus ); |
409 | 412 | ||
410 | rateTimer = new QTimer( this ); | 413 | rateTimer = new QTimer( this ); |
411 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); | 414 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); |
412 | 415 | ||
413 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 416 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
414 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 417 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
415 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 418 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
416 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 419 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
417 | 420 | ||
418 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); | 421 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); |
419 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); | 422 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); |
420 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); | 423 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); |
421 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); | 424 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); |
422 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); | 425 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); |
423 | 426 | ||
424 | 427 | ||
425 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); | 428 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); |
426 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); | 429 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); |
427 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 430 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
428 | 431 | ||
429 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 432 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
430 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); | 433 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); |
431 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); | 434 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); |
432 | 435 | ||
433 | // initialize variables | 436 | // initialize variables |
434 | 437 | ||
435 | readConfig ( true ); | 438 | readConfig ( true ); |
436 | 439 | ||
437 | // initialize the config file, in case some entries are missing | 440 | // initialize the config file, in case some entries are missing |
438 | 441 | ||
439 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 442 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
440 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | 443 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); |
441 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | 444 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); |
442 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 445 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
443 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 446 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
444 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 447 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
445 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 448 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
446 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 449 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
447 | 450 | ||
448 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 451 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
449 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 452 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
450 | } | 453 | } |
451 | 454 | ||
452 | bool VolumeControl::volMuted ( ) const | 455 | bool VolumeControl::volMuted ( ) const |
453 | { | 456 | { |
454 | return m_vol_muted; | 457 | return m_vol_muted; |
455 | } | 458 | } |
456 | 459 | ||
457 | int VolumeControl::volPercent ( ) const | 460 | int VolumeControl::volPercent ( ) const |
458 | { | 461 | { |
459 | return m_vol_percent; | 462 | return m_vol_percent; |
460 | } | 463 | } |
461 | 464 | ||
462 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 465 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
463 | { | 466 | { |
464 | switch ( e-> key ( )) { | 467 | switch ( e-> key ( )) { |
465 | case Key_Up: | 468 | case Key_Up: |
466 | volSlider-> subtractStep ( ); | 469 | volSlider-> subtractStep ( ); |
467 | break; | 470 | break; |
468 | case Key_Down: | 471 | case Key_Down: |
469 | volSlider-> addStep ( ); | 472 | volSlider-> addStep ( ); |
470 | break; | 473 | break; |
471 | case Key_Space: | 474 | case Key_Space: |
472 | volLed-> toggle ( ); | 475 | volLed-> toggle ( ); |
473 | break; | 476 | break; |
474 | case Key_Escape: | 477 | case Key_Escape: |
475 | hide ( ); | 478 | hide ( ); |
476 | break; | 479 | break; |
477 | } | 480 | } |
478 | } | 481 | } |
479 | 482 | ||
480 | void VolumeControl::buttonChanged ( ) | 483 | void VolumeControl::buttonChanged ( ) |
481 | { | 484 | { |
482 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 485 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
483 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 486 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
484 | // called at all when a button is pressed for a time | 487 | // called at all when a button is pressed for a time |
485 | // shorter than RATE_TIMER_INTERVAL. | 488 | // shorter than RATE_TIMER_INTERVAL. |
486 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 489 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
487 | } | 490 | } |
488 | else | 491 | else |
489 | rateTimer-> stop ( ); | 492 | rateTimer-> stop ( ); |
490 | } | 493 | } |
491 | 494 | ||
492 | void VolumeControl::rateTimerDone ( ) | 495 | void VolumeControl::rateTimerDone ( ) |
493 | { | 496 | { |
494 | if ( upButton-> isDown ( )) | 497 | if ( upButton-> isDown ( )) |
495 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 498 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
496 | else // if ( downButton-> isDown ( )) | 499 | else // if ( downButton-> isDown ( )) |
497 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 500 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
498 | } | 501 | } |
499 | 502 | ||
500 | void VolumeControl::show ( bool /*showMic*/ ) | 503 | void VolumeControl::show ( bool /*showMic*/ ) |
501 | { | 504 | { |
502 | readConfig ( ); | 505 | readConfig ( ); |
503 | 506 | ||
504 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 507 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
505 | 508 | ||
506 | int w = sizeHint ( ). width ( ); | 509 | int w = sizeHint ( ). width ( ); |
507 | int x = curPos.x ( ) - ( w / 2 ); | 510 | int x = curPos.x ( ) - ( w / 2 ); |
508 | 511 | ||
509 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 512 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
510 | x = QPEApplication::desktop ( )-> width ( ) - w; | 513 | x = QPEApplication::desktop ( )-> width ( ) - w; |
511 | 514 | ||
512 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 515 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |
513 | QFrame::show ( ); | 516 | QFrame::show ( ); |
514 | 517 | ||
515 | } | 518 | } |
516 | 519 | ||
517 | void VolumeControl::readConfig ( bool force ) | 520 | void VolumeControl::readConfig ( bool force ) |
518 | { | 521 | { |
519 | Config cfg ( "qpe" ); | 522 | Config cfg ( "qpe" ); |
520 | cfg. setGroup ( "Volume" ); | 523 | cfg. setGroup ( "Volume" ); |
521 | 524 | ||
522 | int old_vp = m_vol_percent; | 525 | int old_vp = m_vol_percent; |
523 | int old_mp = m_mic_percent; | 526 | int old_mp = m_mic_percent; |
524 | int old_bass = m_bass_percent; | 527 | int old_bass = m_bass_percent; |
525 | int old_treble = m_treble_percent; | 528 | int old_treble = m_treble_percent; |
526 | bool old_vm = m_vol_muted; | 529 | bool old_vm = m_vol_muted; |
527 | bool old_mm = m_mic_muted; | 530 | bool old_mm = m_mic_muted; |
528 | bool old_sk = m_snd_key; | 531 | bool old_sk = m_snd_key; |
529 | bool old_st = m_snd_touch; | 532 | bool old_st = m_snd_touch; |
530 | bool old_sa = m_snd_alarm; | 533 | bool old_sa = m_snd_alarm; |
531 | int old_ap = m_alarm_percent; | 534 | int old_ap = m_alarm_percent; |
532 | 535 | ||
533 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 536 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
534 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 537 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
535 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); | 538 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); |
536 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); | 539 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); |
537 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 540 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
538 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 541 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
539 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 542 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
540 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 543 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
541 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 544 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
542 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 545 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
543 | 546 | ||
544 | if ( force || ( m_vol_percent != old_vp )) | 547 | if ( force || ( m_vol_percent != old_vp )) |
545 | volSlider-> setValue ( 100 - m_vol_percent ); | 548 | volSlider-> setValue ( 100 - m_vol_percent ); |
546 | if ( force || ( m_mic_percent != old_mp )) | 549 | if ( force || ( m_mic_percent != old_mp )) |
547 | micSlider-> setValue ( 100 - m_mic_percent ); | 550 | micSlider-> setValue ( 100 - m_mic_percent ); |
548 | if ( force || ( m_alarm_percent != old_ap )) | 551 | if ( force || ( m_alarm_percent != old_ap )) |
549 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 552 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
550 | if ( force || ( m_bass_percent != old_bass )) | 553 | if ( force || ( m_bass_percent != old_bass )) |
551 | bassSlider-> setValue ( 100 - m_bass_percent ); | 554 | bassSlider-> setValue ( 100 - m_bass_percent ); |
552 | if ( force || ( m_treble_percent != old_treble )) | 555 | if ( force || ( m_treble_percent != old_treble )) |
553 | trebleSlider-> setValue ( 100 - m_treble_percent ); | 556 | trebleSlider-> setValue ( 100 - m_treble_percent ); |
554 | 557 | ||
555 | 558 | ||
556 | if ( force || ( m_vol_muted != old_vm )) | 559 | if ( force || ( m_vol_muted != old_vm )) |
557 | volLed-> setOn ( !m_vol_muted ); | 560 | volLed-> setOn ( !m_vol_muted ); |
558 | if ( force || ( m_mic_muted != old_mm )) | 561 | if ( force || ( m_mic_muted != old_mm )) |
559 | micLed-> setOn ( !m_mic_muted ); | 562 | micLed-> setOn ( !m_mic_muted ); |
560 | if ( force || ( m_snd_alarm != old_sa )) | 563 | if ( force || ( m_snd_alarm != old_sa )) |
561 | alarmLed-> setOn ( m_snd_alarm ); | 564 | alarmLed-> setOn ( m_snd_alarm ); |
562 | 565 | ||
563 | if ( force || ( m_snd_key != old_sk )) | 566 | if ( force || ( m_snd_key != old_sk )) |
564 | keyBox-> setChecked ( m_snd_key ); | 567 | keyBox-> setChecked ( m_snd_key ); |
565 | if ( force || ( m_snd_touch != old_st )) | 568 | if ( force || ( m_snd_touch != old_st )) |
566 | tapBox-> setChecked ( m_snd_touch ); | 569 | tapBox-> setChecked ( m_snd_touch ); |
567 | if ( force || ( m_snd_alarm != old_sa )) | 570 | if ( force || ( m_snd_alarm != old_sa )) |
568 | alarmBox-> setChecked ( m_snd_alarm ); | 571 | alarmBox-> setChecked ( m_snd_alarm ); |
569 | } | 572 | } |
570 | 573 | ||
571 | 574 | ||
572 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) | 575 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) |
573 | { | 576 | { |
574 | int prevVol = m_vol_percent; | 577 | int prevVol = m_vol_percent; |
575 | bool prevMute = m_vol_muted; | 578 | bool prevMute = m_vol_muted; |
576 | 579 | ||
577 | readConfig ( ); | 580 | readConfig ( ); |
578 | 581 | ||
579 | // Handle case where muting it toggled | 582 | // Handle case where muting it toggled |
580 | if ( m_vol_muted != prevMute ) | 583 | if ( m_vol_muted != prevMute ) |
581 | m_icon-> redraw ( true ); | 584 | m_icon-> redraw ( true ); |
582 | else if ( prevVol != m_vol_percent ) // Avoid over repainting | 585 | else if ( prevVol != m_vol_percent ) // Avoid over repainting |
583 | m_icon-> redraw ( false ); | 586 | m_icon-> redraw ( false ); |
584 | } | 587 | } |
585 | 588 | ||
586 | void VolumeControl::micChanged ( bool nowMuted ) | 589 | void VolumeControl::micChanged ( bool nowMuted ) |
587 | { | 590 | { |
588 | if ( !nowMuted ) | 591 | if ( !nowMuted ) |
589 | readConfig ( ); | 592 | readConfig ( ); |
590 | m_mic_muted = nowMuted; | 593 | m_mic_muted = nowMuted; |
591 | } | 594 | } |
592 | 595 | ||
593 | void VolumeControl::screenTapToggled ( bool b ) | 596 | void VolumeControl::screenTapToggled ( bool b ) |
594 | { | 597 | { |
595 | m_snd_touch = b; | 598 | m_snd_touch = b; |
596 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 599 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
597 | } | 600 | } |
598 | 601 | ||
599 | void VolumeControl::keyClickToggled ( bool b ) | 602 | void VolumeControl::keyClickToggled ( bool b ) |
600 | { | 603 | { |
601 | m_snd_key = b; | 604 | m_snd_key = b; |
602 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 605 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
603 | } | 606 | } |
604 | 607 | ||
605 | void VolumeControl::alarmSoundToggled ( bool b ) | 608 | void VolumeControl::alarmSoundToggled ( bool b ) |
606 | { | 609 | { |
607 | m_snd_alarm = b; | 610 | m_snd_alarm = b; |
608 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 611 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
609 | } | 612 | } |
610 | 613 | ||
611 | void VolumeControl::volMuteToggled ( bool b ) | 614 | void VolumeControl::volMuteToggled ( bool b ) |
612 | { | 615 | { |
613 | m_vol_muted = !b; | 616 | m_vol_muted = !b; |
614 | 617 | ||
615 | m_icon-> redraw ( true ); | 618 | m_icon-> redraw ( true ); |
616 | 619 | ||
617 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 620 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
618 | } | 621 | } |
619 | 622 | ||
620 | void VolumeControl::micMuteToggled ( bool b ) | 623 | void VolumeControl::micMuteToggled ( bool b ) |
621 | { | 624 | { |
622 | m_mic_muted = !b; | 625 | m_mic_muted = !b; |
623 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 626 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
624 | } | 627 | } |
625 | 628 | ||
626 | 629 | ||
627 | void VolumeControl::volMoved ( int percent ) | 630 | void VolumeControl::volMoved ( int percent ) |
628 | { | 631 | { |
629 | m_vol_percent = 100 - percent; | 632 | m_vol_percent = 100 - percent; |
630 | 633 | ||
631 | // clamp volume percent to be between 0 and 100 | 634 | // clamp volume percent to be between 0 and 100 |
632 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 635 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
633 | // repaint just the little volume rectangle | 636 | // repaint just the little volume rectangle |
634 | m_icon-> redraw ( false ); | 637 | m_icon-> redraw ( false ); |
635 | 638 | ||
636 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 639 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
637 | } | 640 | } |
638 | 641 | ||
639 | void VolumeControl::micMoved ( int percent ) | 642 | void VolumeControl::micMoved ( int percent ) |
640 | { | 643 | { |
641 | m_mic_percent = 100 - percent; | 644 | m_mic_percent = 100 - percent; |
642 | 645 | ||
643 | // clamp volume percent to be between 0 and 100 | 646 | // clamp volume percent to be between 0 and 100 |
644 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 647 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
645 | 648 | ||
646 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 649 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
647 | } | 650 | } |
648 | 651 | ||
649 | void VolumeControl::alarmMoved ( int percent ) | 652 | void VolumeControl::alarmMoved ( int percent ) |
650 | { | 653 | { |
651 | m_alarm_percent = 100 - percent; | 654 | m_alarm_percent = 100 - percent; |
652 | 655 | ||
653 | // clamp volume percent to be between 0 and 100 | 656 | // clamp volume percent to be between 0 and 100 |
654 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 657 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
655 | 658 | ||
656 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 659 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
657 | } | 660 | } |
658 | 661 | ||
659 | 662 | ||
660 | void VolumeControl::bassMoved ( int percent ) | 663 | void VolumeControl::bassMoved ( int percent ) |
661 | { | 664 | { |
662 | m_bass_percent = 100 - percent; | 665 | m_bass_percent = 100 - percent; |
663 | 666 | ||
664 | // clamp bass percent to be between 0 and 100 | 667 | // clamp bass percent to be between 0 and 100 |
665 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); | 668 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); |
666 | 669 | ||
667 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | 670 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); |
668 | } | 671 | } |
669 | 672 | ||
670 | 673 | ||
671 | 674 | ||
672 | void VolumeControl::trebleMoved ( int percent ) | 675 | void VolumeControl::trebleMoved ( int percent ) |
673 | { | 676 | { |
674 | m_treble_percent = 100 - percent; | 677 | m_treble_percent = 100 - percent; |
675 | 678 | ||
676 | // clamp treble percent to be between 0 and 100 | 679 | // clamp treble percent to be between 0 and 100 |
677 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); | 680 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); |
678 | 681 | ||
679 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | 682 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); |
680 | } | 683 | } |
681 | 684 | ||
682 | 685 | ||
683 | 686 | ||
684 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 687 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
685 | { | 688 | { |
686 | Config cfg ( "qpe" ); | 689 | Config cfg ( "qpe" ); |
687 | cfg. setGroup ( "Volume" ); | 690 | cfg. setGroup ( "Volume" ); |
688 | cfg. writeEntry ( entry, val ); | 691 | cfg. writeEntry ( entry, val ); |
689 | // cfg. write ( ); | 692 | // cfg. write ( ); |
690 | 693 | ||
691 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 694 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
692 | switch ( upd ) { | 695 | switch ( upd ) { |
693 | case UPD_Vol: { | 696 | case UPD_Vol: { |
694 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 697 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
695 | break; | 698 | break; |
696 | } | 699 | } |
697 | case UPD_Mic: { | 700 | case UPD_Mic: { |
698 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 701 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
699 | break; | 702 | break; |
700 | } | 703 | } |
701 | case UPD_Bass: { | 704 | case UPD_Bass: { |
702 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | 705 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; |
703 | break; | 706 | break; |
704 | } | 707 | } |
705 | case UPD_Treble: { | 708 | case UPD_Treble: { |
706 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | 709 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; |
707 | break; | 710 | break; |
708 | } | 711 | } |
709 | 712 | ||
710 | case UPD_None: | 713 | case UPD_None: |
711 | break; | 714 | break; |
712 | } | 715 | } |
713 | #endif | 716 | #endif |
714 | } | 717 | } |
715 | 718 | ||
716 | //=========================================================================== | 719 | //=========================================================================== |
717 | 720 | ||
718 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 721 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
719 | : QWidget( parent, name ) | 722 | : QWidget( parent, name ) |
720 | { | 723 | { |
721 | setFixedWidth ( AppLnk::smallIconSize() ); | 724 | setFixedWidth ( AppLnk::smallIconSize() ); |
722 | setFixedHeight ( AppLnk::smallIconSize()+4 ); | 725 | setFixedHeight ( AppLnk::smallIconSize()+4 ); |
723 | 726 | ||
724 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); | 727 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); |
725 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); | 728 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); |
726 | 729 | ||
727 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); | 730 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); |
728 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); | 731 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); |
729 | } | 732 | } |
730 | 733 | ||
731 | VolumeApplet::~VolumeApplet() | 734 | VolumeApplet::~VolumeApplet() |
732 | { | 735 | { |
733 | delete m_pixmap; | 736 | delete m_pixmap; |
734 | } | 737 | } |
735 | 738 | ||
736 | int VolumeApplet::position() | 739 | int VolumeApplet::position() |
737 | { | 740 | { |
738 | return 6; | 741 | return 6; |
739 | } | 742 | } |
740 | 743 | ||
741 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 744 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
742 | { | 745 | { |
743 | if ( m_dialog-> isVisible ( )) | 746 | if ( m_dialog-> isVisible ( )) |
744 | m_dialog-> hide ( ); | 747 | m_dialog-> hide ( ); |
745 | else | 748 | else |
746 | m_dialog-> show ( true ); | 749 | m_dialog-> show ( true ); |
747 | } | 750 | } |
748 | 751 | ||
749 | void VolumeApplet::redraw ( bool all ) | 752 | void VolumeApplet::redraw ( bool all ) |
750 | { | 753 | { |
751 | if ( all ) | 754 | if ( all ) |
752 | repaint ( true ); | 755 | repaint ( true ); |
753 | else | 756 | else |
754 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 757 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
755 | } | 758 | } |
756 | 759 | ||
757 | 760 | ||
758 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 761 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
759 | { | 762 | { |
760 | QPainter p ( this ); | 763 | QPainter p ( this ); |
761 | 764 | ||
762 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); | 765 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); |
763 | p. setPen ( darkGray ); | 766 | p. setPen ( darkGray ); |
764 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 767 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
765 | 768 | ||
766 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 769 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
767 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 770 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
768 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 771 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
769 | 772 | ||
770 | if ( m_dialog-> volMuted ( )) { | 773 | if ( m_dialog-> volMuted ( )) { |
771 | p. setPen ( red ); | 774 | p. setPen ( red ); |
772 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 775 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
773 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 776 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
774 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 777 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
775 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 778 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
776 | } | 779 | } |
777 | } | 780 | } |
778 | 781 | ||
779 | 782 | ||
780 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) | 783 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) |
diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index 454a688..958395f 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h | |||
@@ -1,135 +1,135 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __VOLUME_APPLET_H__ | 21 | #ifndef __VOLUME_APPLET_H__ |
22 | #define __VOLUME_APPLET_H__ | 22 | #define __VOLUME_APPLET_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | 26 | ||
27 | class QPixmap; | 27 | class QPixmap; |
28 | class QTimer; | 28 | class QTimer; |
29 | class QSlider; | 29 | class QSlider; |
30 | class QCheckBox; | 30 | class QCheckBox; |
31 | class QButton; | 31 | class QButton; |
32 | class OLedBox; | 32 | namespace Opie { namespace Ui { class OLedBox; }; }; |
33 | 33 | ||
34 | class VolumeApplet; | 34 | class VolumeApplet; |
35 | 35 | ||
36 | class VolumeControl : public QFrame { | 36 | class VolumeControl : public QFrame { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | 38 | ||
39 | public: | 39 | public: |
40 | VolumeControl ( VolumeApplet *icon, bool showMic = false, QWidget *parent=0, const char *name=0 ); | 40 | VolumeControl ( VolumeApplet *icon, bool showMic = false, QWidget *parent=0, const char *name=0 ); |
41 | 41 | ||
42 | bool volMuted ( ) const; | 42 | bool volMuted ( ) const; |
43 | int volPercent ( ) const; | 43 | int volPercent ( ) const; |
44 | 44 | ||
45 | virtual void show ( bool showmic ); | 45 | virtual void show ( bool showmic ); |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | virtual void keyPressEvent ( QKeyEvent * e ); | 48 | virtual void keyPressEvent ( QKeyEvent * e ); |
49 | 49 | ||
50 | protected slots: | 50 | protected slots: |
51 | void volumeChanged ( bool muted ); | 51 | void volumeChanged ( bool muted ); |
52 | void micChanged ( bool muted ); | 52 | void micChanged ( bool muted ); |
53 | 53 | ||
54 | private slots: | 54 | private slots: |
55 | void volMoved ( int percent ); | 55 | void volMoved ( int percent ); |
56 | void micMoved ( int percent ); | 56 | void micMoved ( int percent ); |
57 | void alarmMoved ( int percent ); | 57 | void alarmMoved ( int percent ); |
58 | void bassMoved( int percent ); | 58 | void bassMoved( int percent ); |
59 | void trebleMoved( int percent ); | 59 | void trebleMoved( int percent ); |
60 | 60 | ||
61 | void volMuteToggled ( bool ); | 61 | void volMuteToggled ( bool ); |
62 | void micMuteToggled ( bool ); | 62 | void micMuteToggled ( bool ); |
63 | void alarmSoundToggled ( bool ); | 63 | void alarmSoundToggled ( bool ); |
64 | void keyClickToggled ( bool ); | 64 | void keyClickToggled ( bool ); |
65 | void screenTapToggled ( bool ); | 65 | void screenTapToggled ( bool ); |
66 | 66 | ||
67 | void buttonChanged ( ); | 67 | void buttonChanged ( ); |
68 | void rateTimerDone ( ); | 68 | void rateTimerDone ( ); |
69 | 69 | ||
70 | private: | 70 | private: |
71 | void readConfig ( bool force = false ); | 71 | void readConfig ( bool force = false ); |
72 | 72 | ||
73 | enum eUpdate { | 73 | enum eUpdate { |
74 | UPD_None, | 74 | UPD_None, |
75 | UPD_Vol, | 75 | UPD_Vol, |
76 | UPD_Mic, | 76 | UPD_Mic, |
77 | UPD_Bass, | 77 | UPD_Bass, |
78 | UPD_Treble | 78 | UPD_Treble |
79 | }; | 79 | }; |
80 | void writeConfigEntry ( const char *entry, int val, eUpdate upd ); | 80 | void writeConfigEntry ( const char *entry, int val, eUpdate upd ); |
81 | 81 | ||
82 | 82 | ||
83 | private: | 83 | private: |
84 | QSlider *volSlider; | 84 | QSlider *volSlider; |
85 | QSlider *bassSlider; | 85 | QSlider *bassSlider; |
86 | QSlider *trebleSlider; | 86 | QSlider *trebleSlider; |
87 | QSlider *micSlider; | 87 | QSlider *micSlider; |
88 | QSlider *alarmSlider; | 88 | QSlider *alarmSlider; |
89 | OLedBox *volLed; | 89 | Opie::Ui::OLedBox *volLed; |
90 | OLedBox *micLed; | 90 | Opie::Ui::OLedBox *micLed; |
91 | OLedBox *alarmLed; | 91 | Opie::Ui::OLedBox *alarmLed; |
92 | 92 | ||
93 | QCheckBox *alarmBox; | 93 | QCheckBox *alarmBox; |
94 | QCheckBox *tapBox; | 94 | QCheckBox *tapBox; |
95 | QCheckBox *keyBox; | 95 | QCheckBox *keyBox; |
96 | QPushButton *upButton; | 96 | QPushButton *upButton; |
97 | QPushButton *downButton; | 97 | QPushButton *downButton; |
98 | QTimer *rateTimer; | 98 | QTimer *rateTimer; |
99 | 99 | ||
100 | int m_vol_percent; | 100 | int m_vol_percent; |
101 | int m_mic_percent; | 101 | int m_mic_percent; |
102 | int m_alarm_percent; | 102 | int m_alarm_percent; |
103 | int m_bass_percent; | 103 | int m_bass_percent; |
104 | int m_treble_percent; | 104 | int m_treble_percent; |
105 | bool m_vol_muted; | 105 | bool m_vol_muted; |
106 | bool m_mic_muted; | 106 | bool m_mic_muted; |
107 | bool m_snd_alarm; | 107 | bool m_snd_alarm; |
108 | bool m_snd_touch; | 108 | bool m_snd_touch; |
109 | bool m_snd_key; | 109 | bool m_snd_key; |
110 | 110 | ||
111 | VolumeApplet *m_icon; | 111 | VolumeApplet *m_icon; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | class VolumeApplet : public QWidget { | 114 | class VolumeApplet : public QWidget { |
115 | Q_OBJECT | 115 | Q_OBJECT |
116 | 116 | ||
117 | public: | 117 | public: |
118 | VolumeApplet ( QWidget *parent = 0, const char *name=0 ); | 118 | VolumeApplet ( QWidget *parent = 0, const char *name=0 ); |
119 | ~VolumeApplet ( ); | 119 | ~VolumeApplet ( ); |
120 | static int position(); | 120 | static int position(); |
121 | 121 | ||
122 | void redraw ( bool all = true ); | 122 | void redraw ( bool all = true ); |
123 | 123 | ||
124 | protected: | 124 | protected: |
125 | virtual void mousePressEvent ( QMouseEvent * ); | 125 | virtual void mousePressEvent ( QMouseEvent * ); |
126 | virtual void paintEvent ( QPaintEvent* ); | 126 | virtual void paintEvent ( QPaintEvent* ); |
127 | 127 | ||
128 | private: | 128 | private: |
129 | QPixmap * m_pixmap; | 129 | QPixmap * m_pixmap; |
130 | VolumeControl *m_dialog; | 130 | VolumeControl *m_dialog; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | 133 | ||
134 | #endif // __VOLUME_APPLET_H__ | 134 | #endif // __VOLUME_APPLET_H__ |
135 | 135 | ||
diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro index e118dbd..3067a0f 100644 --- a/core/applets/volumeapplet/volumeapplet.pro +++ b/core/applets/volumeapplet/volumeapplet.pro | |||
@@ -1,14 +1,13 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt plugin warn_on | 2 | CONFIG += qt plugin warn_on |
3 | HEADERS = volume.h oledbox.h | 3 | HEADERS = volume.h |
4 | #SOURCES= volume.cpp oledbox.cpp | ||
5 | SOURCES = volume.cpp | 4 | SOURCES = volume.cpp |
6 | TARGET = volumeapplet | 5 | TARGET = volumeapplet |
7 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
8 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH+= $(OPIEDIR)/include |
9 | DEPENDPATH += | 8 | DEPENDPATH += |
10 | LIBS += -lqpe -lopiecore2 | 9 | LIBS += -lqpe -lopiecore2 -lopieui2 |
11 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
12 | 11 | ||
13 | include( $(OPIEDIR)/include.pro ) | 12 | include( $(OPIEDIR)/include.pro ) |
14 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index 8d71f32..8ea3a48 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp | |||
@@ -1,1003 +1,1005 @@ | |||
1 | #include <opie2/odebug.h> | 1 | #include <opie2/odebug.h> |
2 | #include <opie2/oledbox.h> | 2 | #include <opie2/oledbox.h> |
3 | using namespace Opie::Core; | ||
4 | using namespace Opie::Ui; | ||
3 | 5 | ||
4 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
5 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
6 | #include <qgroupbox.h> | 8 | #include <qgroupbox.h> |
7 | #include <qlabel.h> | 9 | #include <qlabel.h> |
8 | #include <qprogressbar.h> | 10 | #include <qprogressbar.h> |
9 | #include <qheader.h> | 11 | #include <qheader.h> |
10 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
11 | #include <qapplication.h> | 13 | #include <qapplication.h> |
12 | #include <qlistbox.h> | 14 | #include <qlistbox.h> |
13 | #include <qdialog.h> | 15 | #include <qdialog.h> |
14 | #include <qlayout.h> | 16 | #include <qlayout.h> |
15 | #include <qcombobox.h> | 17 | #include <qcombobox.h> |
16 | #include <qlabel.h> | 18 | #include <qlabel.h> |
17 | #include <qlistview.h> | 19 | #include <qlistview.h> |
18 | #include <qpushbutton.h> | 20 | #include <qpushbutton.h> |
19 | 21 | ||
20 | #include <Opietooth.h> | 22 | #include <Opietooth.h> |
21 | #include <OTDriver.h> | 23 | #include <OTDriver.h> |
22 | #include <OTPeer.h> | 24 | #include <OTPeer.h> |
23 | #include <OTGateway.h> | 25 | #include <OTGateway.h> |
24 | #include <OTSDPAttribute.h> | 26 | #include <OTSDPAttribute.h> |
25 | #include <OTSDPService.h> | 27 | #include <OTSDPService.h> |
26 | #include <OTInquiry.h> | 28 | #include <OTInquiry.h> |
27 | 29 | ||
28 | using namespace Opietooth2; | 30 | using namespace Opietooth2; |
29 | 31 | ||
30 | namespace Opietooth2 { | 32 | namespace Opietooth2 { |
31 | 33 | ||
32 | class PeerLVI : public QListViewItem { | 34 | class PeerLVI : public QListViewItem { |
33 | 35 | ||
34 | public : | 36 | public : |
35 | 37 | ||
36 | PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) { | 38 | PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) { |
37 | Peer = P; | 39 | Peer = P; |
38 | } | 40 | } |
39 | ~PeerLVI( void ) { | 41 | ~PeerLVI( void ) { |
40 | } | 42 | } |
41 | 43 | ||
42 | inline OTPeer * peer( void ) | 44 | inline OTPeer * peer( void ) |
43 | { return Peer; } | 45 | { return Peer; } |
44 | 46 | ||
45 | private : | 47 | private : |
46 | 48 | ||
47 | OTPeer * Peer; | 49 | OTPeer * Peer; |
48 | }; | 50 | }; |
49 | 51 | ||
50 | class ChannelLVI : public QListViewItem { | 52 | class ChannelLVI : public QListViewItem { |
51 | 53 | ||
52 | public : | 54 | public : |
53 | 55 | ||
54 | ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) { | 56 | ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) { |
55 | Channel = Ch; | 57 | Channel = Ch; |
56 | } | 58 | } |
57 | ~ChannelLVI( void ) { | 59 | ~ChannelLVI( void ) { |
58 | } | 60 | } |
59 | 61 | ||
60 | inline int channel( void ) | 62 | inline int channel( void ) |
61 | { return Channel; } | 63 | { return Channel; } |
62 | 64 | ||
63 | private : | 65 | private : |
64 | 66 | ||
65 | int Channel; | 67 | int Channel; |
66 | }; | 68 | }; |
67 | 69 | ||
68 | class DriverLVI : public QListViewItem { | 70 | class DriverLVI : public QListViewItem { |
69 | 71 | ||
70 | public : | 72 | public : |
71 | 73 | ||
72 | DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) { | 74 | DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) { |
73 | Driver = P; | 75 | Driver = P; |
74 | } | 76 | } |
75 | ~DriverLVI( void ) { | 77 | ~DriverLVI( void ) { |
76 | } | 78 | } |
77 | 79 | ||
78 | inline OTDriver * driver( void ) | 80 | inline OTDriver * driver( void ) |
79 | { return Driver; } | 81 | { return Driver; } |
80 | 82 | ||
81 | private : | 83 | private : |
82 | 84 | ||
83 | OTDriver * Driver; | 85 | OTDriver * Driver; |
84 | }; | 86 | }; |
85 | 87 | ||
86 | class LinkKeyLVI : public QListViewItem { | 88 | class LinkKeyLVI : public QListViewItem { |
87 | 89 | ||
88 | public : | 90 | public : |
89 | 91 | ||
90 | LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) { | 92 | LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) { |
91 | LinkKey = Ch; | 93 | LinkKey = Ch; |
92 | } | 94 | } |
93 | ~LinkKeyLVI( void ) { | 95 | ~LinkKeyLVI( void ) { |
94 | } | 96 | } |
95 | 97 | ||
96 | inline int index( void ) | 98 | inline int index( void ) |
97 | { return LinkKey; } | 99 | { return LinkKey; } |
98 | 100 | ||
99 | private : | 101 | private : |
100 | 102 | ||
101 | int LinkKey; | 103 | int LinkKey; |
102 | }; | 104 | }; |
103 | }; | 105 | }; |
104 | 106 | ||
105 | // | 107 | // |
106 | // | 108 | // |
107 | // | 109 | // |
108 | // | 110 | // |
109 | // | 111 | // |
110 | 112 | ||
111 | OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : | 113 | OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : |
112 | OTPairingGUI( parent ) { | 114 | OTPairingGUI( parent ) { |
113 | 115 | ||
114 | OT = OTGateway::getOTGateway(); | 116 | OT = OTGateway::getOTGateway(); |
115 | Icons = (_IC ) ? _IC : new OTIcons(); | 117 | Icons = (_IC ) ? _IC : new OTIcons(); |
116 | MyIcons = (_IC == 0 ); | 118 | MyIcons = (_IC == 0 ); |
117 | 119 | ||
118 | // unpairing can only be done if bluetooth is disabled | 120 | // unpairing can only be done if bluetooth is disabled |
119 | Unpair_But->setEnabled( ! OT->isEnabled() ); | 121 | Unpair_But->setEnabled( ! OT->isEnabled() ); |
120 | if( ! OT->isEnabled() ) { | 122 | if( ! OT->isEnabled() ) { |
121 | Unpair_LBL->hide(); | 123 | Unpair_LBL->hide(); |
122 | } else { | 124 | } else { |
123 | Unpair_LBL->show(); | 125 | Unpair_LBL->show(); |
124 | } | 126 | } |
125 | 127 | ||
126 | // open linkkey file and load pairs | 128 | // open linkkey file and load pairs |
127 | LinkKeyArray Keys = OT->getLinkKeys(); | 129 | LinkKeyArray Keys = OT->getLinkKeys(); |
128 | LinkKeyLVI * it; | 130 | LinkKeyLVI * it; |
129 | OTPeer * P; | 131 | OTPeer * P; |
130 | OTDriver * D; | 132 | OTDriver * D; |
131 | 133 | ||
132 | for( unsigned int i = 0 ; | 134 | for( unsigned int i = 0 ; |
133 | i < Keys.count(); | 135 | i < Keys.count(); |
134 | i ++ ) { | 136 | i ++ ) { |
135 | 137 | ||
136 | it = new LinkKeyLVI( i, Pairs_LV ); | 138 | it = new LinkKeyLVI( i, Pairs_LV ); |
137 | 139 | ||
138 | P = 0; | 140 | P = 0; |
139 | D = OT->findDriver( Keys[i].from() ); | 141 | D = OT->findDriver( Keys[i].from() ); |
140 | 142 | ||
141 | if( D ) { | 143 | if( D ) { |
142 | it->setText( 0, D->devname() ); | 144 | it->setText( 0, D->devname() ); |
143 | 145 | ||
144 | // we are source | 146 | // we are source |
145 | P = OT->findPeer( Keys[i].to() ); | 147 | P = OT->findPeer( Keys[i].to() ); |
146 | 148 | ||
147 | if( P ) { | 149 | if( P ) { |
148 | // put name | 150 | // put name |
149 | it->setText( 1, P->name() ); | 151 | it->setText( 1, P->name() ); |
150 | } else { | 152 | } else { |
151 | // unknown | 153 | // unknown |
152 | it->setText( 1, Keys[i].to().toString() ); | 154 | it->setText( 1, Keys[i].to().toString() ); |
153 | } | 155 | } |
154 | 156 | ||
155 | // and put address as sub | 157 | // and put address as sub |
156 | QListViewItem * Sub = new QListViewItem( it ); | 158 | QListViewItem * Sub = new QListViewItem( it ); |
157 | Sub->setText( 0, D->address().toString() ); | 159 | Sub->setText( 0, D->address().toString() ); |
158 | Sub->setText( 1, Keys[i].to().toString() ); | 160 | Sub->setText( 1, Keys[i].to().toString() ); |
159 | } else { | 161 | } else { |
160 | // perhaps we are destination | 162 | // perhaps we are destination |
161 | D = OT->findDriver( Keys[i].to() ); | 163 | D = OT->findDriver( Keys[i].to() ); |
162 | 164 | ||
163 | if( D ) { | 165 | if( D ) { |
164 | it->setText( 1, D->devname() ); | 166 | it->setText( 1, D->devname() ); |
165 | 167 | ||
166 | // we are source | 168 | // we are source |
167 | P = OT->findPeer( Keys[i].from() ); | 169 | P = OT->findPeer( Keys[i].from() ); |
168 | 170 | ||
169 | if( P ) { | 171 | if( P ) { |
170 | // put name | 172 | // put name |
171 | it->setText( 0, P->name() ); | 173 | it->setText( 0, P->name() ); |
172 | } else { | 174 | } else { |
173 | // unknown | 175 | // unknown |
174 | it->setText( 0, Keys[i].from().toString() ); | 176 | it->setText( 0, Keys[i].from().toString() ); |
175 | } | 177 | } |
176 | 178 | ||
177 | // and put address as sub | 179 | // and put address as sub |
178 | QListViewItem * Sub = new QListViewItem( it ); | 180 | QListViewItem * Sub = new QListViewItem( it ); |
179 | Sub->setText( 0, Keys[i].from().toString() ); | 181 | Sub->setText( 0, Keys[i].from().toString() ); |
180 | Sub->setText( 1, D->address().toString() ); | 182 | Sub->setText( 1, D->address().toString() ); |
181 | } else { | 183 | } else { |
182 | // nor source nor destination -> unknown | 184 | // nor source nor destination -> unknown |
183 | it->setText( 0, Keys[i].from().toString() ); | 185 | it->setText( 0, Keys[i].from().toString() ); |
184 | it->setText( 1, Keys[i].to().toString() ); | 186 | it->setText( 1, Keys[i].to().toString() ); |
185 | } | 187 | } |
186 | } | 188 | } |
187 | } | 189 | } |
188 | } | 190 | } |
189 | 191 | ||
190 | 192 | ||
191 | OTPairing::~OTPairing() { | 193 | OTPairing::~OTPairing() { |
192 | if( MyIcons ) | 194 | if( MyIcons ) |
193 | delete Icons; | 195 | delete Icons; |
194 | OTGateway::releaseOTGateway(); | 196 | OTGateway::releaseOTGateway(); |
195 | } | 197 | } |
196 | 198 | ||
197 | void OTPairing::SLOT_Unpair( ) { | 199 | void OTPairing::SLOT_Unpair( ) { |
198 | // find selected pair | 200 | // find selected pair |
199 | 201 | ||
200 | QListViewItem * it = Pairs_LV->firstChild(); | 202 | QListViewItem * it = Pairs_LV->firstChild(); |
201 | while( it ) { | 203 | while( it ) { |
202 | if( it->isSelected() ) { | 204 | if( it->isSelected() ) { |
203 | // confirm ? | 205 | // confirm ? |
204 | if( QMessageBox::warning(0, | 206 | if( QMessageBox::warning(0, |
205 | tr("Break pairing"), | 207 | tr("Break pairing"), |
206 | tr("Sure ?"), | 208 | tr("Sure ?"), |
207 | tr("Yes, break"), | 209 | tr("Yes, break"), |
208 | tr("No, don't break") ) == 0 ) { | 210 | tr("No, don't break") ) == 0 ) { |
209 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; | 211 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; |
210 | // break | 212 | // break |
211 | OT->removeLinkKey( KPIt->index() ); | 213 | OT->removeLinkKey( KPIt->index() ); |
212 | delete KPIt; | 214 | delete KPIt; |
213 | } | 215 | } |
214 | return; | 216 | return; |
215 | } | 217 | } |
216 | it= it->nextSibling(); | 218 | it= it->nextSibling(); |
217 | } | 219 | } |
218 | } | 220 | } |
219 | 221 | ||
220 | // | 222 | // |
221 | // | 223 | // |
222 | // | 224 | // |
223 | // | 225 | // |
224 | // | 226 | // |
225 | 227 | ||
226 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : | 228 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : |
227 | OTScanGUI( parent ), Filter() { | 229 | OTScanGUI( parent ), Filter() { |
228 | 230 | ||
229 | OT = OTGateway::getOTGateway(); | 231 | OT = OTGateway::getOTGateway(); |
230 | Icons = (_IC ) ? _IC : new OTIcons(); | 232 | Icons = (_IC ) ? _IC : new OTIcons(); |
231 | MyIcons = (_IC == 0 ); | 233 | MyIcons = (_IC == 0 ); |
232 | DetectedPeers_LV->header()->hide(); | 234 | DetectedPeers_LV->header()->hide(); |
233 | Current = 0; | 235 | Current = 0; |
234 | SelectedPeer = 0; | 236 | SelectedPeer = 0; |
235 | SelectedChannel = 0; | 237 | SelectedChannel = 0; |
236 | 238 | ||
237 | StrengthTimer = new QTimer( this ); | 239 | StrengthTimer = new QTimer( this ); |
238 | connect( StrengthTimer, | 240 | connect( StrengthTimer, |
239 | SIGNAL( timeout()), | 241 | SIGNAL( timeout()), |
240 | this, | 242 | this, |
241 | SLOT( SLOT_UpdateStrength()) | 243 | SLOT( SLOT_UpdateStrength()) |
242 | ); | 244 | ); |
243 | 245 | ||
244 | connect( OT, | 246 | connect( OT, |
245 | SIGNAL( detectedPeer( OTPeer *, bool )), | 247 | SIGNAL( detectedPeer( OTPeer *, bool )), |
246 | this, | 248 | this, |
247 | SLOT( SLOT_NewPeer( OTPeer *, bool )) | 249 | SLOT( SLOT_NewPeer( OTPeer *, bool )) |
248 | ); | 250 | ); |
249 | connect( OT, | 251 | connect( OT, |
250 | SIGNAL( finishedDetecting()), | 252 | SIGNAL( finishedDetecting()), |
251 | this, | 253 | this, |
252 | SLOT( SLOT_FinishedDetecting()) | 254 | SLOT( SLOT_FinishedDetecting()) |
253 | ); | 255 | ); |
254 | 256 | ||
255 | // populate with peers we already know about | 257 | // populate with peers we already know about |
256 | const PeerVector & P = OT->peers(); | 258 | const PeerVector & P = OT->peers(); |
257 | for( unsigned int i = 0; | 259 | for( unsigned int i = 0; |
258 | i < P.count(); | 260 | i < P.count(); |
259 | i ++ ) { | 261 | i ++ ) { |
260 | SLOT_NewPeer( P[i], TRUE ); | 262 | SLOT_NewPeer( P[i], TRUE ); |
261 | } | 263 | } |
262 | 264 | ||
263 | // populate State fram | 265 | // populate State fram |
264 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); | 266 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); |
265 | 267 | ||
266 | Paired_Led = new OLedBox( green, State_Frm ); | 268 | Paired_Led = new OLedBox( green, State_Frm ); |
267 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); | 269 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); |
268 | 270 | ||
269 | H->addWidget( Paired_Led ); | 271 | H->addWidget( Paired_Led ); |
270 | H->addWidget( L1 ); | 272 | H->addWidget( L1 ); |
271 | H->addStretch( 1 ); | 273 | H->addStretch( 1 ); |
272 | } | 274 | } |
273 | } | 275 | } |
274 | 276 | ||
275 | OTScan::~OTScan() { | 277 | OTScan::~OTScan() { |
276 | if( MyIcons ) | 278 | if( MyIcons ) |
277 | delete Icons; | 279 | delete Icons; |
278 | OTGateway::releaseOTGateway(); | 280 | OTGateway::releaseOTGateway(); |
279 | 281 | ||
280 | // send all peers that we do not care about states | 282 | // send all peers that we do not care about states |
281 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 283 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
282 | while( Lit ) { | 284 | while( Lit ) { |
283 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); | 285 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); |
284 | Lit = Lit->nextSibling(); | 286 | Lit = Lit->nextSibling(); |
285 | } | 287 | } |
286 | } | 288 | } |
287 | 289 | ||
288 | // static scan dialog function | 290 | // static scan dialog function |
289 | int OTScan::getDevice( OTPeer *& Peer, | 291 | int OTScan::getDevice( OTPeer *& Peer, |
290 | int & Channel, | 292 | int & Channel, |
291 | OTGateway * OT, | 293 | OTGateway * OT, |
292 | const UUIDVector & Filter, | 294 | const UUIDVector & Filter, |
293 | QWidget* Parent ) { | 295 | QWidget* Parent ) { |
294 | bool IsUp = 0; | 296 | bool IsUp = 0; |
295 | unsigned int i; | 297 | unsigned int i; |
296 | 298 | ||
297 | // check if bluetooth is up | 299 | // check if bluetooth is up |
298 | OTDriverList & DL = OT->getDriverList(); | 300 | OTDriverList & DL = OT->getDriverList(); |
299 | for( i = 0; | 301 | for( i = 0; |
300 | i < DL.count(); | 302 | i < DL.count(); |
301 | i ++ ) { | 303 | i ++ ) { |
302 | if( DL[i]->isUp() ) { | 304 | if( DL[i]->isUp() ) { |
303 | // one device that is up found | 305 | // one device that is up found |
304 | IsUp = 1; | 306 | IsUp = 1; |
305 | break; | 307 | break; |
306 | } | 308 | } |
307 | } | 309 | } |
308 | 310 | ||
309 | // use this driver | 311 | // use this driver |
310 | OT->setScanWith( OT->driver(i) ); | 312 | OT->setScanWith( OT->driver(i) ); |
311 | 313 | ||
312 | // create dialog | 314 | // create dialog |
313 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); | 315 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); |
314 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 316 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
315 | OTScan * Scn = new OTScan( Dlg ); | 317 | OTScan * Scn = new OTScan( Dlg ); |
316 | 318 | ||
317 | connect( Scn, | 319 | connect( Scn, |
318 | SIGNAL( selected() ), | 320 | SIGNAL( selected() ), |
319 | Dlg, | 321 | Dlg, |
320 | SLOT( accept() ) | 322 | SLOT( accept() ) |
321 | ); | 323 | ); |
322 | 324 | ||
323 | if( Filter ) { | 325 | if( Filter ) { |
324 | Scn->setScanFilter( Filter ); | 326 | Scn->setScanFilter( Filter ); |
325 | } | 327 | } |
326 | 328 | ||
327 | V->addWidget( Scn ); | 329 | V->addWidget( Scn ); |
328 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); | 330 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); |
329 | Dlg->showMaximized(); | 331 | Dlg->showMaximized(); |
330 | int rv = Dlg->exec(); | 332 | int rv = Dlg->exec(); |
331 | 333 | ||
332 | if( rv == QDialog::Accepted ) { | 334 | if( rv == QDialog::Accepted ) { |
333 | // get peer | 335 | // get peer |
334 | Peer = Scn->selectedPeer(); | 336 | Peer = Scn->selectedPeer(); |
335 | if( Peer == 0 ) { | 337 | if( Peer == 0 ) { |
336 | // no peer selected | 338 | // no peer selected |
337 | rv = QDialog::Rejected; | 339 | rv = QDialog::Rejected; |
338 | } else { | 340 | } else { |
339 | Channel = Scn->selectedChannel(); | 341 | Channel = Scn->selectedChannel(); |
340 | } | 342 | } |
341 | } | 343 | } |
342 | 344 | ||
343 | delete Dlg; | 345 | delete Dlg; |
344 | 346 | ||
345 | return rv; | 347 | return rv; |
346 | } | 348 | } |
347 | 349 | ||
348 | void OTScan::setScanFilter( const UUIDVector & V ) { | 350 | void OTScan::setScanFilter( const UUIDVector & V ) { |
349 | Filter = V; | 351 | Filter = V; |
350 | } | 352 | } |
351 | 353 | ||
352 | void OTScan::resetScanFilter( void ) { | 354 | void OTScan::resetScanFilter( void ) { |
353 | Filter.truncate(0); | 355 | Filter.truncate(0); |
354 | } | 356 | } |
355 | 357 | ||
356 | void OTScan::SLOT_DoScan( bool DoIt ) { | 358 | void OTScan::SLOT_DoScan( bool DoIt ) { |
357 | if( DoIt ) { | 359 | if( DoIt ) { |
358 | OT->scanNeighbourhood(); | 360 | OT->scanNeighbourhood(); |
359 | } else { | 361 | } else { |
360 | OT->stopScanOfNeighbourhood(); | 362 | OT->stopScanOfNeighbourhood(); |
361 | } | 363 | } |
362 | 364 | ||
363 | scanMode( DoIt ); | 365 | scanMode( DoIt ); |
364 | } | 366 | } |
365 | 367 | ||
366 | // double clicked on a device | 368 | // double clicked on a device |
367 | void OTScan::SLOT_Selected( QListViewItem * it ) { | 369 | void OTScan::SLOT_Selected( QListViewItem * it ) { |
368 | if( ! it ) | 370 | if( ! it ) |
369 | return; | 371 | return; |
370 | 372 | ||
371 | if( Filter.count() > 0 ) { | 373 | if( Filter.count() > 0 ) { |
372 | // filter on service | 374 | // filter on service |
373 | if( it->depth() == 0 ) { | 375 | if( it->depth() == 0 ) { |
374 | // select a service and not a device | 376 | // select a service and not a device |
375 | return; | 377 | return; |
376 | } | 378 | } |
377 | 379 | ||
378 | // store result | 380 | // store result |
379 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); | 381 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); |
380 | SelectedChannel = ((ChannelLVI *)it)->channel(); | 382 | SelectedChannel = ((ChannelLVI *)it)->channel(); |
381 | } else { | 383 | } else { |
382 | // click on device | 384 | // click on device |
383 | if( it->depth() != 0 ) { | 385 | if( it->depth() != 0 ) { |
384 | return; | 386 | return; |
385 | } | 387 | } |
386 | 388 | ||
387 | SelectedPeer = ((PeerLVI *)it)->peer(); | 389 | SelectedPeer = ((PeerLVI *)it)->peer(); |
388 | SelectedChannel = 0; | 390 | SelectedChannel = 0; |
389 | } | 391 | } |
390 | owarn << "Selected " << SelectedPeer->address().toString() << | 392 | owarn << "Selected " << SelectedPeer->address().toString() << |
391 | " Channel " << SelectedChannel << oendl; | 393 | " Channel " << SelectedChannel << oendl; |
392 | emit selected(); | 394 | emit selected(); |
393 | } | 395 | } |
394 | 396 | ||
395 | void OTScan::SLOT_FinishedDetecting( ) { | 397 | void OTScan::SLOT_FinishedDetecting( ) { |
396 | scanMode( false ); | 398 | scanMode( false ); |
397 | } | 399 | } |
398 | 400 | ||
399 | void OTScan::SLOT_CleanupOld( ) { | 401 | void OTScan::SLOT_CleanupOld( ) { |
400 | 402 | ||
401 | // iterate over all peers and find those that | 403 | // iterate over all peers and find those that |
402 | // are down and have no pairing info | 404 | // are down and have no pairing info |
403 | OTPeer * TheP; | 405 | OTPeer * TheP; |
404 | const LinkKeyArray & Keys = OT->getLinkKeys(); | 406 | const LinkKeyArray & Keys = OT->getLinkKeys(); |
405 | 407 | ||
406 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 408 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
407 | while( Lit ) { | 409 | while( Lit ) { |
408 | TheP = ((PeerLVI *)Lit)->peer(); | 410 | TheP = ((PeerLVI *)Lit)->peer(); |
409 | if( TheP->state() == OTPeer::Peer_Down ) { | 411 | if( TheP->state() == OTPeer::Peer_Down ) { |
410 | unsigned int k; | 412 | unsigned int k; |
411 | 413 | ||
412 | // what about linkkeys ? | 414 | // what about linkkeys ? |
413 | for( k = 0; k < Keys.count(); k ++ ) { | 415 | for( k = 0; k < Keys.count(); k ++ ) { |
414 | if( TheP->address() == Keys[k].to() || | 416 | if( TheP->address() == Keys[k].to() || |
415 | TheP->address() == Keys[k].from() | 417 | TheP->address() == Keys[k].from() |
416 | ) { | 418 | ) { |
417 | // part of linkkey | 419 | // part of linkkey |
418 | owarn << "LINKKEY " << TheP->address().toString() << oendl; | 420 | owarn << "LINKKEY " << TheP->address().toString() << oendl; |
419 | break; | 421 | break; |
420 | } | 422 | } |
421 | } | 423 | } |
422 | 424 | ||
423 | if( k == Keys.count() ) { | 425 | if( k == Keys.count() ) { |
424 | owarn << "RM LINKKEY " << TheP->address().toString() << oendl; | 426 | owarn << "RM LINKKEY " << TheP->address().toString() << oendl; |
425 | // not found -> remember to remove this peer | 427 | // not found -> remember to remove this peer |
426 | QListViewItem * Nit; | 428 | QListViewItem * Nit; |
427 | OT->removePeer( TheP ); | 429 | OT->removePeer( TheP ); |
428 | Nit = Lit->nextSibling(); | 430 | Nit = Lit->nextSibling(); |
429 | delete Lit; | 431 | delete Lit; |
430 | Lit = Nit; | 432 | Lit = Nit; |
431 | continue; | 433 | continue; |
432 | } | 434 | } |
433 | } else { | 435 | } else { |
434 | owarn << "NODOWN " << TheP->address().toString() << oendl; | 436 | owarn << "NODOWN " << TheP->address().toString() << oendl; |
435 | } | 437 | } |
436 | 438 | ||
437 | Lit = Lit->nextSibling(); | 439 | Lit = Lit->nextSibling(); |
438 | } | 440 | } |
439 | } | 441 | } |
440 | 442 | ||
441 | void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ | 443 | void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ |
442 | PeerLVI * it = 0; | 444 | PeerLVI * it = 0; |
443 | 445 | ||
444 | if( IsNew ) { | 446 | if( IsNew ) { |
445 | it = new PeerLVI( P, DetectedPeers_LV ); | 447 | it = new PeerLVI( P, DetectedPeers_LV ); |
446 | } else { | 448 | } else { |
447 | // find peer in table | 449 | // find peer in table |
448 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 450 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
449 | while( Lit ) { | 451 | while( Lit ) { |
450 | if( ((PeerLVI *)Lit)->peer() == P ) { | 452 | if( ((PeerLVI *)Lit)->peer() == P ) { |
451 | // this item | 453 | // this item |
452 | it = (PeerLVI *)Lit; | 454 | it = (PeerLVI *)Lit; |
453 | break; | 455 | break; |
454 | } | 456 | } |
455 | Lit = Lit->nextSibling(); | 457 | Lit = Lit->nextSibling(); |
456 | } | 458 | } |
457 | 459 | ||
458 | if( ! it ) { | 460 | if( ! it ) { |
459 | owarn << "Should not occur" << oendl; | 461 | owarn << "Should not occur" << oendl; |
460 | return; | 462 | return; |
461 | } | 463 | } |
462 | } | 464 | } |
463 | 465 | ||
464 | // update/show info | 466 | // update/show info |
465 | it->setText( 0, P->name() ); | 467 | it->setText( 0, P->name() ); |
466 | it->setPixmap(0, Icons->deviceIcon( | 468 | it->setPixmap(0, Icons->deviceIcon( |
467 | OT->deviceTypeToName( P->deviceClass() ) ) ); | 469 | OT->deviceTypeToName( P->deviceClass() ) ) ); |
468 | 470 | ||
469 | // tell peer to report its state async | 471 | // tell peer to report its state async |
470 | connect( P, | 472 | connect( P, |
471 | SIGNAL( peerStateReport( OTPeer *)), | 473 | SIGNAL( peerStateReport( OTPeer *)), |
472 | this, | 474 | this, |
473 | SLOT( SLOT_PeerState( OTPeer *)) | 475 | SLOT( SLOT_PeerState( OTPeer *)) |
474 | ); | 476 | ); |
475 | 477 | ||
476 | if( IsNew ) { | 478 | if( IsNew ) { |
477 | // find state | 479 | // find state |
478 | refreshState( (PeerLVI *)it, 1 ); | 480 | refreshState( (PeerLVI *)it, 1 ); |
479 | } else { | 481 | } else { |
480 | // update staet | 482 | // update staet |
481 | SLOT_PeerState( P ); | 483 | SLOT_PeerState( P ); |
482 | } | 484 | } |
483 | } | 485 | } |
484 | 486 | ||
485 | void OTScan::SLOT_PeerState( OTPeer * P ) { | 487 | void OTScan::SLOT_PeerState( OTPeer * P ) { |
486 | PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); | 488 | PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); |
487 | while( it ) { | 489 | while( it ) { |
488 | if( it->peer() == P ) { | 490 | if( it->peer() == P ) { |
489 | break; | 491 | break; |
490 | } | 492 | } |
491 | it = (PeerLVI * )it->nextSibling(); | 493 | it = (PeerLVI * )it->nextSibling(); |
492 | } | 494 | } |
493 | 495 | ||
494 | if( ! it ) | 496 | if( ! it ) |
495 | return; | 497 | return; |
496 | 498 | ||
497 | switch( P->state() ) { | 499 | switch( P->state() ) { |
498 | case OTPeer::Peer_Unknown : | 500 | case OTPeer::Peer_Unknown : |
499 | case OTPeer::Peer_Down : | 501 | case OTPeer::Peer_Down : |
500 | it->setPixmap( 1, 0 ); | 502 | it->setPixmap( 1, 0 ); |
501 | break; | 503 | break; |
502 | case OTPeer::Peer_Up : | 504 | case OTPeer::Peer_Up : |
503 | it->setPixmap( 1, Icons->loadPixmap( | 505 | it->setPixmap( 1, Icons->loadPixmap( |
504 | ( P->connectedTo() ) ? "connected" : "notconnected" ) ); | 506 | ( P->connectedTo() ) ? "connected" : "notconnected" ) ); |
505 | if( it == Current && ! StrengthTimer->isActive() ) { | 507 | if( it == Current && ! StrengthTimer->isActive() ) { |
506 | // start showing strength | 508 | // start showing strength |
507 | StrengthTimer->start( 1000, FALSE ); | 509 | StrengthTimer->start( 1000, FALSE ); |
508 | SLOT_UpdateStrength(); | 510 | SLOT_UpdateStrength(); |
509 | } | 511 | } |
510 | break; | 512 | break; |
511 | } | 513 | } |
512 | } | 514 | } |
513 | 515 | ||
514 | void OTScan::SLOT_RefreshState( void ) { | 516 | void OTScan::SLOT_RefreshState( void ) { |
515 | 517 | ||
516 | QListViewItem * it = DetectedPeers_LV->firstChild(); | 518 | QListViewItem * it = DetectedPeers_LV->firstChild(); |
517 | while( it ) { | 519 | while( it ) { |
518 | if( it->isSelected() ) { | 520 | if( it->isSelected() ) { |
519 | break; | 521 | break; |
520 | } | 522 | } |
521 | it = it->nextSibling(); | 523 | it = it->nextSibling(); |
522 | } | 524 | } |
523 | 525 | ||
524 | if( ! it ) | 526 | if( ! it ) |
525 | return; | 527 | return; |
526 | 528 | ||
527 | refreshState( (PeerLVI *)it, 1 ); | 529 | refreshState( (PeerLVI *)it, 1 ); |
528 | } | 530 | } |
529 | 531 | ||
530 | void OTScan::refreshState( PeerLVI * it, bool Force ) { | 532 | void OTScan::refreshState( PeerLVI * it, bool Force ) { |
531 | it->setPixmap( 1, Icons->loadPixmap( "find" ) ); | 533 | it->setPixmap( 1, Icons->loadPixmap( "find" ) ); |
532 | it->peer()->findOutState( 30, Force ); | 534 | it->peer()->findOutState( 30, Force ); |
533 | } | 535 | } |
534 | 536 | ||
535 | void OTScan::SLOT_Show( QListViewItem * it ) { | 537 | void OTScan::SLOT_Show( QListViewItem * it ) { |
536 | 538 | ||
537 | if( ! it || it->depth() > 0 ) | 539 | if( ! it || it->depth() > 0 ) |
538 | return; | 540 | return; |
539 | 541 | ||
540 | QString S; | 542 | QString S; |
541 | 543 | ||
542 | Current = (PeerLVI *)it; | 544 | Current = (PeerLVI *)it; |
543 | 545 | ||
544 | Strength_PB->setProgress( 0 ); // reset | 546 | Strength_PB->setProgress( 0 ); // reset |
545 | Address_LBL->setText( Current->peer()->address().toString() ); | 547 | Address_LBL->setText( Current->peer()->address().toString() ); |
546 | Peer_GB->setTitle( Current->peer()->name() ); | 548 | Peer_GB->setTitle( Current->peer()->name() ); |
547 | 549 | ||
548 | const LinkKeyArray & Keys = OT->getLinkKeys(); | 550 | const LinkKeyArray & Keys = OT->getLinkKeys(); |
549 | 551 | ||
550 | Paired_Led->setOn( FALSE ); | 552 | Paired_Led->setOn( FALSE ); |
551 | for( unsigned int i = 0; | 553 | for( unsigned int i = 0; |
552 | i < Keys.count(); | 554 | i < Keys.count(); |
553 | i ++ ) { | 555 | i ++ ) { |
554 | if( Current->peer()->address() == Keys[i].to() ) { | 556 | if( Current->peer()->address() == Keys[i].to() ) { |
555 | Paired_Led->setOn( TRUE ); | 557 | Paired_Led->setOn( TRUE ); |
556 | break; | 558 | break; |
557 | } | 559 | } |
558 | } | 560 | } |
559 | 561 | ||
560 | if( Current->peer()->state() == OTPeer::Peer_Up ) { | 562 | if( Current->peer()->state() == OTPeer::Peer_Up ) { |
561 | RefreshServices_But->setEnabled( TRUE ); | 563 | RefreshServices_But->setEnabled( TRUE ); |
562 | StrengthTimer->start( 1000, FALSE ); | 564 | StrengthTimer->start( 1000, FALSE ); |
563 | SLOT_UpdateStrength(); | 565 | SLOT_UpdateStrength(); |
564 | } else { | 566 | } else { |
565 | RefreshServices_But->setEnabled( FALSE ); | 567 | RefreshServices_But->setEnabled( FALSE ); |
566 | } | 568 | } |
567 | 569 | ||
568 | } | 570 | } |
569 | 571 | ||
570 | void OTScan::SLOT_UpdateStrength( void ) { | 572 | void OTScan::SLOT_UpdateStrength( void ) { |
571 | OTDriver * D = Current->peer()->connectedTo(); | 573 | OTDriver * D = Current->peer()->connectedTo(); |
572 | 574 | ||
573 | if( D ) { | 575 | if( D ) { |
574 | long Q = D->getLinkQuality( Current->peer()->address() ); | 576 | long Q = D->getLinkQuality( Current->peer()->address() ); |
575 | Strength_PB->setProgress( Q ); | 577 | Strength_PB->setProgress( Q ); |
576 | if( ! Q ) { | 578 | if( ! Q ) { |
577 | // no quality | 579 | // no quality |
578 | Strength_PB->setEnabled( TRUE ); | 580 | Strength_PB->setEnabled( TRUE ); |
579 | StrengthTimer->stop(); | 581 | StrengthTimer->stop(); |
580 | } | 582 | } |
581 | } else { | 583 | } else { |
582 | Strength_PB->setEnabled( FALSE ); | 584 | Strength_PB->setEnabled( FALSE ); |
583 | Strength_PB->setProgress( 0 ); | 585 | Strength_PB->setProgress( 0 ); |
584 | // no point in continuing | 586 | // no point in continuing |
585 | StrengthTimer->stop(); | 587 | StrengthTimer->stop(); |
586 | } | 588 | } |
587 | } | 589 | } |
588 | 590 | ||
589 | void OTScan::SLOT_RefreshServices( void ) { | 591 | void OTScan::SLOT_RefreshServices( void ) { |
590 | 592 | ||
591 | QListViewItem * it = DetectedPeers_LV->firstChild(); | 593 | QListViewItem * it = DetectedPeers_LV->firstChild(); |
592 | while( it ) { | 594 | while( it ) { |
593 | if( it->isSelected() ) { | 595 | if( it->isSelected() ) { |
594 | break; | 596 | break; |
595 | } | 597 | } |
596 | it = it->nextSibling(); | 598 | it = it->nextSibling(); |
597 | } | 599 | } |
598 | 600 | ||
599 | if( ! it ) | 601 | if( ! it ) |
600 | return; | 602 | return; |
601 | 603 | ||
602 | QString S; | 604 | QString S; |
603 | PeerLVI * PI = (PeerLVI *)it; | 605 | PeerLVI * PI = (PeerLVI *)it; |
604 | 606 | ||
605 | scanMode( true ); | 607 | scanMode( true ); |
606 | qApp->processEvents(0); | 608 | qApp->processEvents(0); |
607 | 609 | ||
608 | ServiceVector & V = PI->peer()->services(); | 610 | ServiceVector & V = PI->peer()->services(); |
609 | 611 | ||
610 | while( PI->firstChild() ) { | 612 | while( PI->firstChild() ) { |
611 | // remove children | 613 | // remove children |
612 | delete PI->firstChild(); | 614 | delete PI->firstChild(); |
613 | } | 615 | } |
614 | 616 | ||
615 | for( unsigned int i = 0 ; | 617 | for( unsigned int i = 0 ; |
616 | i < V.count(); | 618 | i < V.count(); |
617 | i ++ ) { | 619 | i ++ ) { |
618 | QString S; | 620 | QString S; |
619 | S = V[i]->name(); | 621 | S = V[i]->name(); |
620 | 622 | ||
621 | if( S.isEmpty() ) { | 623 | if( S.isEmpty() ) { |
622 | continue; | 624 | continue; |
623 | } | 625 | } |
624 | 626 | ||
625 | { QListViewItem * SIt; | 627 | { QListViewItem * SIt; |
626 | UUIDVector UIDV; | 628 | UUIDVector UIDV; |
627 | QPixmap Pm; | 629 | QPixmap Pm; |
628 | bool Done = 0; | 630 | bool Done = 0; |
629 | bool R; | 631 | bool R; |
630 | short ID; | 632 | short ID; |
631 | 633 | ||
632 | SIt = 0; | 634 | SIt = 0; |
633 | 635 | ||
634 | UIDV = V[i]->classIDList(); | 636 | UIDV = V[i]->classIDList(); |
635 | // first all UUID ! 1200 12ff (Genericprofiles) | 637 | // first all UUID ! 1200 12ff (Genericprofiles) |
636 | for( unsigned int j = 0; | 638 | for( unsigned int j = 0; |
637 | j < UIDV.count(); | 639 | j < UIDV.count(); |
638 | j ++ ) { | 640 | j ++ ) { |
639 | 641 | ||
640 | if( Filter.count() ) { | 642 | if( Filter.count() ) { |
641 | bool FilterOut = 1; | 643 | bool FilterOut = 1; |
642 | // filter out if not in list | 644 | // filter out if not in list |
643 | for( unsigned int ff = 0; | 645 | for( unsigned int ff = 0; |
644 | ff < Filter.count(); | 646 | ff < Filter.count(); |
645 | ff ++ ) { | 647 | ff ++ ) { |
646 | if( UIDV[j] == Filter[ff] ) { | 648 | if( UIDV[j] == Filter[ff] ) { |
647 | FilterOut = 0; | 649 | FilterOut = 0; |
648 | break; | 650 | break; |
649 | } | 651 | } |
650 | } | 652 | } |
651 | 653 | ||
652 | if( FilterOut ) { | 654 | if( FilterOut ) { |
653 | // not in filter list | 655 | // not in filter list |
654 | continue; | 656 | continue; |
655 | } | 657 | } |
656 | } // else show | 658 | } // else show |
657 | 659 | ||
658 | ID = UIDV[j].toShort(); | 660 | ID = UIDV[j].toShort(); |
659 | if( ID < 0x1200 || ID > 0x12ff ) { | 661 | if( ID < 0x1200 || ID > 0x12ff ) { |
660 | // use this profile | 662 | // use this profile |
661 | if( R ) { | 663 | if( R ) { |
662 | unsigned int ch; | 664 | unsigned int ch; |
663 | bool has; | 665 | bool has; |
664 | has = V[i]->rfcommChannel( ch ); | 666 | has = V[i]->rfcommChannel( ch ); |
665 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); | 667 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); |
666 | SIt->setText(0, V[i]->name() ); | 668 | SIt->setText(0, V[i]->name() ); |
667 | 669 | ||
668 | Pm = Icons->serviceIcon( ID, R ); | 670 | Pm = Icons->serviceIcon( ID, R ); |
669 | SIt->setPixmap(0, Pm ); | 671 | SIt->setPixmap(0, Pm ); |
670 | Done = 1; | 672 | Done = 1; |
671 | break; | 673 | break; |
672 | } | 674 | } |
673 | } | 675 | } |
674 | } | 676 | } |
675 | 677 | ||
676 | if( ! Done ) { | 678 | if( ! Done ) { |
677 | // check other range too | 679 | // check other range too |
678 | for( unsigned int j = 0; | 680 | for( unsigned int j = 0; |
679 | j < UIDV.count(); | 681 | j < UIDV.count(); |
680 | j ++ ) { | 682 | j ++ ) { |
681 | 683 | ||
682 | if( Filter.count() ) { | 684 | if( Filter.count() ) { |
683 | bool FilterOut = 1; | 685 | bool FilterOut = 1; |
684 | // filter out if not in list | 686 | // filter out if not in list |
685 | for( unsigned int ff = 0; | 687 | for( unsigned int ff = 0; |
686 | ff < Filter.count(); | 688 | ff < Filter.count(); |
687 | ff ++ ) { | 689 | ff ++ ) { |
688 | if( UIDV[j] == Filter[ff] ) { | 690 | if( UIDV[j] == Filter[ff] ) { |
689 | FilterOut = 0; | 691 | FilterOut = 0; |
690 | break; | 692 | break; |
691 | } | 693 | } |
692 | } | 694 | } |
693 | 695 | ||
694 | if( FilterOut ) { | 696 | if( FilterOut ) { |
695 | // not in filter list | 697 | // not in filter list |
696 | continue; | 698 | continue; |
697 | } | 699 | } |
698 | } // else show | 700 | } // else show |
699 | 701 | ||
700 | ID = UIDV[j].toShort(); | 702 | ID = UIDV[j].toShort(); |
701 | if( ID >= 0x1200 && ID <= 0x12ff ) { | 703 | if( ID >= 0x1200 && ID <= 0x12ff ) { |
702 | // use this profile | 704 | // use this profile |
703 | unsigned int ch; | 705 | unsigned int ch; |
704 | bool has; | 706 | bool has; |
705 | has = V[i]->rfcommChannel( ch ); | 707 | has = V[i]->rfcommChannel( ch ); |
706 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); | 708 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); |
707 | SIt->setText(0, V[i]->name() ); | 709 | SIt->setText(0, V[i]->name() ); |
708 | 710 | ||
709 | Pm = Icons->serviceIcon( ID, R ); | 711 | Pm = Icons->serviceIcon( ID, R ); |
710 | SIt->setPixmap(0, Pm ); | 712 | SIt->setPixmap(0, Pm ); |
711 | 713 | ||
712 | break; | 714 | break; |
713 | } | 715 | } |
714 | } | 716 | } |
715 | } | 717 | } |
716 | 718 | ||
717 | } | 719 | } |
718 | } | 720 | } |
719 | 721 | ||
720 | scanMode( false ); | 722 | scanMode( false ); |
721 | } | 723 | } |
722 | 724 | ||
723 | void OTScan::scanMode( bool M ) { | 725 | void OTScan::scanMode( bool M ) { |
724 | // avoid infinite loop because it triggers DoScan | 726 | // avoid infinite loop because it triggers DoScan |
725 | Detect_But->blockSignals( TRUE ); | 727 | Detect_But->blockSignals( TRUE ); |
726 | Detect_But->setOn( M ); | 728 | Detect_But->setOn( M ); |
727 | Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); | 729 | Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); |
728 | Detect_But->blockSignals( FALSE ); | 730 | Detect_But->blockSignals( FALSE ); |
729 | } | 731 | } |
730 | 732 | ||
731 | // | 733 | // |
732 | // | 734 | // |
733 | // | 735 | // |
734 | // | 736 | // |
735 | // | 737 | // |
736 | 738 | ||
737 | OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : | 739 | OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : |
738 | OTManageGUI( parent ) { | 740 | OTManageGUI( parent ) { |
739 | 741 | ||
740 | OT = OTGateway::getOTGateway(); | 742 | OT = OTGateway::getOTGateway(); |
741 | 743 | ||
742 | Icons = (_IC ) ? _IC : new OTIcons(); | 744 | Icons = (_IC ) ? _IC : new OTIcons(); |
743 | MyIcons = (_IC == 0 ); | 745 | MyIcons = (_IC == 0 ); |
744 | AllDrivers_LV->setSorting(-1); | 746 | AllDrivers_LV->setSorting(-1); |
745 | 747 | ||
746 | connect( OT, | 748 | connect( OT, |
747 | SIGNAL( driverListChanged() ), | 749 | SIGNAL( driverListChanged() ), |
748 | this, | 750 | this, |
749 | SLOT( SLOT_DriverListChanged() ) | 751 | SLOT( SLOT_DriverListChanged() ) |
750 | ); | 752 | ); |
751 | connect( OT, | 753 | connect( OT, |
752 | SIGNAL( stateChange( OTDriver *, bool ) ), | 754 | SIGNAL( stateChange( OTDriver *, bool ) ), |
753 | this, | 755 | this, |
754 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) | 756 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) |
755 | ); | 757 | ); |
756 | 758 | ||
757 | SLOT_DriverListChanged(); | 759 | SLOT_DriverListChanged(); |
758 | 760 | ||
759 | AllDrivers_LV->header()->hide(); | 761 | AllDrivers_LV->header()->hide(); |
760 | } | 762 | } |
761 | 763 | ||
762 | OTManage::~OTManage() { | 764 | OTManage::~OTManage() { |
763 | if( MyIcons ) | 765 | if( MyIcons ) |
764 | delete Icons; | 766 | delete Icons; |
765 | OTGateway::releaseOTGateway(); | 767 | OTGateway::releaseOTGateway(); |
766 | } | 768 | } |
767 | 769 | ||
768 | void OTManage::SLOT_ShowDriver( QListViewItem * It ) { | 770 | void OTManage::SLOT_ShowDriver( QListViewItem * It ) { |
769 | if( It == 0 || It->depth() > 0 ) | 771 | if( It == 0 || It->depth() > 0 ) |
770 | // not toplevel | 772 | // not toplevel |
771 | return; | 773 | return; |
772 | 774 | ||
773 | DriverLVI * it = (DriverLVI *) It; | 775 | DriverLVI * it = (DriverLVI *) It; |
774 | DriverIsUp_CB->setChecked( it->driver()->isUp() ); | 776 | DriverIsUp_CB->setChecked( it->driver()->isUp() ); |
775 | } | 777 | } |
776 | 778 | ||
777 | void OTManage::SLOT_UpDriver( bool Up ) { | 779 | void OTManage::SLOT_UpDriver( bool Up ) { |
778 | QListViewItem * it = AllDrivers_LV->firstChild(); | 780 | QListViewItem * it = AllDrivers_LV->firstChild(); |
779 | while( it ) { | 781 | while( it ) { |
780 | if( it->isSelected() ) { | 782 | if( it->isSelected() ) { |
781 | OTDriver * D = ((DriverLVI *)it)->driver(); | 783 | OTDriver * D = ((DriverLVI *)it)->driver(); |
782 | owarn << "UP driver " << D->devname() << oendl; | 784 | owarn << "UP driver " << D->devname() << oendl; |
783 | // this | 785 | // this |
784 | D->setUp( Up ); | 786 | D->setUp( Up ); |
785 | return; | 787 | return; |
786 | } | 788 | } |
787 | it = it->nextSibling(); | 789 | it = it->nextSibling(); |
788 | } | 790 | } |
789 | } | 791 | } |
790 | 792 | ||
791 | void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { | 793 | void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { |
792 | QListViewItem * it = AllDrivers_LV->firstChild(); | 794 | QListViewItem * it = AllDrivers_LV->firstChild(); |
793 | while( it ) { | 795 | while( it ) { |
794 | if( ((DriverLVI *)it)->driver() == D ) { | 796 | if( ((DriverLVI *)it)->driver() == D ) { |
795 | it->setPixmap( 0, | 797 | it->setPixmap( 0, |
796 | Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); | 798 | Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); |
797 | return; | 799 | return; |
798 | } | 800 | } |
799 | it = it->nextSibling(); | 801 | it = it->nextSibling(); |
800 | } | 802 | } |
801 | } | 803 | } |
802 | 804 | ||
803 | void OTManage::SLOT_DriverListChanged( ) { | 805 | void OTManage::SLOT_DriverListChanged( ) { |
804 | DriverLVI * It; | 806 | DriverLVI * It; |
805 | QListViewItem * Sub; | 807 | QListViewItem * Sub; |
806 | QListViewItem * First = 0; | 808 | QListViewItem * First = 0; |
807 | OTDriver* D; | 809 | OTDriver* D; |
808 | OTDriverList & DL = OT->getDriverList(); | 810 | OTDriverList & DL = OT->getDriverList(); |
809 | 811 | ||
810 | AllDrivers_LV->clear(); | 812 | AllDrivers_LV->clear(); |
811 | for( unsigned int i = 0; | 813 | for( unsigned int i = 0; |
812 | i < DL.count(); | 814 | i < DL.count(); |
813 | i ++ ) { | 815 | i ++ ) { |
814 | D = DL[i]; | 816 | D = DL[i]; |
815 | It = new DriverLVI( D, AllDrivers_LV ); | 817 | It = new DriverLVI( D, AllDrivers_LV ); |
816 | 818 | ||
817 | if( ! First ) | 819 | if( ! First ) |
818 | First = It; | 820 | First = It; |
819 | 821 | ||
820 | It->setText( 0, D->devname() ); | 822 | It->setText( 0, D->devname() ); |
821 | It->setPixmap( 0, | 823 | It->setPixmap( 0, |
822 | Icons->loadPixmap( (D->isUp()) ? | 824 | Icons->loadPixmap( (D->isUp()) ? |
823 | "bluezon" : "bluezoff" ) ); | 825 | "bluezon" : "bluezoff" ) ); |
824 | 826 | ||
825 | Sub = new QListViewItem( It ); | 827 | Sub = new QListViewItem( It ); |
826 | Sub->setText( 0, tr( "Name" ) ); | 828 | Sub->setText( 0, tr( "Name" ) ); |
827 | Sub->setText( 1, D->name() ); | 829 | Sub->setText( 1, D->name() ); |
828 | 830 | ||
829 | Sub = new QListViewItem( It ); | 831 | Sub = new QListViewItem( It ); |
830 | Sub->setText( 0, tr( "Address" ) ); | 832 | Sub->setText( 0, tr( "Address" ) ); |
831 | Sub->setText( 1, D->address().toString() ); | 833 | Sub->setText( 1, D->address().toString() ); |
832 | 834 | ||
833 | Sub = new QListViewItem( It ); | 835 | Sub = new QListViewItem( It ); |
834 | Sub->setText( 0, tr( "Revision" ) ); | 836 | Sub->setText( 0, tr( "Revision" ) ); |
835 | Sub->setText( 1, D->revision() ); | 837 | Sub->setText( 1, D->revision() ); |
836 | 838 | ||
837 | Sub = new QListViewItem( It ); | 839 | Sub = new QListViewItem( It ); |
838 | Sub->setText( 0, tr( "Manufacturer" ) ); | 840 | Sub->setText( 0, tr( "Manufacturer" ) ); |
839 | Sub->setText( 1, D->manufacturer() ); | 841 | Sub->setText( 1, D->manufacturer() ); |
840 | 842 | ||
841 | QString Service, Device; | 843 | QString Service, Device; |
842 | D->getClass( Service, Device ); | 844 | D->getClass( Service, Device ); |
843 | 845 | ||
844 | Sub = new QListViewItem( It ); | 846 | Sub = new QListViewItem( It ); |
845 | Sub->setText( 0, tr( "Service classes" ) ); | 847 | Sub->setText( 0, tr( "Service classes" ) ); |
846 | Sub->setText( 1, Service ); | 848 | Sub->setText( 1, Service ); |
847 | Sub = new QListViewItem( It ); | 849 | Sub = new QListViewItem( It ); |
848 | Sub->setText( 0, tr( "Device class" ) ); | 850 | Sub->setText( 0, tr( "Device class" ) ); |
849 | Sub->setText( 1, Device ); | 851 | Sub->setText( 1, Device ); |
850 | } | 852 | } |
851 | 853 | ||
852 | if( DL.count() ) { | 854 | if( DL.count() ) { |
853 | AllDrivers_LV->setCurrentItem( First ); | 855 | AllDrivers_LV->setCurrentItem( First ); |
854 | DriverIsUp_CB->setEnabled( TRUE ); | 856 | DriverIsUp_CB->setEnabled( TRUE ); |
855 | } else { | 857 | } else { |
856 | DriverIsUp_CB->setChecked( FALSE ); | 858 | DriverIsUp_CB->setChecked( FALSE ); |
857 | DriverIsUp_CB->setEnabled( FALSE ); | 859 | DriverIsUp_CB->setEnabled( FALSE ); |
858 | } | 860 | } |
859 | } | 861 | } |
860 | 862 | ||
861 | void OTManage::SLOT_SetRefreshTimer( int v ) { | 863 | void OTManage::SLOT_SetRefreshTimer( int v ) { |
862 | OT->setRefreshTimer( v * 1000 ); | 864 | OT->setRefreshTimer( v * 1000 ); |
863 | } | 865 | } |
864 | 866 | ||
865 | // | 867 | // |
866 | // | 868 | // |
867 | // | 869 | // |
868 | // | 870 | // |
869 | // | 871 | // |
870 | 872 | ||
871 | OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) { | 873 | OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) { |
872 | 874 | ||
873 | Icons = new OTIcons(); | 875 | Icons = new OTIcons(); |
874 | OT = OTGateway::getOTGateway(); | 876 | OT = OTGateway::getOTGateway(); |
875 | 877 | ||
876 | connect( OT, | 878 | connect( OT, |
877 | SIGNAL( deviceEnabled( bool ) ), | 879 | SIGNAL( deviceEnabled( bool ) ), |
878 | this, | 880 | this, |
879 | SLOT( SLOT_DeviceIsEnabled( bool ) ) | 881 | SLOT( SLOT_DeviceIsEnabled( bool ) ) |
880 | ); | 882 | ); |
881 | connect( OT, | 883 | connect( OT, |
882 | SIGNAL( driverListChanged() ), | 884 | SIGNAL( driverListChanged() ), |
883 | this, | 885 | this, |
884 | SLOT( SLOT_DriverListChanged() ) | 886 | SLOT( SLOT_DriverListChanged() ) |
885 | ); | 887 | ); |
886 | connect( OT, | 888 | connect( OT, |
887 | SIGNAL( stateChange( OTDriver *, bool ) ), | 889 | SIGNAL( stateChange( OTDriver *, bool ) ), |
888 | this, | 890 | this, |
889 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) | 891 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) |
890 | ); | 892 | ); |
891 | 893 | ||
892 | if( ! OT->needsEnabling() ) { | 894 | if( ! OT->needsEnabling() ) { |
893 | MustBeEnabled_CB->hide(); | 895 | MustBeEnabled_CB->hide(); |
894 | } else { | 896 | } else { |
895 | // detect current state | 897 | // detect current state |
896 | MustBeEnabled_CB->setChecked( | 898 | MustBeEnabled_CB->setChecked( |
897 | OT->isEnabled() ); | 899 | OT->isEnabled() ); |
898 | } | 900 | } |
899 | 901 | ||
900 | SLOT_DriverListChanged(); | 902 | SLOT_DriverListChanged(); |
901 | } | 903 | } |
902 | 904 | ||
903 | OTMain::~OTMain() { | 905 | OTMain::~OTMain() { |
904 | OTGateway::releaseOTGateway(); | 906 | OTGateway::releaseOTGateway(); |
905 | delete Icons; | 907 | delete Icons; |
906 | } | 908 | } |
907 | 909 | ||
908 | void OTMain::SLOT_DriverListChanged() { | 910 | void OTMain::SLOT_DriverListChanged() { |
909 | OTDriver * D; | 911 | OTDriver * D; |
910 | OTDriverList & DL = OT->getDriverList(); | 912 | OTDriverList & DL = OT->getDriverList(); |
911 | 913 | ||
912 | DeviceList_CB->clear(); | 914 | DeviceList_CB->clear(); |
913 | for( unsigned int i = 0; | 915 | for( unsigned int i = 0; |
914 | i < DL.count(); | 916 | i < DL.count(); |
915 | i ++ ) { | 917 | i ++ ) { |
916 | D = DL[i]; | 918 | D = DL[i]; |
917 | DeviceList_CB->insertItem( | 919 | DeviceList_CB->insertItem( |
918 | Icons->loadPixmap( (D->isUp()) ? | 920 | Icons->loadPixmap( (D->isUp()) ? |
919 | "bluezon" : "bluezoff" ), | 921 | "bluezon" : "bluezoff" ), |
920 | D->devname() ); | 922 | D->devname() ); |
921 | if( D == OT->scanWith() ) { | 923 | if( D == OT->scanWith() ) { |
922 | DeviceList_CB->setCurrentItem( i ); | 924 | DeviceList_CB->setCurrentItem( i ); |
923 | } | 925 | } |
924 | } | 926 | } |
925 | 927 | ||
926 | Scan_But->setEnabled( OT->getDriverList().count() > 0 ); | 928 | Scan_But->setEnabled( OT->getDriverList().count() > 0 ); |
927 | DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 ); | 929 | DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 ); |
928 | } | 930 | } |
929 | 931 | ||
930 | void OTMain::SLOT_EnableBluetooth( bool Up ) { | 932 | void OTMain::SLOT_EnableBluetooth( bool Up ) { |
931 | OT->SLOT_SetEnabled( Up ); | 933 | OT->SLOT_SetEnabled( Up ); |
932 | } | 934 | } |
933 | 935 | ||
934 | void OTMain::SLOT_DeviceIsEnabled( bool Up ) { | 936 | void OTMain::SLOT_DeviceIsEnabled( bool Up ) { |
935 | MustBeEnabled_CB->blockSignals( TRUE ); | 937 | MustBeEnabled_CB->blockSignals( TRUE ); |
936 | MustBeEnabled_CB->setChecked( Up ); | 938 | MustBeEnabled_CB->setChecked( Up ); |
937 | MustBeEnabled_CB->blockSignals( FALSE ); | 939 | MustBeEnabled_CB->blockSignals( FALSE ); |
938 | } | 940 | } |
939 | 941 | ||
940 | void OTMain::SLOT_Manage( void ) { | 942 | void OTMain::SLOT_Manage( void ) { |
941 | QDialog * Dlg = new QDialog( this, 0, TRUE ); | 943 | QDialog * Dlg = new QDialog( this, 0, TRUE ); |
942 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 944 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
943 | OTManage * Mng = new OTManage( Dlg, Icons ); | 945 | OTManage * Mng = new OTManage( Dlg, Icons ); |
944 | 946 | ||
945 | V->addWidget( Mng ); | 947 | V->addWidget( Mng ); |
946 | 948 | ||
947 | Dlg->setCaption( tr("Manage local devices" ) ); | 949 | Dlg->setCaption( tr("Manage local devices" ) ); |
948 | Dlg->showMaximized(); | 950 | Dlg->showMaximized(); |
949 | Dlg->exec(); | 951 | Dlg->exec(); |
950 | delete Dlg; | 952 | delete Dlg; |
951 | } | 953 | } |
952 | 954 | ||
953 | void OTMain::SLOT_Scan( void ) { | 955 | void OTMain::SLOT_Scan( void ) { |
954 | OTDriverList & DL = OT->getDriverList(); | 956 | OTDriverList & DL = OT->getDriverList(); |
955 | for( unsigned int i = 0; | 957 | for( unsigned int i = 0; |
956 | i < DL.count(); | 958 | i < DL.count(); |
957 | i ++ ) { | 959 | i ++ ) { |
958 | if( DL[i]->isUp() && | 960 | if( DL[i]->isUp() && |
959 | DL[i]->devname() == DeviceList_CB->currentText() | 961 | DL[i]->devname() == DeviceList_CB->currentText() |
960 | ) { | 962 | ) { |
961 | QDialog * Dlg = new QDialog( this, 0, TRUE ); | 963 | QDialog * Dlg = new QDialog( this, 0, TRUE ); |
962 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 964 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
963 | OTScan * Scn = new OTScan( Dlg, Icons ); | 965 | OTScan * Scn = new OTScan( Dlg, Icons ); |
964 | 966 | ||
965 | OT->setScanWith( OT->driver(i) ); | 967 | OT->setScanWith( OT->driver(i) ); |
966 | V->addWidget( Scn ); | 968 | V->addWidget( Scn ); |
967 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); | 969 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); |
968 | Dlg->showMaximized(); | 970 | Dlg->showMaximized(); |
969 | Dlg->exec(); | 971 | Dlg->exec(); |
970 | 972 | ||
971 | delete Dlg; | 973 | delete Dlg; |
972 | return; | 974 | return; |
973 | } | 975 | } |
974 | } | 976 | } |
975 | 977 | ||
976 | } | 978 | } |
977 | 979 | ||
978 | void OTMain::SLOT_StateChange( OTDriver * D, bool Up ) { | 980 | void OTMain::SLOT_StateChange( OTDriver * D, bool Up ) { |
979 | for( int i = 0; | 981 | for( int i = 0; |
980 | i < DeviceList_CB->count(); | 982 | i < DeviceList_CB->count(); |
981 | i ++ ) { | 983 | i ++ ) { |
982 | if( DeviceList_CB->text(i) == D->devname() ) { | 984 | if( DeviceList_CB->text(i) == D->devname() ) { |
983 | DeviceList_CB->changeItem( | 985 | DeviceList_CB->changeItem( |
984 | Icons->loadPixmap( (Up) ? "bluezon" : "bluezoff" ), | 986 | Icons->loadPixmap( (Up) ? "bluezon" : "bluezoff" ), |
985 | D->devname(), | 987 | D->devname(), |
986 | i ); | 988 | i ); |
987 | return; | 989 | return; |
988 | } | 990 | } |
989 | } | 991 | } |
990 | } | 992 | } |
991 | 993 | ||
992 | void OTMain::SLOT_Pairing( void ) { | 994 | void OTMain::SLOT_Pairing( void ) { |
993 | QDialog * Dlg = new QDialog( this, 0, TRUE ); | 995 | QDialog * Dlg = new QDialog( this, 0, TRUE ); |
994 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 996 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
995 | OTPairing * Pair = new OTPairing( Dlg, Icons ); | 997 | OTPairing * Pair = new OTPairing( Dlg, Icons ); |
996 | 998 | ||
997 | V->addWidget( Pair ); | 999 | V->addWidget( Pair ); |
998 | Dlg->showMaximized(); | 1000 | Dlg->showMaximized(); |
999 | Dlg->setCaption( tr("Manage pairing" ) ); | 1001 | Dlg->setCaption( tr("Manage pairing" ) ); |
1000 | Dlg->exec(); | 1002 | Dlg->exec(); |
1001 | 1003 | ||
1002 | delete Dlg; | 1004 | delete Dlg; |
1003 | } | 1005 | } |
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.h b/noncore/settings/networksettings2/opietooth2/Opietooth.h index 9e53fcb..16a22d6 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.h +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.h | |||
@@ -1,194 +1,194 @@ | |||
1 | #ifndef OPIETOOTH_H | 1 | #ifndef OPIETOOTH_H |
2 | #define OPIETOOTH_H | 2 | #define OPIETOOTH_H |
3 | 3 | ||
4 | #include <OTIcons.h> | 4 | #include <OTIcons.h> |
5 | 5 | ||
6 | #include <OTPairingGUI.h> | 6 | #include <OTPairingGUI.h> |
7 | class OLedBox; | 7 | namespace Opie { namespace Ui { class OLedBox; }; }; |
8 | 8 | ||
9 | namespace Opietooth2 { | 9 | namespace Opietooth2 { |
10 | 10 | ||
11 | class OTGateway; | 11 | class OTGateway; |
12 | class OTDriver; | 12 | class OTDriver; |
13 | class OTInquiry; | 13 | class OTInquiry; |
14 | class OTPeer; | 14 | class OTPeer; |
15 | class PeerLVI; | 15 | class PeerLVI; |
16 | 16 | ||
17 | class OTPairing : public OTPairingGUI { | 17 | class OTPairing : public OTPairingGUI { |
18 | 18 | ||
19 | Q_OBJECT | 19 | Q_OBJECT |
20 | 20 | ||
21 | public : | 21 | public : |
22 | 22 | ||
23 | OTPairing( QWidget * parent, | 23 | OTPairing( QWidget * parent, |
24 | OTIcons * _Ic = 0 ); | 24 | OTIcons * _Ic = 0 ); |
25 | ~OTPairing(); | 25 | ~OTPairing(); |
26 | 26 | ||
27 | private slots : | 27 | private slots : |
28 | 28 | ||
29 | void SLOT_Unpair( void ); | 29 | void SLOT_Unpair( void ); |
30 | 30 | ||
31 | signals : | 31 | signals : |
32 | 32 | ||
33 | protected : | 33 | protected : |
34 | 34 | ||
35 | private : | 35 | private : |
36 | 36 | ||
37 | bool MyIcons; | 37 | bool MyIcons; |
38 | OTIcons * Icons; | 38 | OTIcons * Icons; |
39 | OTGateway * OT; | 39 | OTGateway * OT; |
40 | }; | 40 | }; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | #include <OTScanGUI.h> | 43 | #include <OTScanGUI.h> |
44 | 44 | ||
45 | namespace Opietooth2 { | 45 | namespace Opietooth2 { |
46 | 46 | ||
47 | class OTGateway; | 47 | class OTGateway; |
48 | class OTDriver; | 48 | class OTDriver; |
49 | class OTInquiry; | 49 | class OTInquiry; |
50 | class OTPeer; | 50 | class OTPeer; |
51 | 51 | ||
52 | class OTScan : public OTScanGUI { | 52 | class OTScan : public OTScanGUI { |
53 | 53 | ||
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | 55 | ||
56 | public : | 56 | public : |
57 | 57 | ||
58 | OTScan( QWidget * parent, | 58 | OTScan( QWidget * parent, |
59 | OTIcons * _Ic = 0 ); | 59 | OTIcons * _Ic = 0 ); |
60 | ~OTScan(); | 60 | ~OTScan(); |
61 | 61 | ||
62 | // static function to return a device and a channel | 62 | // static function to return a device and a channel |
63 | static int getDevice( OTPeer *& Peer, | 63 | static int getDevice( OTPeer *& Peer, |
64 | int & Channel, | 64 | int & Channel, |
65 | OTGateway * OT, | 65 | OTGateway * OT, |
66 | const UUIDVector & Filter = 0, | 66 | const UUIDVector & Filter = 0, |
67 | QWidget* Parent = 0); | 67 | QWidget* Parent = 0); |
68 | 68 | ||
69 | // show only services that match any of the filter | 69 | // show only services that match any of the filter |
70 | void setScanFilter( const UUIDVector & Filter ); | 70 | void setScanFilter( const UUIDVector & Filter ); |
71 | void resetScanFilter( void ); | 71 | void resetScanFilter( void ); |
72 | 72 | ||
73 | inline OTPeer * selectedPeer( void ) | 73 | inline OTPeer * selectedPeer( void ) |
74 | { return SelectedPeer; } | 74 | { return SelectedPeer; } |
75 | inline int selectedChannel( void ) | 75 | inline int selectedChannel( void ) |
76 | { return SelectedChannel; } | 76 | { return SelectedChannel; } |
77 | 77 | ||
78 | public slots : | 78 | public slots : |
79 | 79 | ||
80 | private slots : | 80 | private slots : |
81 | 81 | ||
82 | void SLOT_DoScan( bool ); | 82 | void SLOT_DoScan( bool ); |
83 | void SLOT_NewPeer( OTPeer *, bool ); | 83 | void SLOT_NewPeer( OTPeer *, bool ); |
84 | void SLOT_FinishedDetecting(); | 84 | void SLOT_FinishedDetecting(); |
85 | void SLOT_Show( QListViewItem *); | 85 | void SLOT_Show( QListViewItem *); |
86 | void SLOT_RefreshServices( void ); | 86 | void SLOT_RefreshServices( void ); |
87 | void SLOT_RefreshState( void ); | 87 | void SLOT_RefreshState( void ); |
88 | void SLOT_CleanupOld( void ); | 88 | void SLOT_CleanupOld( void ); |
89 | void SLOT_UpdateStrength( void ); | 89 | void SLOT_UpdateStrength( void ); |
90 | void SLOT_PeerState( OTPeer * ); | 90 | void SLOT_PeerState( OTPeer * ); |
91 | void SLOT_Selected( QListViewItem * ); | 91 | void SLOT_Selected( QListViewItem * ); |
92 | 92 | ||
93 | signals : | 93 | signals : |
94 | 94 | ||
95 | void selected( void ); | 95 | void selected( void ); |
96 | 96 | ||
97 | protected : | 97 | protected : |
98 | 98 | ||
99 | private : | 99 | private : |
100 | 100 | ||
101 | void refreshState( PeerLVI *, bool ); | 101 | void refreshState( PeerLVI *, bool ); |
102 | void scanMode( bool ); | 102 | void scanMode( bool ); |
103 | 103 | ||
104 | // load scanned devices | 104 | // load scanned devices |
105 | 105 | ||
106 | bool MyIcons; | 106 | bool MyIcons; |
107 | OTIcons * Icons; | 107 | OTIcons * Icons; |
108 | OTGateway * OT; | 108 | OTGateway * OT; |
109 | OTInquiry * Scanning; | 109 | OTInquiry * Scanning; |
110 | UUIDVector Filter; | 110 | UUIDVector Filter; |
111 | 111 | ||
112 | OLedBox * Paired_Led; | 112 | Opie::Ui::OLedBox * Paired_Led; |
113 | QTimer * StrengthTimer; | 113 | QTimer * StrengthTimer; |
114 | PeerLVI * Current; | 114 | PeerLVI * Current; |
115 | 115 | ||
116 | OTPeer * SelectedPeer; | 116 | OTPeer * SelectedPeer; |
117 | int SelectedChannel; | 117 | int SelectedChannel; |
118 | }; | 118 | }; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | #include <OTManageGUI.h> | 121 | #include <OTManageGUI.h> |
122 | namespace Opietooth2 { | 122 | namespace Opietooth2 { |
123 | 123 | ||
124 | class OTManage : public OTManageGUI { | 124 | class OTManage : public OTManageGUI { |
125 | 125 | ||
126 | Q_OBJECT | 126 | Q_OBJECT |
127 | 127 | ||
128 | public : | 128 | public : |
129 | 129 | ||
130 | OTManage( QWidget * parent, | 130 | OTManage( QWidget * parent, |
131 | OTIcons * _IC = 0 ); | 131 | OTIcons * _IC = 0 ); |
132 | ~OTManage(); | 132 | ~OTManage(); |
133 | 133 | ||
134 | public slots : | 134 | public slots : |
135 | 135 | ||
136 | private slots : | 136 | private slots : |
137 | 137 | ||
138 | void SLOT_ShowDriver( QListViewItem * ); | 138 | void SLOT_ShowDriver( QListViewItem * ); |
139 | void SLOT_UpDriver( bool ); | 139 | void SLOT_UpDriver( bool ); |
140 | void SLOT_StateChange( OTDriver * , bool ); | 140 | void SLOT_StateChange( OTDriver * , bool ); |
141 | void SLOT_DriverListChanged(); | 141 | void SLOT_DriverListChanged(); |
142 | void SLOT_SetRefreshTimer( int ); | 142 | void SLOT_SetRefreshTimer( int ); |
143 | 143 | ||
144 | signals : | 144 | signals : |
145 | 145 | ||
146 | protected : | 146 | protected : |
147 | 147 | ||
148 | private : | 148 | private : |
149 | 149 | ||
150 | // load scanned devices | 150 | // load scanned devices |
151 | 151 | ||
152 | bool MyIcons; | 152 | bool MyIcons; |
153 | OTIcons * Icons; | 153 | OTIcons * Icons; |
154 | OTGateway * OT; | 154 | OTGateway * OT; |
155 | OTInquiry * Scanning; | 155 | OTInquiry * Scanning; |
156 | }; | 156 | }; |
157 | }; | 157 | }; |
158 | 158 | ||
159 | #include <OTMainGUI.h> | 159 | #include <OTMainGUI.h> |
160 | 160 | ||
161 | namespace Opietooth2 { | 161 | namespace Opietooth2 { |
162 | class OTMain : public OTMainGUI { | 162 | class OTMain : public OTMainGUI { |
163 | 163 | ||
164 | Q_OBJECT | 164 | Q_OBJECT |
165 | 165 | ||
166 | public : | 166 | public : |
167 | 167 | ||
168 | OTMain( QWidget * parent ); | 168 | OTMain( QWidget * parent ); |
169 | ~OTMain(); | 169 | ~OTMain(); |
170 | 170 | ||
171 | public slots : | 171 | public slots : |
172 | 172 | ||
173 | private slots : | 173 | private slots : |
174 | 174 | ||
175 | void SLOT_Pairing( void ); | 175 | void SLOT_Pairing( void ); |
176 | void SLOT_Manage( void ); | 176 | void SLOT_Manage( void ); |
177 | void SLOT_Scan( void ); | 177 | void SLOT_Scan( void ); |
178 | void SLOT_EnableBluetooth( bool ); | 178 | void SLOT_EnableBluetooth( bool ); |
179 | void SLOT_DriverListChanged(); | 179 | void SLOT_DriverListChanged(); |
180 | void SLOT_DeviceIsEnabled( bool ); | 180 | void SLOT_DeviceIsEnabled( bool ); |
181 | void SLOT_StateChange( OTDriver * , bool ); | 181 | void SLOT_StateChange( OTDriver * , bool ); |
182 | 182 | ||
183 | signals : | 183 | signals : |
184 | 184 | ||
185 | protected : | 185 | protected : |
186 | 186 | ||
187 | private : | 187 | private : |
188 | 188 | ||
189 | // load scanned devices | 189 | // load scanned devices |
190 | OTIcons * Icons; | 190 | OTIcons * Icons; |
191 | OTGateway * OT; | 191 | OTGateway * OT; |
192 | }; | 192 | }; |
193 | }; | 193 | }; |
194 | #endif | 194 | #endif |