-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 276f47f..6a14d07 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,513 +1,512 @@ | |||
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 | #include "oledbox.h" | 22 | #include "oledbox.h" |
23 | 23 | ||
24 | #include <opie2/odevice.h> | 24 | #include <opie2/odevice.h> |
25 | #include <opie2/otaskbarapplet.h> | 25 | #include <opie2/otaskbarapplet.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/qcopenvelope_qws.h> | 29 | #include <qpe/qcopenvelope_qws.h> |
30 | 30 | ||
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
33 | #include <qslider.h> | 33 | #include <qslider.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | 39 | ||
40 | #include <stdio.h> | 40 | #include <stdio.h> |
41 | 41 | ||
42 | using namespace Opie::Core; | 42 | using namespace Opie::Core; |
43 | 43 | ||
44 | #define RATE_TIMER_INTERVAL 100 | 44 | #define RATE_TIMER_INTERVAL 100 |
45 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 45 | // 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. | 46 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
47 | 47 | ||
48 | 48 | ||
49 | /* XPM */ | 49 | /* XPM */ |
50 | using namespace Opie::Ui; | 50 | using namespace Opie::Ui; |
51 | static const char * vol_xpm[] = { | 51 | static const char * vol_xpm[] = { |
52 | "20 20 3 1", | 52 | "20 20 3 1", |
53 | " c None", | 53 | " c None", |
54 | ". c #0000FF", | 54 | ". c #0000FF", |
55 | "+ c #000000", | 55 | "+ c #000000", |
56 | " ", | 56 | " ", |
57 | " . ", | 57 | " . ", |
58 | " . . . . ", | 58 | " . . . . ", |
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 | /* XPM */ | 76 | /* XPM */ |
77 | static const char * mic_xpm[] = { | 77 | static const char * mic_xpm[] = { |
78 | "20 20 21 1", | 78 | "20 20 21 1", |
79 | " c None", | 79 | " c None", |
80 | ". c #000000", | 80 | ". c #000000", |
81 | "+ c #EEEEEE", | 81 | "+ c #EEEEEE", |
82 | "@ c #B4B6B4", | 82 | "@ c #B4B6B4", |
83 | "# c #8B8D8B", | 83 | "# c #8B8D8B", |
84 | "$ c #D5D6D5", | 84 | "$ c #D5D6D5", |
85 | "% c #E6E6E6", | 85 | "% c #E6E6E6", |
86 | "& c #9C9D9C", | 86 | "& c #9C9D9C", |
87 | "* c #6A696A", | 87 | "* c #6A696A", |
88 | "= c #E6E2E6", | 88 | "= c #E6E2E6", |
89 | "- c #F6F2F6", | 89 | "- c #F6F2F6", |
90 | "; c #CDC6CD", | 90 | "; c #CDC6CD", |
91 | "> c #737573", | 91 | "> c #737573", |
92 | ", c #4A484A", | 92 | ", c #4A484A", |
93 | "' c #DEDEDE", | 93 | "' c #DEDEDE", |
94 | ") c #F6EEF6", | 94 | ") c #F6EEF6", |
95 | "! c #414041", | 95 | "! c #414041", |
96 | "~ c #202020", | 96 | "~ c #202020", |
97 | "{ c #ACAEAC", | 97 | "{ c #ACAEAC", |
98 | "] c #838583", | 98 | "] c #838583", |
99 | "^ c #6A656A", | 99 | "^ c #6A656A", |
100 | " ", | 100 | " ", |
101 | " .... ", | 101 | " .... ", |
102 | " .+@+#. ", | 102 | " .+@+#. ", |
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 | static const char * bass_xpm[] = { | 122 | static const char * bass_xpm[] = { |
123 | "20 20 3 1", | 123 | "20 20 3 1", |
124 | " c None", | 124 | " c None", |
125 | ". c #000000", | 125 | ". c #000000", |
126 | "+ c #0000FF", | 126 | "+ c #0000FF", |
127 | " ", | 127 | " ", |
128 | " ", | 128 | " ", |
129 | " ", | 129 | " ", |
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 | static const char * treble_xpm[] = { | 149 | static const char * treble_xpm[] = { |
150 | "20 20 3 1", | 150 | "20 20 3 1", |
151 | " c None", | 151 | " c None", |
152 | ". c #0000FF", | 152 | ". c #0000FF", |
153 | "+ c #000000", | 153 | "+ c #000000", |
154 | " .. ", | 154 | " .. ", |
155 | " . .. ", | 155 | " . .. ", |
156 | " . .. ", | 156 | " . .. ", |
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 | /* XPM */ | 178 | /* XPM */ |
179 | static const char * alarm_xpm[] = { | 179 | static const char * alarm_xpm[] = { |
180 | "20 20 33 1", | 180 | "20 20 33 1", |
181 | " c None", | 181 | " c None", |
182 | ". c #080602", | 182 | ". c #080602", |
183 | "+ c #AAA602", | 183 | "+ c #AAA602", |
184 | "@ c #252002", | 184 | "@ c #252002", |
185 | "# c #434202", | 185 | "# c #434202", |
186 | "$ c #795602", | 186 | "$ c #795602", |
187 | "% c #C3C20D", | 187 | "% c #C3C20D", |
188 | "& c #DADAC2", | 188 | "& c #DADAC2", |
189 | "* c #826002", | 189 | "* c #826002", |
190 | "= c #740502", | 190 | "= c #740502", |
191 | "- c #D6D602", | 191 | "- c #D6D602", |
192 | "; c #322E02", | 192 | "; c #322E02", |
193 | "> c #826A02", | 193 | "> c #826A02", |
194 | ", c #F1F195", | 194 | ", c #F1F195", |
195 | "' c #959215", | 195 | "' c #959215", |
196 | ") c #423602", | 196 | ") c #423602", |
197 | "! c #4B0302", | 197 | "! c #4B0302", |
198 | "~ c #844315", | 198 | "~ c #844315", |
199 | "{ c #AAAA2A", | 199 | "{ c #AAAA2A", |
200 | "] c #E2DE42", | 200 | "] c #E2DE42", |
201 | "^ c #BA7E04", | 201 | "^ c #BA7E04", |
202 | "/ c #7F7502", | 202 | "/ c #7F7502", |
203 | "( c #828276", | 203 | "( c #828276", |
204 | "_ c #FEFE4E", | 204 | "_ c #FEFE4E", |
205 | ": c #7D1902", | 205 | ": c #7D1902", |
206 | "< c #989656", | 206 | "< c #989656", |
207 | "[ c #260B02", | 207 | "[ c #260B02", |
208 | "} c #F7F7D8", | 208 | "} c #F7F7D8", |
209 | "| c #DCDA5A", | 209 | "| c #DCDA5A", |
210 | "1 c #823102", | 210 | "1 c #823102", |
211 | "2 c #B1AC6B", | 211 | "2 c #B1AC6B", |
212 | "3 c #F7F710", | 212 | "3 c #F7F710", |
213 | "4 c #838204", | 213 | "4 c #838204", |
214 | " ", | 214 | " ", |
215 | " ", | 215 | " ", |
216 | " 4'4/ ", | 216 | " 4'4/ ", |
217 | " /-^= ", | 217 | " /-^= ", |
218 | " 42{4>4 ", | 218 | " 42{4>4 ", |
219 | " '2|+*$44 ", | 219 | " '2|+*$44 ", |
220 | " +2&3+$1*44 ", | 220 | " +2&3+$1*44 ", |
221 | " (%_}_+/$:>/4 ", | 221 | " (%_}_+/$:>/4 ", |
222 | " 4%_}3+#;>:*4 ", | 222 | " 4%_}3+#;>:*4 ", |
223 | " 4%_}&+#[1$/4 ", | 223 | " 4%_}&+#[1$/4 ", |
224 | " 4%_,2')[~~>4 ", | 224 | " 4%_,2')[~~>4 ", |
225 | " 4%33'4#@~1>4 ", | 225 | " 4%33'4#@~1>4 ", |
226 | " 4%3344#[:>/4 ", | 226 | " 4%3344#[:>/4 ", |
227 | " 42&_3'4#@>:*44 ", | 227 | " 42&_3'4#@>:*44 ", |
228 | " 42|}}3'4#[;$)$44 ", | 228 | " 42|}}3'4#[;$)$44 ", |
229 | "444{]]2^~~:!!#.@##/ ", | 229 | "444{]]2^~~:!!#.@##/ ", |
230 | "4444-%*:==!!=...../ ", | 230 | "4444-%*:==!!=...../ ", |
231 | " /:[.. ", | 231 | " /:[.. ", |
232 | " /@. ", | 232 | " /@. ", |
233 | " "}; | 233 | " "}; |
234 | 234 | ||
235 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 235 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
236 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 236 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
237 | { | 237 | { |
238 | m_icon = icon; | 238 | m_icon = icon; |
239 | 239 | ||
240 | bool has_wav_alarm = true; | 240 | bool has_wav_alarm = true; |
241 | bool has_bass = true; | 241 | bool has_bass = true; |
242 | bool has_treble = true; | 242 | bool has_treble = true; |
243 | 243 | ||
244 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually | 244 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
245 | case Model_Zaurus_SL5000: | 245 | case Model_Zaurus_SL5000: |
246 | has_wav_alarm = false; //poor guys probably feeling left out... | 246 | has_wav_alarm = false; //poor guys probably feeling left out... |
247 | break; | 247 | break; |
248 | default: | 248 | default: |
249 | break; | 249 | break; |
250 | } | 250 | } |
251 | 251 | ||
252 | if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 252 | if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { |
253 | has_bass = false; | 253 | has_bass = false; |
254 | has_treble = false; | 254 | has_treble = false; |
255 | } | 255 | } |
256 | 256 | ||
257 | |||
258 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 257 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
259 | 258 | ||
260 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 259 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
261 | grid-> setSpacing ( 4 ); | 260 | grid-> setSpacing ( 4 ); |
262 | grid-> setMargin ( 6 ); | 261 | grid-> setMargin ( 6 ); |
263 | 262 | ||
264 | QVBoxLayout *vbox; | 263 | QVBoxLayout *vbox; |
265 | QLabel *l; | 264 | QLabel *l; |
266 | 265 | ||
267 | vbox = new QVBoxLayout ( ); | 266 | vbox = new QVBoxLayout ( ); |
268 | vbox-> setSpacing ( 4 ); | 267 | vbox-> setSpacing ( 4 ); |
269 | grid-> addLayout ( vbox, 1, 0 ); | 268 | grid-> addLayout ( vbox, 1, 0 ); |
270 | 269 | ||
271 | upButton = new QPushButton ( this ); | 270 | upButton = new QPushButton ( this ); |
272 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 271 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
273 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | 272 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); |
274 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 273 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
275 | 274 | ||
276 | vbox-> addWidget ( upButton ); | 275 | vbox-> addWidget ( upButton ); |
277 | 276 | ||
278 | downButton = new QPushButton ( this ); | 277 | downButton = new QPushButton ( this ); |
279 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 278 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
280 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | 279 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); |
281 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 280 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
282 | 281 | ||
283 | vbox-> addWidget ( downButton ); | 282 | vbox-> addWidget ( downButton ); |
284 | 283 | ||
285 | volSlider = new QSlider ( this ); | 284 | volSlider = new QSlider ( this ); |
286 | volSlider-> setRange ( 0, 100 ); | 285 | volSlider-> setRange ( 0, 100 ); |
287 | volSlider-> setTickmarks ( QSlider::Both ); | 286 | volSlider-> setTickmarks ( QSlider::Both ); |
288 | volSlider-> setTickInterval ( 20 ); | 287 | volSlider-> setTickInterval ( 20 ); |
289 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 288 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
290 | 289 | ||
291 | l = new QLabel ( this ); | 290 | l = new QLabel ( this ); |
292 | l-> setPixmap ( QPixmap ( vol_xpm )); | 291 | l-> setPixmap ( QPixmap ( vol_xpm )); |
293 | 292 | ||
294 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 293 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
295 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 294 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
296 | 295 | ||
297 | volLed = new OLedBox ( green, this ); | 296 | volLed = new OLedBox ( green, this ); |
298 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 297 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
299 | volLed-> setFixedSize ( 16, 16 ); | 298 | volLed-> setFixedSize ( 16, 16 ); |
300 | 299 | ||
301 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 300 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
302 | 301 | ||
303 | QVBox *basstrebleBox = new QVBox( this ); | 302 | QVBox *basstrebleBox = new QVBox( this ); |
304 | 303 | ||
305 | trebleSlider = new QSlider ( basstrebleBox ); | 304 | trebleSlider = new QSlider ( basstrebleBox ); |
306 | trebleSlider-> setRange ( 0, 100 ); | 305 | trebleSlider-> setRange ( 0, 100 ); |
307 | trebleSlider-> setTickmarks ( QSlider::Both ); | 306 | trebleSlider-> setTickmarks ( QSlider::Both ); |
308 | trebleSlider-> setTickInterval ( 20 ); | 307 | trebleSlider-> setTickInterval ( 20 ); |
309 | trebleSlider->setMaximumHeight( 40 ); | 308 | trebleSlider->setMaximumHeight( 40 ); |
310 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); | 309 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); |
311 | 310 | ||
312 | bassSlider = new QSlider ( basstrebleBox ); | 311 | bassSlider = new QSlider ( basstrebleBox ); |
313 | bassSlider-> setRange ( 0, 100 ); | 312 | bassSlider-> setRange ( 0, 100 ); |
314 | bassSlider-> setTickmarks ( QSlider::Both ); | 313 | bassSlider-> setTickmarks ( QSlider::Both ); |
315 | bassSlider-> setTickInterval ( 20 ); | 314 | bassSlider-> setTickInterval ( 20 ); |
316 | bassSlider->setMaximumHeight( 40 ); | 315 | bassSlider->setMaximumHeight( 40 ); |
317 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); | 316 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); |
318 | 317 | ||
319 | QLabel *bassLabel = new QLabel ( this ); | 318 | QLabel *bassLabel = new QLabel ( this ); |
320 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); | 319 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); |
321 | 320 | ||
322 | QLabel *trebleLabel = new QLabel( this ); | 321 | QLabel *trebleLabel = new QLabel( this ); |
323 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); | 322 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); |
324 | 323 | ||
325 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); | 324 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); |
326 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); | 325 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); |
327 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); | 326 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); |
328 | 327 | ||
329 | if ( !has_bass ) { | 328 | if ( !has_bass ) { |
330 | bassSlider->hide(); | 329 | bassSlider->hide(); |
331 | bassLabel->hide(); | 330 | bassLabel->hide(); |
332 | } | 331 | } |
333 | 332 | ||
334 | if ( !has_treble ) { | 333 | if ( !has_treble ) { |
335 | trebleSlider->hide(); | 334 | trebleSlider->hide(); |
336 | trebleLabel->hide(); | 335 | trebleLabel->hide(); |
337 | } | 336 | } |
338 | 337 | ||
339 | micSlider = new QSlider ( this ); | 338 | micSlider = new QSlider ( this ); |
340 | micSlider-> setRange ( 0, 100 ); | 339 | micSlider-> setRange ( 0, 100 ); |
341 | micSlider-> setTickmarks ( QSlider::Both ); | 340 | micSlider-> setTickmarks ( QSlider::Both ); |
342 | micSlider-> setTickInterval ( 20 ); | 341 | micSlider-> setTickInterval ( 20 ); |
343 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 342 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
344 | 343 | ||
345 | l = new QLabel ( this ); | 344 | l = new QLabel ( this ); |
346 | l-> setPixmap ( QPixmap ( mic_xpm )); | 345 | l-> setPixmap ( QPixmap ( mic_xpm )); |
347 | 346 | ||
348 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 347 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
349 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 348 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
350 | 349 | ||
351 | micLed = new OLedBox ( red, this ); | 350 | micLed = new OLedBox ( red, this ); |
352 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 351 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
353 | micLed-> setFixedSize ( 16, 16 ); | 352 | micLed-> setFixedSize ( 16, 16 ); |
354 | 353 | ||
355 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 354 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
356 | 355 | ||
357 | alarmSlider = new QSlider ( this ); | 356 | alarmSlider = new QSlider ( this ); |
358 | alarmSlider-> setRange ( 0, 100 ); | 357 | alarmSlider-> setRange ( 0, 100 ); |
359 | alarmSlider-> setTickmarks ( QSlider::Both ); | 358 | alarmSlider-> setTickmarks ( QSlider::Both ); |
360 | alarmSlider-> setTickInterval ( 20 ); | 359 | alarmSlider-> setTickInterval ( 20 ); |
361 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 360 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
362 | 361 | ||
363 | QLabel *alarmLabel = new QLabel ( this ); | 362 | QLabel *alarmLabel = new QLabel ( this ); |
364 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 363 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
365 | 364 | ||
366 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 365 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
367 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 366 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
368 | 367 | ||
369 | alarmLed = new OLedBox ( yellow, this ); | 368 | alarmLed = new OLedBox ( yellow, this ); |
370 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 369 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
371 | alarmLed-> setFixedSize ( 16, 16 ); | 370 | alarmLed-> setFixedSize ( 16, 16 ); |
372 | 371 | ||
373 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 372 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
374 | 373 | ||
375 | if ( !has_wav_alarm ) { | 374 | if ( !has_wav_alarm ) { |
376 | alarmSlider-> hide ( ); | 375 | alarmSlider-> hide ( ); |
377 | alarmLabel-> hide ( ); | 376 | alarmLabel-> hide ( ); |
378 | alarmLed-> hide ( ); | 377 | alarmLed-> hide ( ); |
379 | } | 378 | } |
380 | 379 | ||
381 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); | 380 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
382 | 381 | ||
383 | vbox = new QVBoxLayout ( ); | 382 | vbox = new QVBoxLayout ( ); |
384 | vbox-> setSpacing ( 4 ); | 383 | vbox-> setSpacing ( 4 ); |
385 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); | 384 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
386 | 385 | ||
387 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 386 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
388 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 387 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
389 | 388 | ||
390 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 389 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
391 | 390 | ||
392 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 391 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
393 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 392 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
394 | 393 | ||
395 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 394 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
396 | 395 | ||
397 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 396 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
398 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 397 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
399 | 398 | ||
400 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 399 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
401 | 400 | ||
402 | if ( has_wav_alarm ) { | 401 | if ( has_wav_alarm ) { |
403 | alarmBox-> hide ( ); | 402 | alarmBox-> hide ( ); |
404 | } | 403 | } |
405 | 404 | ||
406 | vbox-> addStretch ( 100 ); | 405 | vbox-> addStretch ( 100 ); |
407 | 406 | ||
408 | setFixedSize ( sizeHint ( )); | 407 | setFixedSize ( sizeHint ( )); |
409 | setFocusPolicy ( QWidget::NoFocus ); | 408 | setFocusPolicy ( QWidget::NoFocus ); |
410 | 409 | ||
411 | rateTimer = new QTimer( this ); | 410 | rateTimer = new QTimer( this ); |
412 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); | 411 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); |
413 | 412 | ||
414 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 413 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
415 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 414 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
416 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 415 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
417 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 416 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
418 | 417 | ||
419 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); | 418 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); |
420 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); | 419 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); |
421 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); | 420 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); |
422 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); | 421 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); |
423 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); | 422 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); |
424 | 423 | ||
425 | 424 | ||
426 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); | 425 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); |
427 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); | 426 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); |
428 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 427 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
429 | 428 | ||
430 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 429 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
431 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); | 430 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); |
432 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); | 431 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); |
433 | 432 | ||
434 | // initialize variables | 433 | // initialize variables |
435 | 434 | ||
436 | readConfig ( true ); | 435 | readConfig ( true ); |
437 | 436 | ||
438 | // initialize the config file, in case some entries are missing | 437 | // initialize the config file, in case some entries are missing |
439 | 438 | ||
440 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 439 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
441 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | 440 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); |
442 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | 441 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); |
443 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 442 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
444 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 443 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
445 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 444 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
446 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 445 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
447 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 446 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
448 | 447 | ||
449 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 448 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
450 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 449 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
451 | } | 450 | } |
452 | 451 | ||
453 | bool VolumeControl::volMuted ( ) const | 452 | bool VolumeControl::volMuted ( ) const |
454 | { | 453 | { |
455 | return m_vol_muted; | 454 | return m_vol_muted; |
456 | } | 455 | } |
457 | 456 | ||
458 | int VolumeControl::volPercent ( ) const | 457 | int VolumeControl::volPercent ( ) const |
459 | { | 458 | { |
460 | return m_vol_percent; | 459 | return m_vol_percent; |
461 | } | 460 | } |
462 | 461 | ||
463 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 462 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
464 | { | 463 | { |
465 | switch ( e-> key ( )) { | 464 | switch ( e-> key ( )) { |
466 | case Key_Up: | 465 | case Key_Up: |
467 | volSlider-> subtractStep ( ); | 466 | volSlider-> subtractStep ( ); |
468 | break; | 467 | break; |
469 | case Key_Down: | 468 | case Key_Down: |
470 | volSlider-> addStep ( ); | 469 | volSlider-> addStep ( ); |
471 | break; | 470 | break; |
472 | case Key_Space: | 471 | case Key_Space: |
473 | volLed-> toggle ( ); | 472 | volLed-> toggle ( ); |
474 | break; | 473 | break; |
475 | case Key_Escape: | 474 | case Key_Escape: |
476 | hide ( ); | 475 | hide ( ); |
477 | break; | 476 | break; |
478 | } | 477 | } |
479 | } | 478 | } |
480 | 479 | ||
481 | void VolumeControl::buttonChanged ( ) | 480 | void VolumeControl::buttonChanged ( ) |
482 | { | 481 | { |
483 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 482 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
484 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 483 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
485 | // called at all when a button is pressed for a time | 484 | // called at all when a button is pressed for a time |
486 | // shorter than RATE_TIMER_INTERVAL. | 485 | // shorter than RATE_TIMER_INTERVAL. |
487 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 486 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
488 | } | 487 | } |
489 | else | 488 | else |
490 | rateTimer-> stop ( ); | 489 | rateTimer-> stop ( ); |
491 | } | 490 | } |
492 | 491 | ||
493 | void VolumeControl::rateTimerDone ( ) | 492 | void VolumeControl::rateTimerDone ( ) |
494 | { | 493 | { |
495 | if ( upButton-> isDown ( )) | 494 | if ( upButton-> isDown ( )) |
496 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 495 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
497 | else // if ( downButton-> isDown ( )) | 496 | else // if ( downButton-> isDown ( )) |
498 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 497 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
499 | } | 498 | } |
500 | 499 | ||
501 | void VolumeControl::show ( bool /*showMic*/ ) | 500 | void VolumeControl::show ( bool /*showMic*/ ) |
502 | { | 501 | { |
503 | readConfig ( ); | 502 | readConfig ( ); |
504 | 503 | ||
505 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 504 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
506 | 505 | ||
507 | int w = sizeHint ( ). width ( ); | 506 | int w = sizeHint ( ). width ( ); |
508 | int x = curPos.x ( ) - ( w / 2 ); | 507 | int x = curPos.x ( ) - ( w / 2 ); |
509 | 508 | ||
510 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 509 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
511 | x = QPEApplication::desktop ( )-> width ( ) - w; | 510 | x = QPEApplication::desktop ( )-> width ( ) - w; |
512 | 511 | ||
513 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 512 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |