author | deller <deller> | 2005-04-01 22:46:30 (UTC) |
---|---|---|
committer | deller <deller> | 2005-04-01 22:46:30 (UTC) |
commit | 88cc0cc17864de6e36bdeedaae6df0a5cc738c5a (patch) (unidiff) | |
tree | ae0b24a579e940e6d508821dd98ee0edf2c95c03 | |
parent | cc4594a5c8d45d2f8d14c6ac1723a8ed39577f8f (diff) | |
download | opie-88cc0cc17864de6e36bdeedaae6df0a5cc738c5a.zip opie-88cc0cc17864de6e36bdeedaae6df0a5cc738c5a.tar.gz opie-88cc0cc17864de6e36bdeedaae6df0a5cc738c5a.tar.bz2 |
show the popups inside the visible screen
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 2 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 11ba2f6..7f0aca5 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,788 +1,788 @@ | |||
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 | /* OPIE */ |
24 | #include <opie2/oledbox.h> | 24 | #include <opie2/oledbox.h> |
25 | #include <opie2/odevice.h> | 25 | #include <opie2/odevice.h> |
26 | #include <opie2/otaskbarapplet.h> | 26 | #include <opie2/otaskbarapplet.h> |
27 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | using namespace Opie::Core; | 31 | using namespace Opie::Core; |
32 | using namespace Opie::Ui; | 32 | using namespace Opie::Ui; |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qcheckbox.h> | 36 | #include <qcheckbox.h> |
37 | #include <qslider.h> | 37 | #include <qslider.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qvbox.h> | 39 | #include <qvbox.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | 46 | ||
47 | #define RATE_TIMER_INTERVAL 100 | 47 | #define RATE_TIMER_INTERVAL 100 |
48 | // 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 |
49 | // 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. |
50 | 50 | ||
51 | 51 | ||
52 | /* XPM */ | 52 | /* XPM */ |
53 | using namespace Opie::Ui; | 53 | using namespace Opie::Ui; |
54 | static const char * vol_xpm[] = { | 54 | static const char * vol_xpm[] = { |
55 | "20 20 3 1", | 55 | "20 20 3 1", |
56 | " c None", | 56 | " c None", |
57 | ". c #0000FF", | 57 | ". c #0000FF", |
58 | "+ c #000000", | 58 | "+ c #000000", |
59 | " ", | 59 | " ", |
60 | " . ", | 60 | " . ", |
61 | " . . . . ", | 61 | " . . . . ", |
62 | " . . . . . . ", | 62 | " . . . . . . ", |
63 | " . . . . . . . ", | 63 | " . . . . . . . ", |
64 | " . . ..... . . ", | 64 | " . . ..... . . ", |
65 | " . ... ..... ... ", | 65 | " . ... ..... ... ", |
66 | " ........... .... ", | 66 | " ........... .... ", |
67 | " ................. ", | 67 | " ................. ", |
68 | "++++++++++++++++++++", | 68 | "++++++++++++++++++++", |
69 | " .................. ", | 69 | " .................. ", |
70 | " . ............. . ", | 70 | " . ............. . ", |
71 | " . ..... ....... ", | 71 | " . ..... ....... ", |
72 | " . ... ..... . ", | 72 | " . ... ..... . ", |
73 | " . ... ..... . ", | 73 | " . ... ..... . ", |
74 | " . ... ..... ", | 74 | " . ... ..... ", |
75 | " . . . . . ", | 75 | " . . . . . ", |
76 | " . . . ", | 76 | " . . . ", |
77 | " . . . ", | 77 | " . . . ", |
78 | " "}; | 78 | " "}; |
79 | /* XPM */ | 79 | /* XPM */ |
80 | static const char * mic_xpm[] = { | 80 | static const char * mic_xpm[] = { |
81 | "20 20 21 1", | 81 | "20 20 21 1", |
82 | " c None", | 82 | " c None", |
83 | ". c #000000", | 83 | ". c #000000", |
84 | "+ c #EEEEEE", | 84 | "+ c #EEEEEE", |
85 | "@ c #B4B6B4", | 85 | "@ c #B4B6B4", |
86 | "# c #8B8D8B", | 86 | "# c #8B8D8B", |
87 | "$ c #D5D6D5", | 87 | "$ c #D5D6D5", |
88 | "% c #E6E6E6", | 88 | "% c #E6E6E6", |
89 | "& c #9C9D9C", | 89 | "& c #9C9D9C", |
90 | "* c #6A696A", | 90 | "* c #6A696A", |
91 | "= c #E6E2E6", | 91 | "= c #E6E2E6", |
92 | "- c #F6F2F6", | 92 | "- c #F6F2F6", |
93 | "; c #CDC6CD", | 93 | "; c #CDC6CD", |
94 | "> c #737573", | 94 | "> c #737573", |
95 | ", c #4A484A", | 95 | ", c #4A484A", |
96 | "' c #DEDEDE", | 96 | "' c #DEDEDE", |
97 | ") c #F6EEF6", | 97 | ") c #F6EEF6", |
98 | "! c #414041", | 98 | "! c #414041", |
99 | "~ c #202020", | 99 | "~ c #202020", |
100 | "{ c #ACAEAC", | 100 | "{ c #ACAEAC", |
101 | "] c #838583", | 101 | "] c #838583", |
102 | "^ c #6A656A", | 102 | "^ c #6A656A", |
103 | " ", | 103 | " ", |
104 | " .... ", | 104 | " .... ", |
105 | " .+@+#. ", | 105 | " .+@+#. ", |
106 | " ..$%&%*. ", | 106 | " ..$%&%*. ", |
107 | " .=-.;=>=,. ", | 107 | " .=-.;=>=,. ", |
108 | " .'+).&+!+. ", | 108 | " .'+).&+!+. ", |
109 | " .+;+;.~+~. ", | 109 | " .+;+;.~+~. ", |
110 | " ..%{%,.... ", | 110 | " ..%{%,.... ", |
111 | " ..&=>=~.. ", | 111 | " ..&=>=~.. ", |
112 | " .+..]^,.. ", | 112 | " .+..]^,.. ", |
113 | " .+....... ", | 113 | " .+....... ", |
114 | " .%... ", | 114 | " .%... ", |
115 | " .=... ", | 115 | " .=... ", |
116 | " .+... ", | 116 | " .+... ", |
117 | " .+... ", | 117 | " .+... ", |
118 | " .... ", | 118 | " .... ", |
119 | " .... ", | 119 | " .... ", |
120 | " .. ", | 120 | " .. ", |
121 | " . ", | 121 | " . ", |
122 | ". "}; | 122 | ". "}; |
123 | 123 | ||
124 | 124 | ||
125 | static const char * bass_xpm[] = { | 125 | static const char * bass_xpm[] = { |
126 | "20 20 3 1", | 126 | "20 20 3 1", |
127 | " c None", | 127 | " c None", |
128 | ". c #000000", | 128 | ". c #000000", |
129 | "+ c #0000FF", | 129 | "+ c #0000FF", |
130 | " ", | 130 | " ", |
131 | " ", | 131 | " ", |
132 | " ", | 132 | " ", |
133 | "..... +++ ......", | 133 | "..... +++ ......", |
134 | " +++++++ ", | 134 | " +++++++ ", |
135 | " ++ ++ ", | 135 | " ++ ++ ", |
136 | "... ++ ... ++ ++ .", | 136 | "... ++ ... ++ ++ .", |
137 | " +++ ++ ++ ", | 137 | " +++ ++ ++ ", |
138 | " ++++ ++ ", | 138 | " ++++ ++ ", |
139 | "... ++++ .. ++ .....", | 139 | "... ++++ .. ++ .....", |
140 | " ++ ++ ", | 140 | " ++ ++ ", |
141 | " ++ ++ ", | 141 | " ++ ++ ", |
142 | "..........++ ++ .", | 142 | "..........++ ++ .", |
143 | " ++ ", | 143 | " ++ ", |
144 | " ++ ", | 144 | " ++ ", |
145 | "...... ++ .........", | 145 | "...... ++ .........", |
146 | " + ", | 146 | " + ", |
147 | " ", | 147 | " ", |
148 | " ", | 148 | " ", |
149 | " "}; | 149 | " "}; |
150 | 150 | ||
151 | 151 | ||
152 | static const char * treble_xpm[] = { | 152 | static const char * treble_xpm[] = { |
153 | "20 20 3 1", | 153 | "20 20 3 1", |
154 | " c None", | 154 | " c None", |
155 | ". c #0000FF", | 155 | ". c #0000FF", |
156 | "+ c #000000", | 156 | "+ c #000000", |
157 | " .. ", | 157 | " .. ", |
158 | " . .. ", | 158 | " . .. ", |
159 | " . .. ", | 159 | " . .. ", |
160 | "++++++++ . .. ++++++", | 160 | "++++++++ . .. ++++++", |
161 | " . . ", | 161 | " . . ", |
162 | " ... ", | 162 | " ... ", |
163 | "++++++++ . +++++++", | 163 | "++++++++ . +++++++", |
164 | " .. ", | 164 | " .. ", |
165 | " .. . ", | 165 | " .. . ", |
166 | "+++ .. ... +++++++", | 166 | "+++ .. ... +++++++", |
167 | " .. .. .. ", | 167 | " .. .. .. ", |
168 | " .. . . .. ", | 168 | " .. . . .. ", |
169 | "+++ .. . . + . +++++", | 169 | "+++ .. . . + . +++++", |
170 | " .. . .. ", | 170 | " .. . .. ", |
171 | " .. . .. ", | 171 | " .. . .. ", |
172 | "++++ ...... +++++++", | 172 | "++++ ...... +++++++", |
173 | " . ", | 173 | " . ", |
174 | " .. . ", | 174 | " .. . ", |
175 | " .. . ", | 175 | " .. . ", |
176 | " .. "}; | 176 | " .. "}; |
177 | 177 | ||
178 | 178 | ||
179 | 179 | ||
180 | 180 | ||
181 | /* XPM */ | 181 | /* XPM */ |
182 | static const char * alarm_xpm[] = { | 182 | static const char * alarm_xpm[] = { |
183 | "20 20 33 1", | 183 | "20 20 33 1", |
184 | " c None", | 184 | " c None", |
185 | ". c #080602", | 185 | ". c #080602", |
186 | "+ c #AAA602", | 186 | "+ c #AAA602", |
187 | "@ c #252002", | 187 | "@ c #252002", |
188 | "# c #434202", | 188 | "# c #434202", |
189 | "$ c #795602", | 189 | "$ c #795602", |
190 | "% c #C3C20D", | 190 | "% c #C3C20D", |
191 | "& c #DADAC2", | 191 | "& c #DADAC2", |
192 | "* c #826002", | 192 | "* c #826002", |
193 | "= c #740502", | 193 | "= c #740502", |
194 | "- c #D6D602", | 194 | "- c #D6D602", |
195 | "; c #322E02", | 195 | "; c #322E02", |
196 | "> c #826A02", | 196 | "> c #826A02", |
197 | ", c #F1F195", | 197 | ", c #F1F195", |
198 | "' c #959215", | 198 | "' c #959215", |
199 | ") c #423602", | 199 | ") c #423602", |
200 | "! c #4B0302", | 200 | "! c #4B0302", |
201 | "~ c #844315", | 201 | "~ c #844315", |
202 | "{ c #AAAA2A", | 202 | "{ c #AAAA2A", |
203 | "] c #E2DE42", | 203 | "] c #E2DE42", |
204 | "^ c #BA7E04", | 204 | "^ c #BA7E04", |
205 | "/ c #7F7502", | 205 | "/ c #7F7502", |
206 | "( c #828276", | 206 | "( c #828276", |
207 | "_ c #FEFE4E", | 207 | "_ c #FEFE4E", |
208 | ": c #7D1902", | 208 | ": c #7D1902", |
209 | "< c #989656", | 209 | "< c #989656", |
210 | "[ c #260B02", | 210 | "[ c #260B02", |
211 | "} c #F7F7D8", | 211 | "} c #F7F7D8", |
212 | "| c #DCDA5A", | 212 | "| c #DCDA5A", |
213 | "1 c #823102", | 213 | "1 c #823102", |
214 | "2 c #B1AC6B", | 214 | "2 c #B1AC6B", |
215 | "3 c #F7F710", | 215 | "3 c #F7F710", |
216 | "4 c #838204", | 216 | "4 c #838204", |
217 | " ", | 217 | " ", |
218 | " ", | 218 | " ", |
219 | " 4'4/ ", | 219 | " 4'4/ ", |
220 | " /-^= ", | 220 | " /-^= ", |
221 | " 42{4>4 ", | 221 | " 42{4>4 ", |
222 | " '2|+*$44 ", | 222 | " '2|+*$44 ", |
223 | " +2&3+$1*44 ", | 223 | " +2&3+$1*44 ", |
224 | " (%_}_+/$:>/4 ", | 224 | " (%_}_+/$:>/4 ", |
225 | " 4%_}3+#;>:*4 ", | 225 | " 4%_}3+#;>:*4 ", |
226 | " 4%_}&+#[1$/4 ", | 226 | " 4%_}&+#[1$/4 ", |
227 | " 4%_,2')[~~>4 ", | 227 | " 4%_,2')[~~>4 ", |
228 | " 4%33'4#@~1>4 ", | 228 | " 4%33'4#@~1>4 ", |
229 | " 4%3344#[:>/4 ", | 229 | " 4%3344#[:>/4 ", |
230 | " 42&_3'4#@>:*44 ", | 230 | " 42&_3'4#@>:*44 ", |
231 | " 42|}}3'4#[;$)$44 ", | 231 | " 42|}}3'4#[;$)$44 ", |
232 | "444{]]2^~~:!!#.@##/ ", | 232 | "444{]]2^~~:!!#.@##/ ", |
233 | "4444-%*:==!!=...../ ", | 233 | "4444-%*:==!!=...../ ", |
234 | " /:[.. ", | 234 | " /:[.. ", |
235 | " /@. ", | 235 | " /@. ", |
236 | " "}; | 236 | " "}; |
237 | 237 | ||
238 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 238 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
239 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 239 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
240 | { | 240 | { |
241 | m_icon = icon; | 241 | m_icon = icon; |
242 | 242 | ||
243 | bool has_wav_alarm = true; | 243 | bool has_wav_alarm = true; |
244 | bool has_bass = true; | 244 | bool has_bass = true; |
245 | bool has_treble = true; | 245 | bool has_treble = true; |
246 | 246 | ||
247 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually | 247 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
248 | case Model_Zaurus_SL5000: | 248 | case Model_Zaurus_SL5000: |
249 | has_wav_alarm = false; //poor guys probably feeling left out... | 249 | has_wav_alarm = false; //poor guys probably feeling left out... |
250 | break; | 250 | break; |
251 | default: | 251 | default: |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | 254 | ||
255 | if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { | 255 | if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { |
256 | has_bass = false; | 256 | has_bass = false; |
257 | has_treble = false; | 257 | has_treble = false; |
258 | } | 258 | } |
259 | 259 | ||
260 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 260 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
261 | 261 | ||
262 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 262 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
263 | grid-> setSpacing ( 4 ); | 263 | grid-> setSpacing ( 4 ); |
264 | grid-> setMargin ( 6 ); | 264 | grid-> setMargin ( 6 ); |
265 | 265 | ||
266 | QVBoxLayout *vbox; | 266 | QVBoxLayout *vbox; |
267 | QLabel *l; | 267 | QLabel *l; |
268 | 268 | ||
269 | vbox = new QVBoxLayout ( ); | 269 | vbox = new QVBoxLayout ( ); |
270 | vbox-> setSpacing ( 4 ); | 270 | vbox-> setSpacing ( 4 ); |
271 | grid-> addLayout ( vbox, 1, 0 ); | 271 | grid-> addLayout ( vbox, 1, 0 ); |
272 | 272 | ||
273 | upButton = new QPushButton ( this ); | 273 | upButton = new QPushButton ( this ); |
274 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 274 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
275 | QPixmap pic; | 275 | QPixmap pic; |
276 | pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 276 | pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
277 | upButton-> setPixmap ( pic ); | 277 | upButton-> setPixmap ( pic ); |
278 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 278 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
279 | 279 | ||
280 | vbox-> addWidget ( upButton ); | 280 | vbox-> addWidget ( upButton ); |
281 | 281 | ||
282 | downButton = new QPushButton ( this ); | 282 | downButton = new QPushButton ( this ); |
283 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 283 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
284 | pic.convertFromImage( Resource::loadImage( "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 284 | pic.convertFromImage( Resource::loadImage( "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
285 | downButton-> setPixmap ( pic ); | 285 | downButton-> setPixmap ( pic ); |
286 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 286 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
287 | 287 | ||
288 | vbox-> addWidget ( downButton ); | 288 | vbox-> addWidget ( downButton ); |
289 | 289 | ||
290 | volSlider = new QSlider ( this ); | 290 | volSlider = new QSlider ( this ); |
291 | volSlider-> setRange ( 0, 100 ); | 291 | volSlider-> setRange ( 0, 100 ); |
292 | volSlider-> setTickmarks ( QSlider::Both ); | 292 | volSlider-> setTickmarks ( QSlider::Both ); |
293 | volSlider-> setTickInterval ( 20 ); | 293 | volSlider-> setTickInterval ( 20 ); |
294 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 294 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
295 | 295 | ||
296 | l = new QLabel ( this ); | 296 | l = new QLabel ( this ); |
297 | l-> setPixmap ( QPixmap ( vol_xpm )); | 297 | l-> setPixmap ( QPixmap ( vol_xpm )); |
298 | 298 | ||
299 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 299 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
300 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 300 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
301 | 301 | ||
302 | volLed = new OLedBox ( green, this ); | 302 | volLed = new OLedBox ( green, this ); |
303 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 303 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
304 | volLed-> setFixedSize ( 16, 16 ); | 304 | volLed-> setFixedSize ( 16, 16 ); |
305 | 305 | ||
306 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 306 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
307 | 307 | ||
308 | QVBox *basstrebleBox = new QVBox( this ); | 308 | QVBox *basstrebleBox = new QVBox( this ); |
309 | 309 | ||
310 | trebleSlider = new QSlider ( basstrebleBox ); | 310 | trebleSlider = new QSlider ( basstrebleBox ); |
311 | trebleSlider-> setRange ( 0, 100 ); | 311 | trebleSlider-> setRange ( 0, 100 ); |
312 | trebleSlider-> setTickmarks ( QSlider::Both ); | 312 | trebleSlider-> setTickmarks ( QSlider::Both ); |
313 | trebleSlider-> setTickInterval ( 20 ); | 313 | trebleSlider-> setTickInterval ( 20 ); |
314 | trebleSlider->setMaximumHeight( 40 ); | 314 | trebleSlider->setMaximumHeight( 40 ); |
315 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); | 315 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); |
316 | 316 | ||
317 | bassSlider = new QSlider ( basstrebleBox ); | 317 | bassSlider = new QSlider ( basstrebleBox ); |
318 | bassSlider-> setRange ( 0, 100 ); | 318 | bassSlider-> setRange ( 0, 100 ); |
319 | bassSlider-> setTickmarks ( QSlider::Both ); | 319 | bassSlider-> setTickmarks ( QSlider::Both ); |
320 | bassSlider-> setTickInterval ( 20 ); | 320 | bassSlider-> setTickInterval ( 20 ); |
321 | bassSlider->setMaximumHeight( 40 ); | 321 | bassSlider->setMaximumHeight( 40 ); |
322 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); | 322 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); |
323 | 323 | ||
324 | QLabel *bassLabel = new QLabel ( this ); | 324 | QLabel *bassLabel = new QLabel ( this ); |
325 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); | 325 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); |
326 | 326 | ||
327 | QLabel *trebleLabel = new QLabel( this ); | 327 | QLabel *trebleLabel = new QLabel( this ); |
328 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); | 328 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); |
329 | 329 | ||
330 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); | 330 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); |
331 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); | 331 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); |
332 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); | 332 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); |
333 | 333 | ||
334 | if ( !has_bass ) { | 334 | if ( !has_bass ) { |
335 | bassSlider->hide(); | 335 | bassSlider->hide(); |
336 | bassLabel->hide(); | 336 | bassLabel->hide(); |
337 | } | 337 | } |
338 | 338 | ||
339 | if ( !has_treble ) { | 339 | if ( !has_treble ) { |
340 | trebleSlider->hide(); | 340 | trebleSlider->hide(); |
341 | trebleLabel->hide(); | 341 | trebleLabel->hide(); |
342 | } | 342 | } |
343 | 343 | ||
344 | micSlider = new QSlider ( this ); | 344 | micSlider = new QSlider ( this ); |
345 | micSlider-> setRange ( 0, 100 ); | 345 | micSlider-> setRange ( 0, 100 ); |
346 | micSlider-> setTickmarks ( QSlider::Both ); | 346 | micSlider-> setTickmarks ( QSlider::Both ); |
347 | micSlider-> setTickInterval ( 20 ); | 347 | micSlider-> setTickInterval ( 20 ); |
348 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 348 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
349 | 349 | ||
350 | l = new QLabel ( this ); | 350 | l = new QLabel ( this ); |
351 | l-> setPixmap ( QPixmap ( mic_xpm )); | 351 | l-> setPixmap ( QPixmap ( mic_xpm )); |
352 | 352 | ||
353 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 353 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
354 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 354 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
355 | 355 | ||
356 | micLed = new OLedBox ( red, this ); | 356 | micLed = new OLedBox ( red, this ); |
357 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 357 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
358 | micLed-> setFixedSize ( 16, 16 ); | 358 | micLed-> setFixedSize ( 16, 16 ); |
359 | 359 | ||
360 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 360 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
361 | 361 | ||
362 | alarmSlider = new QSlider ( this ); | 362 | alarmSlider = new QSlider ( this ); |
363 | alarmSlider-> setRange ( 0, 100 ); | 363 | alarmSlider-> setRange ( 0, 100 ); |
364 | alarmSlider-> setTickmarks ( QSlider::Both ); | 364 | alarmSlider-> setTickmarks ( QSlider::Both ); |
365 | alarmSlider-> setTickInterval ( 20 ); | 365 | alarmSlider-> setTickInterval ( 20 ); |
366 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 366 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
367 | 367 | ||
368 | QLabel *alarmLabel = new QLabel ( this ); | 368 | QLabel *alarmLabel = new QLabel ( this ); |
369 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 369 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
370 | 370 | ||
371 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 371 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
372 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 372 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
373 | 373 | ||
374 | alarmLed = new OLedBox ( yellow, this ); | 374 | alarmLed = new OLedBox ( yellow, this ); |
375 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 375 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
376 | alarmLed-> setFixedSize ( 16, 16 ); | 376 | alarmLed-> setFixedSize ( 16, 16 ); |
377 | 377 | ||
378 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 378 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
379 | 379 | ||
380 | if ( !has_wav_alarm ) { | 380 | if ( !has_wav_alarm ) { |
381 | alarmSlider-> hide ( ); | 381 | alarmSlider-> hide ( ); |
382 | alarmLabel-> hide ( ); | 382 | alarmLabel-> hide ( ); |
383 | alarmLed-> hide ( ); | 383 | alarmLed-> hide ( ); |
384 | } | 384 | } |
385 | 385 | ||
386 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); | 386 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
387 | 387 | ||
388 | vbox = new QVBoxLayout ( ); | 388 | vbox = new QVBoxLayout ( ); |
389 | vbox-> setSpacing ( 4 ); | 389 | vbox-> setSpacing ( 4 ); |
390 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); | 390 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
391 | 391 | ||
392 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 392 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
393 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 393 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
394 | 394 | ||
395 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 395 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
396 | 396 | ||
397 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 397 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
398 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 398 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
399 | 399 | ||
400 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 400 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
401 | 401 | ||
402 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 402 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
403 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 403 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
404 | 404 | ||
405 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 405 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
406 | 406 | ||
407 | if ( has_wav_alarm ) { | 407 | if ( has_wav_alarm ) { |
408 | alarmBox-> hide ( ); | 408 | alarmBox-> hide ( ); |
409 | } | 409 | } |
410 | 410 | ||
411 | vbox-> addStretch ( 100 ); | 411 | vbox-> addStretch ( 100 ); |
412 | 412 | ||
413 | setFixedSize ( sizeHint ( )); | 413 | setFixedSize ( sizeHint ( )); |
414 | setFocusPolicy ( QWidget::NoFocus ); | 414 | setFocusPolicy ( QWidget::NoFocus ); |
415 | 415 | ||
416 | rateTimer = new QTimer( this ); | 416 | rateTimer = new QTimer( this ); |
417 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); | 417 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); |
418 | 418 | ||
419 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 419 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
420 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 420 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
421 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 421 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
422 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 422 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
423 | 423 | ||
424 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); | 424 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); |
425 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); | 425 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); |
426 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); | 426 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); |
427 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); | 427 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); |
428 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); | 428 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); |
429 | 429 | ||
430 | 430 | ||
431 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); | 431 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); |
432 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); | 432 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); |
433 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 433 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
434 | 434 | ||
435 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 435 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
436 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); | 436 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); |
437 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); | 437 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); |
438 | 438 | ||
439 | // initialize variables | 439 | // initialize variables |
440 | 440 | ||
441 | readConfig ( true ); | 441 | readConfig ( true ); |
442 | 442 | ||
443 | // initialize the config file, in case some entries are missing | 443 | // initialize the config file, in case some entries are missing |
444 | 444 | ||
445 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 445 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
446 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | 446 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); |
447 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | 447 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); |
448 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 448 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
449 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 449 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
450 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 450 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
451 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 451 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
452 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 452 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
453 | 453 | ||
454 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 454 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
455 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 455 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
456 | } | 456 | } |
457 | 457 | ||
458 | bool VolumeControl::volMuted ( ) const | 458 | bool VolumeControl::volMuted ( ) const |
459 | { | 459 | { |
460 | return m_vol_muted; | 460 | return m_vol_muted; |
461 | } | 461 | } |
462 | 462 | ||
463 | int VolumeControl::volPercent ( ) const | 463 | int VolumeControl::volPercent ( ) const |
464 | { | 464 | { |
465 | return m_vol_percent; | 465 | return m_vol_percent; |
466 | } | 466 | } |
467 | 467 | ||
468 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 468 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
469 | { | 469 | { |
470 | switch ( e-> key ( )) { | 470 | switch ( e-> key ( )) { |
471 | case Key_Up: | 471 | case Key_Up: |
472 | volSlider-> subtractStep ( ); | 472 | volSlider-> subtractStep ( ); |
473 | break; | 473 | break; |
474 | case Key_Down: | 474 | case Key_Down: |
475 | volSlider-> addStep ( ); | 475 | volSlider-> addStep ( ); |
476 | break; | 476 | break; |
477 | case Key_Space: | 477 | case Key_Space: |
478 | volLed-> toggle ( ); | 478 | volLed-> toggle ( ); |
479 | break; | 479 | break; |
480 | case Key_Escape: | 480 | case Key_Escape: |
481 | hide ( ); | 481 | hide ( ); |
482 | break; | 482 | break; |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | void VolumeControl::buttonChanged ( ) | 486 | void VolumeControl::buttonChanged ( ) |
487 | { | 487 | { |
488 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 488 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
489 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 489 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
490 | // called at all when a button is pressed for a time | 490 | // called at all when a button is pressed for a time |
491 | // shorter than RATE_TIMER_INTERVAL. | 491 | // shorter than RATE_TIMER_INTERVAL. |
492 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 492 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
493 | } | 493 | } |
494 | else | 494 | else |
495 | rateTimer-> stop ( ); | 495 | rateTimer-> stop ( ); |
496 | } | 496 | } |
497 | 497 | ||
498 | void VolumeControl::rateTimerDone ( ) | 498 | void VolumeControl::rateTimerDone ( ) |
499 | { | 499 | { |
500 | if ( upButton-> isDown ( )) | 500 | if ( upButton-> isDown ( )) |
501 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 501 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
502 | else // if ( downButton-> isDown ( )) | 502 | else // if ( downButton-> isDown ( )) |
503 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 503 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
504 | } | 504 | } |
505 | 505 | ||
506 | void VolumeControl::show ( bool /*showMic*/ ) | 506 | void VolumeControl::show ( bool /*showMic*/ ) |
507 | { | 507 | { |
508 | readConfig ( ); | 508 | readConfig ( ); |
509 | 509 | ||
510 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 510 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
511 | 511 | ||
512 | int w = sizeHint ( ). width ( ); | 512 | int w = sizeHint ( ). width ( ); |
513 | int x = curPos.x ( ) - ( w / 2 ); | 513 | int x = curPos.x ( ) - ( w / 2 ); |
514 | 514 | ||
515 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 515 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
516 | x = QPEApplication::desktop ( )-> width ( ) - w; | 516 | x = QPEApplication::desktop ( )-> width ( ) - w; |
517 | 517 | ||
518 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 518 | move ( QMAX(x,0), curPos. y ( ) - sizeHint ( ). height ( )); |
519 | QFrame::show ( ); | 519 | QFrame::show ( ); |
520 | 520 | ||
521 | } | 521 | } |
522 | 522 | ||
523 | void VolumeControl::readConfig ( bool force ) | 523 | void VolumeControl::readConfig ( bool force ) |
524 | { | 524 | { |
525 | Config cfg ( "qpe" ); | 525 | Config cfg ( "qpe" ); |
526 | cfg. setGroup ( "Volume" ); | 526 | cfg. setGroup ( "Volume" ); |
527 | 527 | ||
528 | int old_vp = m_vol_percent; | 528 | int old_vp = m_vol_percent; |
529 | int old_mp = m_mic_percent; | 529 | int old_mp = m_mic_percent; |
530 | int old_bass = m_bass_percent; | 530 | int old_bass = m_bass_percent; |
531 | int old_treble = m_treble_percent; | 531 | int old_treble = m_treble_percent; |
532 | bool old_vm = m_vol_muted; | 532 | bool old_vm = m_vol_muted; |
533 | bool old_mm = m_mic_muted; | 533 | bool old_mm = m_mic_muted; |
534 | bool old_sk = m_snd_key; | 534 | bool old_sk = m_snd_key; |
535 | bool old_st = m_snd_touch; | 535 | bool old_st = m_snd_touch; |
536 | bool old_sa = m_snd_alarm; | 536 | bool old_sa = m_snd_alarm; |
537 | int old_ap = m_alarm_percent; | 537 | int old_ap = m_alarm_percent; |
538 | 538 | ||
539 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 539 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
540 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 540 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
541 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); | 541 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); |
542 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); | 542 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); |
543 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 543 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
544 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 544 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
545 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 545 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
546 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 546 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
547 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 547 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
548 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 548 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
549 | 549 | ||
550 | if ( force || ( m_vol_percent != old_vp )) | 550 | if ( force || ( m_vol_percent != old_vp )) |
551 | volSlider-> setValue ( 100 - m_vol_percent ); | 551 | volSlider-> setValue ( 100 - m_vol_percent ); |
552 | if ( force || ( m_mic_percent != old_mp )) | 552 | if ( force || ( m_mic_percent != old_mp )) |
553 | micSlider-> setValue ( 100 - m_mic_percent ); | 553 | micSlider-> setValue ( 100 - m_mic_percent ); |
554 | if ( force || ( m_alarm_percent != old_ap )) | 554 | if ( force || ( m_alarm_percent != old_ap )) |
555 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 555 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
556 | if ( force || ( m_bass_percent != old_bass )) | 556 | if ( force || ( m_bass_percent != old_bass )) |
557 | bassSlider-> setValue ( 100 - m_bass_percent ); | 557 | bassSlider-> setValue ( 100 - m_bass_percent ); |
558 | if ( force || ( m_treble_percent != old_treble )) | 558 | if ( force || ( m_treble_percent != old_treble )) |
559 | trebleSlider-> setValue ( 100 - m_treble_percent ); | 559 | trebleSlider-> setValue ( 100 - m_treble_percent ); |
560 | 560 | ||
561 | 561 | ||
562 | if ( force || ( m_vol_muted != old_vm )) | 562 | if ( force || ( m_vol_muted != old_vm )) |
563 | volLed-> setOn ( !m_vol_muted ); | 563 | volLed-> setOn ( !m_vol_muted ); |
564 | if ( force || ( m_mic_muted != old_mm )) | 564 | if ( force || ( m_mic_muted != old_mm )) |
565 | micLed-> setOn ( !m_mic_muted ); | 565 | micLed-> setOn ( !m_mic_muted ); |
566 | if ( force || ( m_snd_alarm != old_sa )) | 566 | if ( force || ( m_snd_alarm != old_sa )) |
567 | alarmLed-> setOn ( m_snd_alarm ); | 567 | alarmLed-> setOn ( m_snd_alarm ); |
568 | 568 | ||
569 | if ( force || ( m_snd_key != old_sk )) | 569 | if ( force || ( m_snd_key != old_sk )) |
570 | keyBox-> setChecked ( m_snd_key ); | 570 | keyBox-> setChecked ( m_snd_key ); |
571 | if ( force || ( m_snd_touch != old_st )) | 571 | if ( force || ( m_snd_touch != old_st )) |
572 | tapBox-> setChecked ( m_snd_touch ); | 572 | tapBox-> setChecked ( m_snd_touch ); |
573 | if ( force || ( m_snd_alarm != old_sa )) | 573 | if ( force || ( m_snd_alarm != old_sa )) |
574 | alarmBox-> setChecked ( m_snd_alarm ); | 574 | alarmBox-> setChecked ( m_snd_alarm ); |
575 | } | 575 | } |
576 | 576 | ||
577 | 577 | ||
578 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) | 578 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) |
579 | { | 579 | { |
580 | int prevVol = m_vol_percent; | 580 | int prevVol = m_vol_percent; |
581 | bool prevMute = m_vol_muted; | 581 | bool prevMute = m_vol_muted; |
582 | 582 | ||
583 | readConfig ( ); | 583 | readConfig ( ); |
584 | 584 | ||
585 | // Handle case where muting it toggled | 585 | // Handle case where muting it toggled |
586 | if ( m_vol_muted != prevMute ) | 586 | if ( m_vol_muted != prevMute ) |
587 | m_icon-> redraw ( true ); | 587 | m_icon-> redraw ( true ); |
588 | else if ( prevVol != m_vol_percent ) // Avoid over repainting | 588 | else if ( prevVol != m_vol_percent ) // Avoid over repainting |
589 | m_icon-> redraw ( false ); | 589 | m_icon-> redraw ( false ); |
590 | } | 590 | } |
591 | 591 | ||
592 | void VolumeControl::micChanged ( bool nowMuted ) | 592 | void VolumeControl::micChanged ( bool nowMuted ) |
593 | { | 593 | { |
594 | if ( !nowMuted ) | 594 | if ( !nowMuted ) |
595 | readConfig ( ); | 595 | readConfig ( ); |
596 | m_mic_muted = nowMuted; | 596 | m_mic_muted = nowMuted; |
597 | } | 597 | } |
598 | 598 | ||
599 | void VolumeControl::screenTapToggled ( bool b ) | 599 | void VolumeControl::screenTapToggled ( bool b ) |
600 | { | 600 | { |
601 | m_snd_touch = b; | 601 | m_snd_touch = b; |
602 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 602 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
603 | } | 603 | } |
604 | 604 | ||
605 | void VolumeControl::keyClickToggled ( bool b ) | 605 | void VolumeControl::keyClickToggled ( bool b ) |
606 | { | 606 | { |
607 | m_snd_key = b; | 607 | m_snd_key = b; |
608 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 608 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
609 | } | 609 | } |
610 | 610 | ||
611 | void VolumeControl::alarmSoundToggled ( bool b ) | 611 | void VolumeControl::alarmSoundToggled ( bool b ) |
612 | { | 612 | { |
613 | m_snd_alarm = b; | 613 | m_snd_alarm = b; |
614 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 614 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
615 | } | 615 | } |
616 | 616 | ||
617 | void VolumeControl::volMuteToggled ( bool b ) | 617 | void VolumeControl::volMuteToggled ( bool b ) |
618 | { | 618 | { |
619 | m_vol_muted = !b; | 619 | m_vol_muted = !b; |
620 | 620 | ||
621 | m_icon-> redraw ( true ); | 621 | m_icon-> redraw ( true ); |
622 | 622 | ||
623 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 623 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
624 | } | 624 | } |
625 | 625 | ||
626 | void VolumeControl::micMuteToggled ( bool b ) | 626 | void VolumeControl::micMuteToggled ( bool b ) |
627 | { | 627 | { |
628 | m_mic_muted = !b; | 628 | m_mic_muted = !b; |
629 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 629 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
630 | } | 630 | } |
631 | 631 | ||
632 | 632 | ||
633 | void VolumeControl::volMoved ( int percent ) | 633 | void VolumeControl::volMoved ( int percent ) |
634 | { | 634 | { |
635 | m_vol_percent = 100 - percent; | 635 | m_vol_percent = 100 - percent; |
636 | 636 | ||
637 | // clamp volume percent to be between 0 and 100 | 637 | // clamp volume percent to be between 0 and 100 |
638 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 638 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
639 | // repaint just the little volume rectangle | 639 | // repaint just the little volume rectangle |
640 | m_icon-> redraw ( false ); | 640 | m_icon-> redraw ( false ); |
641 | 641 | ||
642 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 642 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
643 | } | 643 | } |
644 | 644 | ||
645 | void VolumeControl::micMoved ( int percent ) | 645 | void VolumeControl::micMoved ( int percent ) |
646 | { | 646 | { |
647 | m_mic_percent = 100 - percent; | 647 | m_mic_percent = 100 - percent; |
648 | 648 | ||
649 | // clamp volume percent to be between 0 and 100 | 649 | // clamp volume percent to be between 0 and 100 |
650 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 650 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
651 | 651 | ||
652 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 652 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
653 | } | 653 | } |
654 | 654 | ||
655 | void VolumeControl::alarmMoved ( int percent ) | 655 | void VolumeControl::alarmMoved ( int percent ) |
656 | { | 656 | { |
657 | m_alarm_percent = 100 - percent; | 657 | m_alarm_percent = 100 - percent; |
658 | 658 | ||
659 | // clamp volume percent to be between 0 and 100 | 659 | // clamp volume percent to be between 0 and 100 |
660 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 660 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
661 | 661 | ||
662 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 662 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | void VolumeControl::bassMoved ( int percent ) | 666 | void VolumeControl::bassMoved ( int percent ) |
667 | { | 667 | { |
668 | m_bass_percent = 100 - percent; | 668 | m_bass_percent = 100 - percent; |
669 | 669 | ||
670 | // clamp bass percent to be between 0 and 100 | 670 | // clamp bass percent to be between 0 and 100 |
671 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); | 671 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); |
672 | 672 | ||
673 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | 673 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | 677 | ||
678 | void VolumeControl::trebleMoved ( int percent ) | 678 | void VolumeControl::trebleMoved ( int percent ) |
679 | { | 679 | { |
680 | m_treble_percent = 100 - percent; | 680 | m_treble_percent = 100 - percent; |
681 | 681 | ||
682 | // clamp treble percent to be between 0 and 100 | 682 | // clamp treble percent to be between 0 and 100 |
683 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); | 683 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); |
684 | 684 | ||
685 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | 685 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); |
686 | } | 686 | } |
687 | 687 | ||
688 | 688 | ||
689 | 689 | ||
690 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 690 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
691 | { | 691 | { |
692 | Config cfg ( "qpe" ); | 692 | Config cfg ( "qpe" ); |
693 | cfg. setGroup ( "Volume" ); | 693 | cfg. setGroup ( "Volume" ); |
694 | cfg. writeEntry ( entry, val ); | 694 | cfg. writeEntry ( entry, val ); |
695 | // cfg. write ( ); | 695 | // cfg. write ( ); |
696 | 696 | ||
697 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 697 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
698 | switch ( upd ) { | 698 | switch ( upd ) { |
699 | case UPD_Vol: { | 699 | case UPD_Vol: { |
700 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 700 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
701 | break; | 701 | break; |
702 | } | 702 | } |
703 | case UPD_Mic: { | 703 | case UPD_Mic: { |
704 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 704 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
705 | break; | 705 | break; |
706 | } | 706 | } |
707 | case UPD_Bass: { | 707 | case UPD_Bass: { |
708 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | 708 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; |
709 | break; | 709 | break; |
710 | } | 710 | } |
711 | case UPD_Treble: { | 711 | case UPD_Treble: { |
712 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | 712 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; |
713 | break; | 713 | break; |
714 | } | 714 | } |
715 | 715 | ||
716 | case UPD_None: | 716 | case UPD_None: |
717 | break; | 717 | break; |
718 | } | 718 | } |
719 | #endif | 719 | #endif |
720 | } | 720 | } |
721 | 721 | ||
722 | //=========================================================================== | 722 | //=========================================================================== |
723 | 723 | ||
724 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 724 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
725 | : QWidget( parent, name ) | 725 | : QWidget( parent, name ) |
726 | { | 726 | { |
727 | setFixedWidth ( AppLnk::smallIconSize() ); | 727 | setFixedWidth ( AppLnk::smallIconSize() ); |
728 | setFixedHeight ( AppLnk::smallIconSize()+4 ); | 728 | setFixedHeight ( AppLnk::smallIconSize()+4 ); |
729 | 729 | ||
730 | QPixmap pic; | 730 | QPixmap pic; |
731 | pic.convertFromImage( Resource::loadImage( "volume" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 731 | pic.convertFromImage( Resource::loadImage( "volume" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
732 | m_pixmap = new QPixmap ( pic ); | 732 | m_pixmap = new QPixmap ( pic ); |
733 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); | 733 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); |
734 | 734 | ||
735 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); | 735 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); |
736 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); | 736 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); |
737 | } | 737 | } |
738 | 738 | ||
739 | VolumeApplet::~VolumeApplet() | 739 | VolumeApplet::~VolumeApplet() |
740 | { | 740 | { |
741 | delete m_pixmap; | 741 | delete m_pixmap; |
742 | } | 742 | } |
743 | 743 | ||
744 | int VolumeApplet::position() | 744 | int VolumeApplet::position() |
745 | { | 745 | { |
746 | return 6; | 746 | return 6; |
747 | } | 747 | } |
748 | 748 | ||
749 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 749 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
750 | { | 750 | { |
751 | if ( m_dialog-> isVisible ( )) | 751 | if ( m_dialog-> isVisible ( )) |
752 | m_dialog-> hide ( ); | 752 | m_dialog-> hide ( ); |
753 | else | 753 | else |
754 | m_dialog-> show ( true ); | 754 | m_dialog-> show ( true ); |
755 | } | 755 | } |
756 | 756 | ||
757 | void VolumeApplet::redraw ( bool all ) | 757 | void VolumeApplet::redraw ( bool all ) |
758 | { | 758 | { |
759 | if ( all ) | 759 | if ( all ) |
760 | repaint ( true ); | 760 | repaint ( true ); |
761 | else | 761 | else |
762 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 762 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
763 | } | 763 | } |
764 | 764 | ||
765 | 765 | ||
766 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 766 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
767 | { | 767 | { |
768 | QPainter p ( this ); | 768 | QPainter p ( this ); |
769 | 769 | ||
770 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); | 770 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); |
771 | p. setPen ( darkGray ); | 771 | p. setPen ( darkGray ); |
772 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 772 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
773 | 773 | ||
774 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 774 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
775 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 775 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
776 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 776 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
777 | 777 | ||
778 | if ( m_dialog-> volMuted ( )) { | 778 | if ( m_dialog-> volMuted ( )) { |
779 | p. setPen ( red ); | 779 | p. setPen ( red ); |
780 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 780 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
781 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 781 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
782 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 782 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
783 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 783 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | 786 | ||
787 | 787 | ||
788 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) | 788 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) |
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index 364f3ad..88ab032 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp | |||
@@ -1,509 +1,509 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de> | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de> |
3 | ** | 3 | ** |
4 | ** This file may be distributed and/or modified under the terms of the | 4 | ** This file may be distributed and/or modified under the terms of the |
5 | ** GNU General Public License version 2 as published by the Free Software | 5 | ** GNU General Public License version 2 as published by the Free Software |
6 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
7 | ** packaging of this file. | 7 | ** packaging of this file. |
8 | ** | 8 | ** |
9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | 13 | ||
14 | #include "wireless.h" | 14 | #include "wireless.h" |
15 | #include "mgraph.h" | 15 | #include "mgraph.h" |
16 | #include "advancedconfig.h" | 16 | #include "advancedconfig.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/odebug.h> | 19 | #include <opie2/odebug.h> |
20 | #include <opie2/onetwork.h> | 20 | #include <opie2/onetwork.h> |
21 | #include <opie2/otaskbarapplet.h> | 21 | #include <opie2/otaskbarapplet.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
25 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
26 | using namespace Opie::Net; | 26 | using namespace Opie::Net; |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qradiobutton.h> | 29 | #include <qradiobutton.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qslider.h> | 33 | #include <qslider.h> |
34 | #include <qbuttongroup.h> | 34 | #include <qbuttongroup.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | 38 | ||
39 | /* STD */ | 39 | /* STD */ |
40 | #include <math.h> | 40 | #include <math.h> |
41 | #include <sys/types.h> | 41 | #include <sys/types.h> |
42 | #include <signal.h> | 42 | #include <signal.h> |
43 | #if defined (__GNUC__) && (__GNUC__ < 3) | 43 | #if defined (__GNUC__) && (__GNUC__ < 3) |
44 | #define round qRound | 44 | #define round qRound |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | //#define MDEBUG | 47 | //#define MDEBUG |
48 | #undef MDEBUG | 48 | #undef MDEBUG |
49 | 49 | ||
50 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) | 50 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) |
51 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) | 51 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) |
52 | { | 52 | { |
53 | 53 | ||
54 | readConfig(); | 54 | readConfig(); |
55 | writeConfigEntry( "UpdateFrequency", updateFrequency ); | 55 | writeConfigEntry( "UpdateFrequency", updateFrequency ); |
56 | 56 | ||
57 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 57 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
58 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); | 58 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); |
59 | 59 | ||
60 | /* status label */ | 60 | /* status label */ |
61 | 61 | ||
62 | statusLabel = new QLabel( this, "statuslabel" ); | 62 | statusLabel = new QLabel( this, "statuslabel" ); |
63 | QString text( "Wireless Status:<br>" | 63 | QString text( "Wireless Status:<br>" |
64 | "*** Unknown ***<br>" | 64 | "*** Unknown ***<br>" |
65 | "Card not inserted ?<br>" | 65 | "Card not inserted ?<br>" |
66 | "Or Sharp ROM ?<br>" | 66 | "Or Sharp ROM ?<br>" |
67 | "CELL: 00:00:00:00:00:00" ); | 67 | "CELL: 00:00:00:00:00:00" ); |
68 | /* QString text( "Station: Unknown<br>" | 68 | /* QString text( "Station: Unknown<br>" |
69 | "ESSID: Unknown<br>" | 69 | "ESSID: Unknown<br>" |
70 | "MODE: Unknown<br>" | 70 | "MODE: Unknown<br>" |
71 | "FREQ: Unknown<br>" | 71 | "FREQ: Unknown<br>" |
72 | "CELL: AA:BB:CC:DD:EE:FF" ); */ | 72 | "CELL: AA:BB:CC:DD:EE:FF" ); */ |
73 | statusLabel->setText( text ); | 73 | statusLabel->setText( text ); |
74 | statusLabel->setFixedSize( statusLabel->sizeHint() ); | 74 | statusLabel->setFixedSize( statusLabel->sizeHint() ); |
75 | grid->addWidget( statusLabel, 0, 0 ); | 75 | grid->addWidget( statusLabel, 0, 0 ); |
76 | 76 | ||
77 | /* visualization group box */ | 77 | /* visualization group box */ |
78 | 78 | ||
79 | /* quality graph */ | 79 | /* quality graph */ |
80 | 80 | ||
81 | mgraph = new MGraph( this ); | 81 | mgraph = new MGraph( this ); |
82 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 82 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
83 | mgraph->setMin( 0 ); | 83 | mgraph->setMin( 0 ); |
84 | mgraph->setMax( 92 ); | 84 | mgraph->setMax( 92 ); |
85 | grid->addWidget( mgraph, 1, 0 ); | 85 | grid->addWidget( mgraph, 1, 0 ); |
86 | mgraph->setFocusPolicy( QWidget::NoFocus ); | 86 | mgraph->setFocusPolicy( QWidget::NoFocus ); |
87 | 87 | ||
88 | /* advanced configuration Button */ | 88 | /* advanced configuration Button */ |
89 | 89 | ||
90 | QPushButton* advanced = new QPushButton( "Advanced...", this ); | 90 | QPushButton* advanced = new QPushButton( "Advanced...", this ); |
91 | advanced->setFocusPolicy( QWidget::NoFocus ); | 91 | advanced->setFocusPolicy( QWidget::NoFocus ); |
92 | grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); | 92 | grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); |
93 | connect( advanced, SIGNAL( clicked() ), | 93 | connect( advanced, SIGNAL( clicked() ), |
94 | this, SLOT( advancedConfigClicked() ) ); | 94 | this, SLOT( advancedConfigClicked() ) ); |
95 | 95 | ||
96 | /* update Frequency Label */ | 96 | /* update Frequency Label */ |
97 | 97 | ||
98 | updateLabel = new QLabel( this ); | 98 | updateLabel = new QLabel( this ); |
99 | text.sprintf( "Update every %d s", updateFrequency ); | 99 | text.sprintf( "Update every %d s", updateFrequency ); |
100 | updateLabel->setText( text ); | 100 | updateLabel->setText( text ); |
101 | grid->addWidget( updateLabel, 2, 1 ); | 101 | grid->addWidget( updateLabel, 2, 1 ); |
102 | 102 | ||
103 | /* update Frequency Slider */ | 103 | /* update Frequency Slider */ |
104 | 104 | ||
105 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); | 105 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); |
106 | updateSlider->setRange( 0, 9 ); | 106 | updateSlider->setRange( 0, 9 ); |
107 | updateSlider->setValue( updateFrequency ); | 107 | updateSlider->setValue( updateFrequency ); |
108 | updateSlider->setTickmarks( QSlider::Both ); | 108 | updateSlider->setTickmarks( QSlider::Both ); |
109 | updateSlider->setTickInterval( 1 ); | 109 | updateSlider->setTickInterval( 1 ); |
110 | updateSlider->setSteps( 1, 1 ); | 110 | updateSlider->setSteps( 1, 1 ); |
111 | updateSlider->setFocusPolicy( QWidget::NoFocus ); | 111 | updateSlider->setFocusPolicy( QWidget::NoFocus ); |
112 | grid->addWidget( updateSlider, 1, 1 ); | 112 | grid->addWidget( updateSlider, 1, 1 ); |
113 | connect( updateSlider, SIGNAL( valueChanged(int) ), | 113 | connect( updateSlider, SIGNAL( valueChanged(int) ), |
114 | this, SLOT( updateDelayChange(int) ) ); | 114 | this, SLOT( updateDelayChange(int) ) ); |
115 | 115 | ||
116 | setFixedSize( sizeHint() ); | 116 | setFixedSize( sizeHint() ); |
117 | setFocusPolicy( QWidget::NoFocus ); | 117 | setFocusPolicy( QWidget::NoFocus ); |
118 | 118 | ||
119 | applet->updateDelayChange( updateFrequency ); | 119 | applet->updateDelayChange( updateFrequency ); |
120 | 120 | ||
121 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 121 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void WirelessControl::advancedConfigClicked() | 124 | void WirelessControl::advancedConfigClicked() |
125 | { | 125 | { |
126 | AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE ); | 126 | AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE ); |
127 | int result = a->exec(); | 127 | int result = a->exec(); |
128 | a->hide(); | 128 | a->hide(); |
129 | delete a; | 129 | delete a; |
130 | if ( result == QDialog::Accepted ) | 130 | if ( result == QDialog::Accepted ) |
131 | { | 131 | { |
132 | readConfig(); | 132 | readConfig(); |
133 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 133 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | void WirelessControl::updateDelayChange( int delay ) | 137 | void WirelessControl::updateDelayChange( int delay ) |
138 | { | 138 | { |
139 | QString text; | 139 | QString text; |
140 | text.sprintf( "Update every %d s", delay ); | 140 | text.sprintf( "Update every %d s", delay ); |
141 | updateLabel->setText( text ); | 141 | updateLabel->setText( text ); |
142 | applet->updateDelayChange( delay ); | 142 | applet->updateDelayChange( delay ); |
143 | writeConfigEntry( "UpdateFrequency", delay ); | 143 | writeConfigEntry( "UpdateFrequency", delay ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void WirelessControl::displayStyleChange( int style ) | 146 | void WirelessControl::displayStyleChange( int style ) |
147 | { | 147 | { |
148 | applet->displayStyleChange( style ); | 148 | applet->displayStyleChange( style ); |
149 | writeConfigEntry( "DisplayStyle", style ); | 149 | writeConfigEntry( "DisplayStyle", style ); |
150 | } | 150 | } |
151 | 151 | ||
152 | void WirelessControl::show ( bool ) | 152 | void WirelessControl::show ( bool ) |
153 | { | 153 | { |
154 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); | 154 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); |
155 | 155 | ||
156 | int w = sizeHint().width(); | 156 | int w = sizeHint().width(); |
157 | int x = curPos.x() - ( w / 2 ); | 157 | int x = curPos.x() - ( w / 2 ); |
158 | 158 | ||
159 | if ( ( x + w ) > QPEApplication::desktop() ->width() ) | 159 | if ( ( x + w ) > QPEApplication::desktop() ->width() ) |
160 | x = QPEApplication::desktop ( ) -> width ( ) - w; | 160 | x = QPEApplication::desktop ( ) -> width ( ) - w; |
161 | 161 | ||
162 | move( x, curPos.y () - sizeHint().height () ); | 162 | move( QMAX(x,0), curPos.y () - sizeHint().height () ); |
163 | QFrame::show(); | 163 | QFrame::show(); |
164 | } | 164 | } |
165 | 165 | ||
166 | void WirelessControl::readConfig() | 166 | void WirelessControl::readConfig() |
167 | { | 167 | { |
168 | Config cfg( "qpe" ); | 168 | Config cfg( "qpe" ); |
169 | cfg.setGroup( "Wireless" ); | 169 | cfg.setGroup( "Wireless" ); |
170 | 170 | ||
171 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); | 171 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); |
172 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); | 172 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); |
173 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); | 173 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); |
174 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); | 174 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); |
175 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); | 175 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); |
176 | } | 176 | } |
177 | 177 | ||
178 | void WirelessControl::writeConfigEntry( const char *entry, int val ) | 178 | void WirelessControl::writeConfigEntry( const char *entry, int val ) |
179 | { | 179 | { |
180 | Config cfg( "qpe" ); | 180 | Config cfg( "qpe" ); |
181 | cfg.setGroup( "Wireless" ); | 181 | cfg.setGroup( "Wireless" ); |
182 | cfg.writeEntry( entry, val ); | 182 | cfg.writeEntry( entry, val ); |
183 | } | 183 | } |
184 | 184 | ||
185 | //=========================================================================== | 185 | //=========================================================================== |
186 | 186 | ||
187 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) | 187 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) |
188 | : QWidget( parent, name ), | 188 | : QWidget( parent, name ), |
189 | timer( 0 ), interface( 0 ), oldiface( 0 ), | 189 | timer( 0 ), interface( 0 ), oldiface( 0 ), |
190 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) | 190 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) |
191 | { | 191 | { |
192 | setFixedHeight( 18 ); | 192 | setFixedHeight( 18 ); |
193 | setFixedWidth( 14 ); | 193 | setFixedWidth( 14 ); |
194 | status = new WirelessControl( this, this, "wireless status" ); | 194 | status = new WirelessControl( this, this, "wireless status" ); |
195 | } | 195 | } |
196 | 196 | ||
197 | void WirelessApplet::checkInterface() | 197 | void WirelessApplet::checkInterface() |
198 | { | 198 | { |
199 | interface = 0L; | 199 | interface = 0L; |
200 | ONetwork* net = ONetwork::instance(); | 200 | ONetwork* net = ONetwork::instance(); |
201 | net->synchronize(); | 201 | net->synchronize(); |
202 | ONetwork::InterfaceIterator it = net->iterator(); | 202 | ONetwork::InterfaceIterator it = net->iterator(); |
203 | 203 | ||
204 | while ( it.current() && !it.current()->isWireless() ) ++it; | 204 | while ( it.current() && !it.current()->isWireless() ) ++it; |
205 | 205 | ||
206 | if ( it.current() && it.current()->isWireless() ) | 206 | if ( it.current() && it.current()->isWireless() ) |
207 | interface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 207 | interface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
208 | 208 | ||
209 | if ( interface ) | 209 | if ( interface ) |
210 | { | 210 | { |
211 | #ifdef MDEBUG | 211 | #ifdef MDEBUG |
212 | odebug << "WIFIAPPLET: using interface '" << ( const char* ) interface->name() << "'" << oendl; | 212 | odebug << "WIFIAPPLET: using interface '" << ( const char* ) interface->name() << "'" << oendl; |
213 | #endif | 213 | #endif |
214 | 214 | ||
215 | } | 215 | } |
216 | else | 216 | else |
217 | { | 217 | { |
218 | #ifdef MDEBUG | 218 | #ifdef MDEBUG |
219 | odebug << "WIFIAPPLET: D'oh! No Wireless interface present... :(" << oendl; | 219 | odebug << "WIFIAPPLET: D'oh! No Wireless interface present... :(" << oendl; |
220 | #endif | 220 | #endif |
221 | hide(); | 221 | hide(); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | void WirelessApplet::renewDHCP() | 225 | void WirelessApplet::renewDHCP() |
226 | { | 226 | { |
227 | #ifdef MDEBUG | 227 | #ifdef MDEBUG |
228 | odebug << "WIFIAPPLET: Going to request a DHCP configuration renew." << oendl; | 228 | odebug << "WIFIAPPLET: Going to request a DHCP configuration renew." << oendl; |
229 | #endif | 229 | #endif |
230 | 230 | ||
231 | QString pidfile; | 231 | QString pidfile; |
232 | if ( !interface ) | 232 | if ( !interface ) |
233 | return ; | 233 | return ; |
234 | QString ifacename( interface->name() ); | 234 | QString ifacename( interface->name() ); |
235 | 235 | ||
236 | // At first we are trying dhcpcd | 236 | // At first we are trying dhcpcd |
237 | 237 | ||
238 | pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); | 238 | pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); |
239 | #ifdef MDEBUG | 239 | #ifdef MDEBUG |
240 | odebug << "WIFIAPPLET: dhcpcd pidfile is '" << ( const char* ) pidfile << "'" << oendl; | 240 | odebug << "WIFIAPPLET: dhcpcd pidfile is '" << ( const char* ) pidfile << "'" << oendl; |
241 | #endif | 241 | #endif |
242 | int pid; | 242 | int pid; |
243 | QFile pfile( pidfile ); | 243 | QFile pfile( pidfile ); |
244 | bool hasFile = pfile.open( IO_ReadOnly ); | 244 | bool hasFile = pfile.open( IO_ReadOnly ); |
245 | QTextStream s( &pfile ); | 245 | QTextStream s( &pfile ); |
246 | if ( hasFile ) | 246 | if ( hasFile ) |
247 | { | 247 | { |
248 | s >> pid; | 248 | s >> pid; |
249 | #ifdef MDEBUG | 249 | #ifdef MDEBUG |
250 | odebug << "WIFIAPPLET: sent SIGALARM to pid " << pid << "" << oendl; | 250 | odebug << "WIFIAPPLET: sent SIGALARM to pid " << pid << "" << oendl; |
251 | #endif | 251 | #endif |
252 | kill( pid, SIGALRM ); | 252 | kill( pid, SIGALRM ); |
253 | return ; | 253 | return ; |
254 | } | 254 | } |
255 | 255 | ||
256 | // No dhcpcd, so we are trying udhcpc | 256 | // No dhcpcd, so we are trying udhcpc |
257 | #ifdef MDEBUG | 257 | #ifdef MDEBUG |
258 | odebug << "WIFIAPPLET: dhcpcd not available." << oendl; | 258 | odebug << "WIFIAPPLET: dhcpcd not available." << oendl; |
259 | #endif | 259 | #endif |
260 | pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename ); | 260 | pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename ); |
261 | #ifdef MDEBUG | 261 | #ifdef MDEBUG |
262 | odebug << "WIFIAPPLET: udhcpc pidfile is '" << ( const char* ) pidfile << "'" << oendl; | 262 | odebug << "WIFIAPPLET: udhcpc pidfile is '" << ( const char* ) pidfile << "'" << oendl; |
263 | #endif | 263 | #endif |
264 | QFile pfile2( pidfile ); | 264 | QFile pfile2( pidfile ); |
265 | hasFile = pfile2.open( IO_ReadOnly ); | 265 | hasFile = pfile2.open( IO_ReadOnly ); |
266 | QTextStream s2( &pfile2 ); | 266 | QTextStream s2( &pfile2 ); |
267 | if ( hasFile ) | 267 | if ( hasFile ) |
268 | { | 268 | { |
269 | s2 >> pid; | 269 | s2 >> pid; |
270 | #ifdef MDEBUG | 270 | #ifdef MDEBUG |
271 | odebug << "WIFIAPPLET: sent SIGUSR1 to pid " << pid << "" << oendl; | 271 | odebug << "WIFIAPPLET: sent SIGUSR1 to pid " << pid << "" << oendl; |
272 | #endif | 272 | #endif |
273 | kill( pid, SIGUSR1 ); | 273 | kill( pid, SIGUSR1 ); |
274 | return ; | 274 | return ; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) | 278 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) |
279 | { | 279 | { |
280 | rocESSID = ESSID; | 280 | rocESSID = ESSID; |
281 | rocFREQ = FREQ; | 281 | rocFREQ = FREQ; |
282 | rocAP = AP; | 282 | rocAP = AP; |
283 | rocMODE = MODE; | 283 | rocMODE = MODE; |
284 | } | 284 | } |
285 | 285 | ||
286 | void WirelessApplet::updateDelayChange( int delay ) | 286 | void WirelessApplet::updateDelayChange( int delay ) |
287 | { | 287 | { |
288 | if ( timer ) | 288 | if ( timer ) |
289 | killTimer( timer ); | 289 | killTimer( timer ); |
290 | delay *= 1000; | 290 | delay *= 1000; |
291 | if ( delay == 0 ) | 291 | if ( delay == 0 ) |
292 | delay = 50; | 292 | delay = 50; |
293 | timer = startTimer( delay ); | 293 | timer = startTimer( delay ); |
294 | } | 294 | } |
295 | 295 | ||
296 | void WirelessApplet::displayStyleChange( int style ) | 296 | void WirelessApplet::displayStyleChange( int style ) |
297 | { | 297 | { |
298 | visualStyle = style; | 298 | visualStyle = style; |
299 | repaint(); | 299 | repaint(); |
300 | } | 300 | } |
301 | 301 | ||
302 | WirelessApplet::~WirelessApplet() | 302 | WirelessApplet::~WirelessApplet() |
303 | {} | 303 | {} |
304 | 304 | ||
305 | void WirelessApplet::timerEvent( QTimerEvent* ) | 305 | void WirelessApplet::timerEvent( QTimerEvent* ) |
306 | { | 306 | { |
307 | #ifdef MDEBUG | 307 | #ifdef MDEBUG |
308 | odebug << "WirelessApplet::timerEvent" << oendl; | 308 | odebug << "WirelessApplet::timerEvent" << oendl; |
309 | #endif | 309 | #endif |
310 | if ( interface ) | 310 | if ( interface ) |
311 | { | 311 | { |
312 | if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) ) | 312 | if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) ) |
313 | { | 313 | { |
314 | #ifdef MDEBUG | 314 | #ifdef MDEBUG |
315 | odebug << "WIFIAPPLET: Interface no longer present." << oendl; | 315 | odebug << "WIFIAPPLET: Interface no longer present." << oendl; |
316 | #endif | 316 | #endif |
317 | interface = 0L; | 317 | interface = 0L; |
318 | mustRepaint(); | 318 | mustRepaint(); |
319 | return; | 319 | return; |
320 | } | 320 | } |
321 | 321 | ||
322 | if ( mustRepaint() ) | 322 | if ( mustRepaint() ) |
323 | { | 323 | { |
324 | #ifdef MDEBUG | 324 | #ifdef MDEBUG |
325 | odebug << "WIFIAPPLET: A value has changed -> repainting." << oendl; | 325 | odebug << "WIFIAPPLET: A value has changed -> repainting." << oendl; |
326 | #endif | 326 | #endif |
327 | repaint(); | 327 | repaint(); |
328 | } | 328 | } |
329 | 329 | ||
330 | if ( status->isVisible() ) | 330 | if ( status->isVisible() ) |
331 | { | 331 | { |
332 | updatePopupWindow(); | 332 | updatePopupWindow(); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | else | 335 | else |
336 | { | 336 | { |
337 | checkInterface(); | 337 | checkInterface(); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | void WirelessApplet::mousePressEvent( QMouseEvent * ) | 341 | void WirelessApplet::mousePressEvent( QMouseEvent * ) |
342 | { | 342 | { |
343 | if ( status->isVisible() ) | 343 | if ( status->isVisible() ) |
344 | status->hide(); | 344 | status->hide(); |
345 | else | 345 | else |
346 | status->show( true ); | 346 | status->show( true ); |
347 | } | 347 | } |
348 | 348 | ||
349 | bool WirelessApplet::mustRepaint() | 349 | bool WirelessApplet::mustRepaint() |
350 | { | 350 | { |
351 | // check if there are enough changes to justify a (flickering) repaint | 351 | // check if there are enough changes to justify a (flickering) repaint |
352 | 352 | ||
353 | // has the interface changed? | 353 | // has the interface changed? |
354 | 354 | ||
355 | if ( interface != oldiface ) | 355 | if ( interface != oldiface ) |
356 | { | 356 | { |
357 | oldiface = interface; | 357 | oldiface = interface; |
358 | if ( interface ) | 358 | if ( interface ) |
359 | { | 359 | { |
360 | #ifdef MDEBUG | 360 | #ifdef MDEBUG |
361 | odebug << "WIFIAPPLET: We had no interface but now we have one! :-)" << oendl; | 361 | odebug << "WIFIAPPLET: We had no interface but now we have one! :-)" << oendl; |
362 | #endif | 362 | #endif |
363 | show(); | 363 | show(); |
364 | } | 364 | } |
365 | else | 365 | else |
366 | { | 366 | { |
367 | #ifdef MDEBUG | 367 | #ifdef MDEBUG |
368 | odebug << "WIFIAPPLET: We had a interface but now we don't have one! ;-(" << oendl; | 368 | odebug << "WIFIAPPLET: We had a interface but now we don't have one! ;-(" << oendl; |
369 | #endif | 369 | #endif |
370 | hide(); | 370 | hide(); |
371 | return true; | 371 | return true; |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | int rings = numberOfRings(); | 375 | int rings = numberOfRings(); |
376 | 376 | ||
377 | if ( rings != oldrings ) | 377 | if ( rings != oldrings ) |
378 | { | 378 | { |
379 | oldrings = rings; | 379 | oldrings = rings; |
380 | return true; | 380 | return true; |
381 | } | 381 | } |
382 | 382 | ||
383 | int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100; | 383 | int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100; |
384 | int signalH = interface->signalStrength() * ( height() - 3 ) / 100; | 384 | int signalH = interface->signalStrength() * ( height() - 3 ) / 100; |
385 | int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100; | 385 | int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100; |
386 | 386 | ||
387 | if ( ( noiseH != oldnoiseH ) | 387 | if ( ( noiseH != oldnoiseH ) |
388 | || ( signalH != oldsignalH ) | 388 | || ( signalH != oldsignalH ) |
389 | || ( qualityH != oldqualityH ) ) | 389 | || ( qualityH != oldqualityH ) ) |
390 | { | 390 | { |
391 | oldnoiseH = noiseH; | 391 | oldnoiseH = noiseH; |
392 | oldsignalH = signalH; | 392 | oldsignalH = signalH; |
393 | oldqualityH = qualityH; | 393 | oldqualityH = qualityH; |
394 | return true; | 394 | return true; |
395 | } | 395 | } |
396 | 396 | ||
397 | if ( rocESSID && ( oldESSID != interface->SSID() ) ) | 397 | if ( rocESSID && ( oldESSID != interface->SSID() ) ) |
398 | { | 398 | { |
399 | #ifdef MDEBUG | 399 | #ifdef MDEBUG |
400 | odebug << "WIFIAPPLET: ESSID has changed." << oendl; | 400 | odebug << "WIFIAPPLET: ESSID has changed." << oendl; |
401 | #endif | 401 | #endif |
402 | renewDHCP(); | 402 | renewDHCP(); |
403 | } | 403 | } |
404 | else if ( rocFREQ && ( oldFREQ != interface->frequency() ) ) | 404 | else if ( rocFREQ && ( oldFREQ != interface->frequency() ) ) |
405 | { | 405 | { |
406 | #ifdef MDEBUG | 406 | #ifdef MDEBUG |
407 | odebug << "WIFIAPPLET: FREQ has changed." << oendl; | 407 | odebug << "WIFIAPPLET: FREQ has changed." << oendl; |
408 | #endif | 408 | #endif |
409 | renewDHCP(); | 409 | renewDHCP(); |
410 | } | 410 | } |
411 | else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) ) | 411 | else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) ) |
412 | { | 412 | { |
413 | #ifdef MDEBUG | 413 | #ifdef MDEBUG |
414 | odebug << "WIFIAPPLET: AP has changed." << oendl; | 414 | odebug << "WIFIAPPLET: AP has changed." << oendl; |
415 | #endif | 415 | #endif |
416 | renewDHCP(); | 416 | renewDHCP(); |
417 | } | 417 | } |
418 | else if ( rocMODE && ( oldMODE != interface->mode() ) ) | 418 | else if ( rocMODE && ( oldMODE != interface->mode() ) ) |
419 | { | 419 | { |
420 | #ifdef MDEBUG | 420 | #ifdef MDEBUG |
421 | odebug << "WIFIAPPLET: MODE has changed." << oendl; | 421 | odebug << "WIFIAPPLET: MODE has changed." << oendl; |
422 | #endif | 422 | #endif |
423 | renewDHCP(); | 423 | renewDHCP(); |
424 | } | 424 | } |
425 | 425 | ||
426 | oldESSID = interface->SSID(); | 426 | oldESSID = interface->SSID(); |
427 | oldMODE = interface->mode(); | 427 | oldMODE = interface->mode(); |
428 | oldFREQ = interface->frequency(); | 428 | oldFREQ = interface->frequency(); |
429 | oldAP = interface->associatedAP().toString(); | 429 | oldAP = interface->associatedAP().toString(); |
430 | 430 | ||
431 | return false; | 431 | return false; |
432 | } | 432 | } |
433 | 433 | ||
434 | void WirelessApplet::updatePopupWindow() | 434 | void WirelessApplet::updatePopupWindow() |
435 | { | 435 | { |
436 | int qualityH = interface->signalStrength(); | 436 | int qualityH = interface->signalStrength(); |
437 | 437 | ||
438 | if ( status->mgraph ) | 438 | if ( status->mgraph ) |
439 | status->mgraph->addValue( qualityH, false ); | 439 | status->mgraph->addValue( qualityH, false ); |
440 | 440 | ||
441 | QString freqString; | 441 | QString freqString; |
442 | QString cell = ( interface->mode() == "Managed" ) ? "AP: " : "Cell: "; | 442 | QString cell = ( interface->mode() == "Managed" ) ? "AP: " : "Cell: "; |
443 | freqString.sprintf( "%.3f GHz", interface->frequency() ); | 443 | freqString.sprintf( "%.3f GHz", interface->frequency() ); |
444 | status->statusLabel->setText( "Station: " + interface->nickName() + "<br>" + | 444 | status->statusLabel->setText( "Station: " + interface->nickName() + "<br>" + |
445 | "ESSID: " + interface->SSID() + "<br>" + | 445 | "ESSID: " + interface->SSID() + "<br>" + |
446 | "MODE: " + interface->mode() + "<br>" + | 446 | "MODE: " + interface->mode() + "<br>" + |
447 | "FREQ: " + freqString + "<br>" + | 447 | "FREQ: " + freqString + "<br>" + |
448 | cell + " " + interface->associatedAP().toString() ); | 448 | cell + " " + interface->associatedAP().toString() ); |
449 | } | 449 | } |
450 | 450 | ||
451 | int WirelessApplet::numberOfRings() | 451 | int WirelessApplet::numberOfRings() |
452 | { | 452 | { |
453 | if ( !interface ) return -1; | 453 | if ( !interface ) return -1; |
454 | int qualityH = interface->signalStrength(); | 454 | int qualityH = interface->signalStrength(); |
455 | odebug << "quality = " << qualityH << "" << oendl; | 455 | odebug << "quality = " << qualityH << "" << oendl; |
456 | if ( qualityH < 1 ) return -1; | 456 | if ( qualityH < 1 ) return -1; |
457 | if ( qualityH < 20 ) return 0; | 457 | if ( qualityH < 20 ) return 0; |
458 | if ( qualityH < 40 ) return 1; | 458 | if ( qualityH < 40 ) return 1; |
459 | if ( qualityH < 60 ) return 2; | 459 | if ( qualityH < 60 ) return 2; |
460 | if ( qualityH < 65 ) return 3; | 460 | if ( qualityH < 65 ) return 3; |
461 | return 4; | 461 | return 4; |
462 | } | 462 | } |
463 | 463 | ||
464 | void WirelessApplet::paintEvent( QPaintEvent* ) | 464 | void WirelessApplet::paintEvent( QPaintEvent* ) |
465 | { | 465 | { |
466 | QPainter p( this ); | 466 | QPainter p( this ); |
467 | int h = height(); | 467 | int h = height(); |
468 | int w = width(); | 468 | int w = width(); |
469 | int m = 2; | 469 | int m = 2; |
470 | 470 | ||
471 | p.drawLine( m, h-m-1, round( w/2.0 ), round( 0+h/3.0 ) ); | 471 | p.drawLine( m, h-m-1, round( w/2.0 ), round( 0+h/3.0 ) ); |
472 | p.drawLine( round( w/2.0 ), round( 0+h/3.0 ), w-m, h-m-1 ); | 472 | p.drawLine( round( w/2.0 ), round( 0+h/3.0 ), w-m, h-m-1 ); |
473 | p.setPen( QColor( 150, 150, 150 ) ); | 473 | p.setPen( QColor( 150, 150, 150 ) ); |
474 | p.drawLine( w-m, h-m-1, m, h-m-1 ); | 474 | p.drawLine( w-m, h-m-1, m, h-m-1 ); |
475 | 475 | ||
476 | int rings = numberOfRings(); | 476 | int rings = numberOfRings(); |
477 | 477 | ||
478 | if ( rings == -1 ) | 478 | if ( rings == -1 ) |
479 | { | 479 | { |
480 | p.setPen( QPen( QColor( 200, 20, 20 ), 2 ) ); | 480 | p.setPen( QPen( QColor( 200, 20, 20 ), 2 ) ); |
481 | p.drawLine( w/2-m-m, h/2-m-m, w/2+m+m, h/2+m+m ); | 481 | p.drawLine( w/2-m-m, h/2-m-m, w/2+m+m, h/2+m+m ); |
482 | p.drawLine( w/2+m+m, h/2-m-m, w/2-m-m, h/2+m+m ); | 482 | p.drawLine( w/2+m+m, h/2-m-m, w/2-m-m, h/2+m+m ); |
483 | return; | 483 | return; |
484 | } | 484 | } |
485 | 485 | ||
486 | odebug << "WirelessApplet: painting " << rings << " rings" << oendl; | 486 | odebug << "WirelessApplet: painting " << rings << " rings" << oendl; |
487 | int radius = 2; | 487 | int radius = 2; |
488 | int rstep = 4; | 488 | int rstep = 4; |
489 | int maxrings = w/rstep; | 489 | int maxrings = w/rstep; |
490 | 490 | ||
491 | p.setPen( QColor( 200, 20, 20 ) ); | 491 | p.setPen( QColor( 200, 20, 20 ) ); |
492 | for ( int i = 0; i < rings; ++i ) | 492 | for ( int i = 0; i < rings; ++i ) |
493 | { | 493 | { |
494 | p.drawEllipse( w/2 - radius/2, h/3 - radius/2, radius, radius ); | 494 | p.drawEllipse( w/2 - radius/2, h/3 - radius/2, radius, radius ); |
495 | radius += rstep; | 495 | radius += rstep; |
496 | }; | 496 | }; |
497 | 497 | ||
498 | 498 | ||
499 | 499 | ||
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
503 | int WirelessApplet::position() | 503 | int WirelessApplet::position() |
504 | { | 504 | { |
505 | return 6; | 505 | return 6; |
506 | } | 506 | } |
507 | 507 | ||
508 | EXPORT_OPIE_APPLET_v1( WirelessApplet ) | 508 | EXPORT_OPIE_APPLET_v1( WirelessApplet ) |
509 | 509 | ||