-rw-r--r-- | core/applets/volumeapplet/opie-volumeapplet.control | 2 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 13 |
2 files changed, 5 insertions, 10 deletions
diff --git a/core/applets/volumeapplet/opie-volumeapplet.control b/core/applets/volumeapplet/opie-volumeapplet.control index 3056520..731692a 100644 --- a/core/applets/volumeapplet/opie-volumeapplet.control +++ b/core/applets/volumeapplet/opie-volumeapplet.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-volumeapplet | 1 | Package: opie-volumeapplet |
2 | Files: plugins/applets/libvolumeapplet.so* | 2 | Files: plugins/applets/libvolumeapplet.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applets | 4 | Section: opie/applets |
5 | Maintainer: L.J. Potter <lpotter@trolltech.com> | 5 | Maintainer: L.J. Potter <lpotter@trolltech.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal, libopiecore2, libopieui2 |
8 | Description: Volume applet | 8 | Description: Volume applet |
9 | Volume applet for the Opie environment taskbar. | 9 | Volume applet for the Opie environment taskbar. |
10 | Version: $QPE_VERSION$EXTRAVERSION | 10 | Version: $QPE_VERSION$EXTRAVERSION |
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 7f0aca5..7d67311 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,788 +1,783 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "volume.h" | 21 | #include "volume.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* 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 <opie2/oresource.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 | upButton-> setPixmap ( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); |
276 | pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
277 | upButton-> setPixmap ( pic ); | ||
278 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 276 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
279 | 277 | ||
280 | vbox-> addWidget ( upButton ); | 278 | vbox-> addWidget ( upButton ); |
281 | 279 | ||
282 | downButton = new QPushButton ( this ); | 280 | downButton = new QPushButton ( this ); |
283 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 281 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
284 | pic.convertFromImage( Resource::loadImage( "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 282 | downButton-> setPixmap ( Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ) ); |
285 | downButton-> setPixmap ( pic ); | ||
286 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 283 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
287 | 284 | ||
288 | vbox-> addWidget ( downButton ); | 285 | vbox-> addWidget ( downButton ); |
289 | 286 | ||
290 | volSlider = new QSlider ( this ); | 287 | volSlider = new QSlider ( this ); |
291 | volSlider-> setRange ( 0, 100 ); | 288 | volSlider-> setRange ( 0, 100 ); |
292 | volSlider-> setTickmarks ( QSlider::Both ); | 289 | volSlider-> setTickmarks ( QSlider::Both ); |
293 | volSlider-> setTickInterval ( 20 ); | 290 | volSlider-> setTickInterval ( 20 ); |
294 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 291 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
295 | 292 | ||
296 | l = new QLabel ( this ); | 293 | l = new QLabel ( this ); |
297 | l-> setPixmap ( QPixmap ( vol_xpm )); | 294 | l-> setPixmap ( QPixmap ( vol_xpm )); |
298 | 295 | ||
299 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 296 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
300 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 297 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
301 | 298 | ||
302 | volLed = new OLedBox ( green, this ); | 299 | volLed = new OLedBox ( green, this ); |
303 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 300 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
304 | volLed-> setFixedSize ( 16, 16 ); | 301 | volLed-> setFixedSize ( 16, 16 ); |
305 | 302 | ||
306 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 303 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
307 | 304 | ||
308 | QVBox *basstrebleBox = new QVBox( this ); | 305 | QVBox *basstrebleBox = new QVBox( this ); |
309 | 306 | ||
310 | trebleSlider = new QSlider ( basstrebleBox ); | 307 | trebleSlider = new QSlider ( basstrebleBox ); |
311 | trebleSlider-> setRange ( 0, 100 ); | 308 | trebleSlider-> setRange ( 0, 100 ); |
312 | trebleSlider-> setTickmarks ( QSlider::Both ); | 309 | trebleSlider-> setTickmarks ( QSlider::Both ); |
313 | trebleSlider-> setTickInterval ( 20 ); | 310 | trebleSlider-> setTickInterval ( 20 ); |
314 | trebleSlider->setMaximumHeight( 40 ); | 311 | trebleSlider->setMaximumHeight( 40 ); |
315 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); | 312 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); |
316 | 313 | ||
317 | bassSlider = new QSlider ( basstrebleBox ); | 314 | bassSlider = new QSlider ( basstrebleBox ); |
318 | bassSlider-> setRange ( 0, 100 ); | 315 | bassSlider-> setRange ( 0, 100 ); |
319 | bassSlider-> setTickmarks ( QSlider::Both ); | 316 | bassSlider-> setTickmarks ( QSlider::Both ); |
320 | bassSlider-> setTickInterval ( 20 ); | 317 | bassSlider-> setTickInterval ( 20 ); |
321 | bassSlider->setMaximumHeight( 40 ); | 318 | bassSlider->setMaximumHeight( 40 ); |
322 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); | 319 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); |
323 | 320 | ||
324 | QLabel *bassLabel = new QLabel ( this ); | 321 | QLabel *bassLabel = new QLabel ( this ); |
325 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); | 322 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); |
326 | 323 | ||
327 | QLabel *trebleLabel = new QLabel( this ); | 324 | QLabel *trebleLabel = new QLabel( this ); |
328 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); | 325 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); |
329 | 326 | ||
330 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); | 327 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); |
331 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); | 328 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); |
332 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); | 329 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); |
333 | 330 | ||
334 | if ( !has_bass ) { | 331 | if ( !has_bass ) { |
335 | bassSlider->hide(); | 332 | bassSlider->hide(); |
336 | bassLabel->hide(); | 333 | bassLabel->hide(); |
337 | } | 334 | } |
338 | 335 | ||
339 | if ( !has_treble ) { | 336 | if ( !has_treble ) { |
340 | trebleSlider->hide(); | 337 | trebleSlider->hide(); |
341 | trebleLabel->hide(); | 338 | trebleLabel->hide(); |
342 | } | 339 | } |
343 | 340 | ||
344 | micSlider = new QSlider ( this ); | 341 | micSlider = new QSlider ( this ); |
345 | micSlider-> setRange ( 0, 100 ); | 342 | micSlider-> setRange ( 0, 100 ); |
346 | micSlider-> setTickmarks ( QSlider::Both ); | 343 | micSlider-> setTickmarks ( QSlider::Both ); |
347 | micSlider-> setTickInterval ( 20 ); | 344 | micSlider-> setTickInterval ( 20 ); |
348 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 345 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
349 | 346 | ||
350 | l = new QLabel ( this ); | 347 | l = new QLabel ( this ); |
351 | l-> setPixmap ( QPixmap ( mic_xpm )); | 348 | l-> setPixmap ( QPixmap ( mic_xpm )); |
352 | 349 | ||
353 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 350 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
354 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 351 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
355 | 352 | ||
356 | micLed = new OLedBox ( red, this ); | 353 | micLed = new OLedBox ( red, this ); |
357 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 354 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
358 | micLed-> setFixedSize ( 16, 16 ); | 355 | micLed-> setFixedSize ( 16, 16 ); |
359 | 356 | ||
360 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 357 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
361 | 358 | ||
362 | alarmSlider = new QSlider ( this ); | 359 | alarmSlider = new QSlider ( this ); |
363 | alarmSlider-> setRange ( 0, 100 ); | 360 | alarmSlider-> setRange ( 0, 100 ); |
364 | alarmSlider-> setTickmarks ( QSlider::Both ); | 361 | alarmSlider-> setTickmarks ( QSlider::Both ); |
365 | alarmSlider-> setTickInterval ( 20 ); | 362 | alarmSlider-> setTickInterval ( 20 ); |
366 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 363 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
367 | 364 | ||
368 | QLabel *alarmLabel = new QLabel ( this ); | 365 | QLabel *alarmLabel = new QLabel ( this ); |
369 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 366 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
370 | 367 | ||
371 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 368 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
372 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 369 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
373 | 370 | ||
374 | alarmLed = new OLedBox ( yellow, this ); | 371 | alarmLed = new OLedBox ( yellow, this ); |
375 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 372 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
376 | alarmLed-> setFixedSize ( 16, 16 ); | 373 | alarmLed-> setFixedSize ( 16, 16 ); |
377 | 374 | ||
378 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 375 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
379 | 376 | ||
380 | if ( !has_wav_alarm ) { | 377 | if ( !has_wav_alarm ) { |
381 | alarmSlider-> hide ( ); | 378 | alarmSlider-> hide ( ); |
382 | alarmLabel-> hide ( ); | 379 | alarmLabel-> hide ( ); |
383 | alarmLed-> hide ( ); | 380 | alarmLed-> hide ( ); |
384 | } | 381 | } |
385 | 382 | ||
386 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); | 383 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
387 | 384 | ||
388 | vbox = new QVBoxLayout ( ); | 385 | vbox = new QVBoxLayout ( ); |
389 | vbox-> setSpacing ( 4 ); | 386 | vbox-> setSpacing ( 4 ); |
390 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); | 387 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
391 | 388 | ||
392 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 389 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
393 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 390 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
394 | 391 | ||
395 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 392 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
396 | 393 | ||
397 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 394 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
398 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 395 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
399 | 396 | ||
400 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 397 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
401 | 398 | ||
402 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 399 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
403 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 400 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
404 | 401 | ||
405 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 402 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
406 | 403 | ||
407 | if ( has_wav_alarm ) { | 404 | if ( has_wav_alarm ) { |
408 | alarmBox-> hide ( ); | 405 | alarmBox-> hide ( ); |
409 | } | 406 | } |
410 | 407 | ||
411 | vbox-> addStretch ( 100 ); | 408 | vbox-> addStretch ( 100 ); |
412 | 409 | ||
413 | setFixedSize ( sizeHint ( )); | 410 | setFixedSize ( sizeHint ( )); |
414 | setFocusPolicy ( QWidget::NoFocus ); | 411 | setFocusPolicy ( QWidget::NoFocus ); |
415 | 412 | ||
416 | rateTimer = new QTimer( this ); | 413 | rateTimer = new QTimer( this ); |
417 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); | 414 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); |
418 | 415 | ||
419 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 416 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
420 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 417 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
421 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 418 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
422 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 419 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
423 | 420 | ||
424 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); | 421 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); |
425 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); | 422 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); |
426 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); | 423 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); |
427 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); | 424 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); |
428 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); | 425 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); |
429 | 426 | ||
430 | 427 | ||
431 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); | 428 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); |
432 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); | 429 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); |
433 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 430 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
434 | 431 | ||
435 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 432 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
436 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); | 433 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); |
437 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); | 434 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); |
438 | 435 | ||
439 | // initialize variables | 436 | // initialize variables |
440 | 437 | ||
441 | readConfig ( true ); | 438 | readConfig ( true ); |
442 | 439 | ||
443 | // initialize the config file, in case some entries are missing | 440 | // initialize the config file, in case some entries are missing |
444 | 441 | ||
445 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 442 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
446 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | 443 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); |
447 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | 444 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); |
448 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 445 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
449 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 446 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
450 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 447 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
451 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 448 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
452 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 449 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
453 | 450 | ||
454 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 451 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
455 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 452 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
456 | } | 453 | } |
457 | 454 | ||
458 | bool VolumeControl::volMuted ( ) const | 455 | bool VolumeControl::volMuted ( ) const |
459 | { | 456 | { |
460 | return m_vol_muted; | 457 | return m_vol_muted; |
461 | } | 458 | } |
462 | 459 | ||
463 | int VolumeControl::volPercent ( ) const | 460 | int VolumeControl::volPercent ( ) const |
464 | { | 461 | { |
465 | return m_vol_percent; | 462 | return m_vol_percent; |
466 | } | 463 | } |
467 | 464 | ||
468 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 465 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
469 | { | 466 | { |
470 | switch ( e-> key ( )) { | 467 | switch ( e-> key ( )) { |
471 | case Key_Up: | 468 | case Key_Up: |
472 | volSlider-> subtractStep ( ); | 469 | volSlider-> subtractStep ( ); |
473 | break; | 470 | break; |
474 | case Key_Down: | 471 | case Key_Down: |
475 | volSlider-> addStep ( ); | 472 | volSlider-> addStep ( ); |
476 | break; | 473 | break; |
477 | case Key_Space: | 474 | case Key_Space: |
478 | volLed-> toggle ( ); | 475 | volLed-> toggle ( ); |
479 | break; | 476 | break; |
480 | case Key_Escape: | 477 | case Key_Escape: |
481 | hide ( ); | 478 | hide ( ); |
482 | break; | 479 | break; |
483 | } | 480 | } |
484 | } | 481 | } |
485 | 482 | ||
486 | void VolumeControl::buttonChanged ( ) | 483 | void VolumeControl::buttonChanged ( ) |
487 | { | 484 | { |
488 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 485 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
489 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 486 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
490 | // called at all when a button is pressed for a time | 487 | // called at all when a button is pressed for a time |
491 | // shorter than RATE_TIMER_INTERVAL. | 488 | // shorter than RATE_TIMER_INTERVAL. |
492 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 489 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
493 | } | 490 | } |
494 | else | 491 | else |
495 | rateTimer-> stop ( ); | 492 | rateTimer-> stop ( ); |
496 | } | 493 | } |
497 | 494 | ||
498 | void VolumeControl::rateTimerDone ( ) | 495 | void VolumeControl::rateTimerDone ( ) |
499 | { | 496 | { |
500 | if ( upButton-> isDown ( )) | 497 | if ( upButton-> isDown ( )) |
501 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 498 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
502 | else // if ( downButton-> isDown ( )) | 499 | else // if ( downButton-> isDown ( )) |
503 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 500 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
504 | } | 501 | } |
505 | 502 | ||
506 | void VolumeControl::show ( bool /*showMic*/ ) | 503 | void VolumeControl::show ( bool /*showMic*/ ) |
507 | { | 504 | { |
508 | readConfig ( ); | 505 | readConfig ( ); |
509 | 506 | ||
510 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 507 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
511 | 508 | ||
512 | int w = sizeHint ( ). width ( ); | 509 | int w = sizeHint ( ). width ( ); |
513 | int x = curPos.x ( ) - ( w / 2 ); | 510 | int x = curPos.x ( ) - ( w / 2 ); |
514 | 511 | ||
515 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 512 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
516 | x = QPEApplication::desktop ( )-> width ( ) - w; | 513 | x = QPEApplication::desktop ( )-> width ( ) - w; |
517 | 514 | ||
518 | move ( QMAX(x,0), curPos. y ( ) - sizeHint ( ). height ( )); | 515 | move ( QMAX(x,0), curPos. y ( ) - sizeHint ( ). height ( )); |
519 | QFrame::show ( ); | 516 | QFrame::show ( ); |
520 | 517 | ||
521 | } | 518 | } |
522 | 519 | ||
523 | void VolumeControl::readConfig ( bool force ) | 520 | void VolumeControl::readConfig ( bool force ) |
524 | { | 521 | { |
525 | Config cfg ( "qpe" ); | 522 | Config cfg ( "qpe" ); |
526 | cfg. setGroup ( "Volume" ); | 523 | cfg. setGroup ( "Volume" ); |
527 | 524 | ||
528 | int old_vp = m_vol_percent; | 525 | int old_vp = m_vol_percent; |
529 | int old_mp = m_mic_percent; | 526 | int old_mp = m_mic_percent; |
530 | int old_bass = m_bass_percent; | 527 | int old_bass = m_bass_percent; |
531 | int old_treble = m_treble_percent; | 528 | int old_treble = m_treble_percent; |
532 | bool old_vm = m_vol_muted; | 529 | bool old_vm = m_vol_muted; |
533 | bool old_mm = m_mic_muted; | 530 | bool old_mm = m_mic_muted; |
534 | bool old_sk = m_snd_key; | 531 | bool old_sk = m_snd_key; |
535 | bool old_st = m_snd_touch; | 532 | bool old_st = m_snd_touch; |
536 | bool old_sa = m_snd_alarm; | 533 | bool old_sa = m_snd_alarm; |
537 | int old_ap = m_alarm_percent; | 534 | int old_ap = m_alarm_percent; |
538 | 535 | ||
539 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 536 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
540 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 537 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
541 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); | 538 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); |
542 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); | 539 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); |
543 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 540 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
544 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 541 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
545 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 542 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
546 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 543 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
547 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 544 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
548 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 545 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
549 | 546 | ||
550 | if ( force || ( m_vol_percent != old_vp )) | 547 | if ( force || ( m_vol_percent != old_vp )) |
551 | volSlider-> setValue ( 100 - m_vol_percent ); | 548 | volSlider-> setValue ( 100 - m_vol_percent ); |
552 | if ( force || ( m_mic_percent != old_mp )) | 549 | if ( force || ( m_mic_percent != old_mp )) |
553 | micSlider-> setValue ( 100 - m_mic_percent ); | 550 | micSlider-> setValue ( 100 - m_mic_percent ); |
554 | if ( force || ( m_alarm_percent != old_ap )) | 551 | if ( force || ( m_alarm_percent != old_ap )) |
555 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 552 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
556 | if ( force || ( m_bass_percent != old_bass )) | 553 | if ( force || ( m_bass_percent != old_bass )) |
557 | bassSlider-> setValue ( 100 - m_bass_percent ); | 554 | bassSlider-> setValue ( 100 - m_bass_percent ); |
558 | if ( force || ( m_treble_percent != old_treble )) | 555 | if ( force || ( m_treble_percent != old_treble )) |
559 | trebleSlider-> setValue ( 100 - m_treble_percent ); | 556 | trebleSlider-> setValue ( 100 - m_treble_percent ); |
560 | 557 | ||
561 | 558 | ||
562 | if ( force || ( m_vol_muted != old_vm )) | 559 | if ( force || ( m_vol_muted != old_vm )) |
563 | volLed-> setOn ( !m_vol_muted ); | 560 | volLed-> setOn ( !m_vol_muted ); |
564 | if ( force || ( m_mic_muted != old_mm )) | 561 | if ( force || ( m_mic_muted != old_mm )) |
565 | micLed-> setOn ( !m_mic_muted ); | 562 | micLed-> setOn ( !m_mic_muted ); |
566 | if ( force || ( m_snd_alarm != old_sa )) | 563 | if ( force || ( m_snd_alarm != old_sa )) |
567 | alarmLed-> setOn ( m_snd_alarm ); | 564 | alarmLed-> setOn ( m_snd_alarm ); |
568 | 565 | ||
569 | if ( force || ( m_snd_key != old_sk )) | 566 | if ( force || ( m_snd_key != old_sk )) |
570 | keyBox-> setChecked ( m_snd_key ); | 567 | keyBox-> setChecked ( m_snd_key ); |
571 | if ( force || ( m_snd_touch != old_st )) | 568 | if ( force || ( m_snd_touch != old_st )) |
572 | tapBox-> setChecked ( m_snd_touch ); | 569 | tapBox-> setChecked ( m_snd_touch ); |
573 | if ( force || ( m_snd_alarm != old_sa )) | 570 | if ( force || ( m_snd_alarm != old_sa )) |
574 | alarmBox-> setChecked ( m_snd_alarm ); | 571 | alarmBox-> setChecked ( m_snd_alarm ); |
575 | } | 572 | } |
576 | 573 | ||
577 | 574 | ||
578 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) | 575 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) |
579 | { | 576 | { |
580 | int prevVol = m_vol_percent; | 577 | int prevVol = m_vol_percent; |
581 | bool prevMute = m_vol_muted; | 578 | bool prevMute = m_vol_muted; |
582 | 579 | ||
583 | readConfig ( ); | 580 | readConfig ( ); |
584 | 581 | ||
585 | // Handle case where muting it toggled | 582 | // Handle case where muting it toggled |
586 | if ( m_vol_muted != prevMute ) | 583 | if ( m_vol_muted != prevMute ) |
587 | m_icon-> redraw ( true ); | 584 | m_icon-> redraw ( true ); |
588 | else if ( prevVol != m_vol_percent ) // Avoid over repainting | 585 | else if ( prevVol != m_vol_percent ) // Avoid over repainting |
589 | m_icon-> redraw ( false ); | 586 | m_icon-> redraw ( false ); |
590 | } | 587 | } |
591 | 588 | ||
592 | void VolumeControl::micChanged ( bool nowMuted ) | 589 | void VolumeControl::micChanged ( bool nowMuted ) |
593 | { | 590 | { |
594 | if ( !nowMuted ) | 591 | if ( !nowMuted ) |
595 | readConfig ( ); | 592 | readConfig ( ); |
596 | m_mic_muted = nowMuted; | 593 | m_mic_muted = nowMuted; |
597 | } | 594 | } |
598 | 595 | ||
599 | void VolumeControl::screenTapToggled ( bool b ) | 596 | void VolumeControl::screenTapToggled ( bool b ) |
600 | { | 597 | { |
601 | m_snd_touch = b; | 598 | m_snd_touch = b; |
602 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 599 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
603 | } | 600 | } |
604 | 601 | ||
605 | void VolumeControl::keyClickToggled ( bool b ) | 602 | void VolumeControl::keyClickToggled ( bool b ) |
606 | { | 603 | { |
607 | m_snd_key = b; | 604 | m_snd_key = b; |
608 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 605 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
609 | } | 606 | } |
610 | 607 | ||
611 | void VolumeControl::alarmSoundToggled ( bool b ) | 608 | void VolumeControl::alarmSoundToggled ( bool b ) |
612 | { | 609 | { |
613 | m_snd_alarm = b; | 610 | m_snd_alarm = b; |
614 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 611 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
615 | } | 612 | } |
616 | 613 | ||
617 | void VolumeControl::volMuteToggled ( bool b ) | 614 | void VolumeControl::volMuteToggled ( bool b ) |
618 | { | 615 | { |
619 | m_vol_muted = !b; | 616 | m_vol_muted = !b; |
620 | 617 | ||
621 | m_icon-> redraw ( true ); | 618 | m_icon-> redraw ( true ); |
622 | 619 | ||
623 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 620 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
624 | } | 621 | } |
625 | 622 | ||
626 | void VolumeControl::micMuteToggled ( bool b ) | 623 | void VolumeControl::micMuteToggled ( bool b ) |
627 | { | 624 | { |
628 | m_mic_muted = !b; | 625 | m_mic_muted = !b; |
629 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 626 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
630 | } | 627 | } |
631 | 628 | ||
632 | 629 | ||
633 | void VolumeControl::volMoved ( int percent ) | 630 | void VolumeControl::volMoved ( int percent ) |
634 | { | 631 | { |
635 | m_vol_percent = 100 - percent; | 632 | m_vol_percent = 100 - percent; |
636 | 633 | ||
637 | // clamp volume percent to be between 0 and 100 | 634 | // 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 ); | 635 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
639 | // repaint just the little volume rectangle | 636 | // repaint just the little volume rectangle |
640 | m_icon-> redraw ( false ); | 637 | m_icon-> redraw ( false ); |
641 | 638 | ||
642 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 639 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
643 | } | 640 | } |
644 | 641 | ||
645 | void VolumeControl::micMoved ( int percent ) | 642 | void VolumeControl::micMoved ( int percent ) |
646 | { | 643 | { |
647 | m_mic_percent = 100 - percent; | 644 | m_mic_percent = 100 - percent; |
648 | 645 | ||
649 | // clamp volume percent to be between 0 and 100 | 646 | // 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 ); | 647 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
651 | 648 | ||
652 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 649 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
653 | } | 650 | } |
654 | 651 | ||
655 | void VolumeControl::alarmMoved ( int percent ) | 652 | void VolumeControl::alarmMoved ( int percent ) |
656 | { | 653 | { |
657 | m_alarm_percent = 100 - percent; | 654 | m_alarm_percent = 100 - percent; |
658 | 655 | ||
659 | // clamp volume percent to be between 0 and 100 | 656 | // 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 ); | 657 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
661 | 658 | ||
662 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 659 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
663 | } | 660 | } |
664 | 661 | ||
665 | 662 | ||
666 | void VolumeControl::bassMoved ( int percent ) | 663 | void VolumeControl::bassMoved ( int percent ) |
667 | { | 664 | { |
668 | m_bass_percent = 100 - percent; | 665 | m_bass_percent = 100 - percent; |
669 | 666 | ||
670 | // clamp bass percent to be between 0 and 100 | 667 | // 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 ); | 668 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); |
672 | 669 | ||
673 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | 670 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); |
674 | } | 671 | } |
675 | 672 | ||
676 | 673 | ||
677 | 674 | ||
678 | void VolumeControl::trebleMoved ( int percent ) | 675 | void VolumeControl::trebleMoved ( int percent ) |
679 | { | 676 | { |
680 | m_treble_percent = 100 - percent; | 677 | m_treble_percent = 100 - percent; |
681 | 678 | ||
682 | // clamp treble percent to be between 0 and 100 | 679 | // 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 ); | 680 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); |
684 | 681 | ||
685 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | 682 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); |
686 | } | 683 | } |
687 | 684 | ||
688 | 685 | ||
689 | 686 | ||
690 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 687 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
691 | { | 688 | { |
692 | Config cfg ( "qpe" ); | 689 | Config cfg ( "qpe" ); |
693 | cfg. setGroup ( "Volume" ); | 690 | cfg. setGroup ( "Volume" ); |
694 | cfg. writeEntry ( entry, val ); | 691 | cfg. writeEntry ( entry, val ); |
695 | // cfg. write ( ); | 692 | // cfg. write ( ); |
696 | 693 | ||
697 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 694 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
698 | switch ( upd ) { | 695 | switch ( upd ) { |
699 | case UPD_Vol: { | 696 | case UPD_Vol: { |
700 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 697 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
701 | break; | 698 | break; |
702 | } | 699 | } |
703 | case UPD_Mic: { | 700 | case UPD_Mic: { |
704 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 701 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
705 | break; | 702 | break; |
706 | } | 703 | } |
707 | case UPD_Bass: { | 704 | case UPD_Bass: { |
708 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | 705 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; |
709 | break; | 706 | break; |
710 | } | 707 | } |
711 | case UPD_Treble: { | 708 | case UPD_Treble: { |
712 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | 709 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; |
713 | break; | 710 | break; |
714 | } | 711 | } |
715 | 712 | ||
716 | case UPD_None: | 713 | case UPD_None: |
717 | break; | 714 | break; |
718 | } | 715 | } |
719 | #endif | 716 | #endif |
720 | } | 717 | } |
721 | 718 | ||
722 | //=========================================================================== | 719 | //=========================================================================== |
723 | 720 | ||
724 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 721 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
725 | : QWidget( parent, name ) | 722 | : QWidget( parent, name ) |
726 | { | 723 | { |
727 | setFixedWidth ( AppLnk::smallIconSize() ); | 724 | setFixedWidth ( AppLnk::smallIconSize() ); |
728 | setFixedHeight ( AppLnk::smallIconSize()+4 ); | 725 | setFixedHeight ( AppLnk::smallIconSize()+4 ); |
729 | 726 | ||
730 | QPixmap pic; | 727 | m_pixmap = new QPixmap ( Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon ) ); |
731 | pic.convertFromImage( Resource::loadImage( "volume" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
732 | m_pixmap = new QPixmap ( pic ); | ||
733 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); | 728 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); |
734 | 729 | ||
735 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); | 730 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); |
736 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); | 731 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); |
737 | } | 732 | } |
738 | 733 | ||
739 | VolumeApplet::~VolumeApplet() | 734 | VolumeApplet::~VolumeApplet() |
740 | { | 735 | { |
741 | delete m_pixmap; | 736 | delete m_pixmap; |
742 | } | 737 | } |
743 | 738 | ||
744 | int VolumeApplet::position() | 739 | int VolumeApplet::position() |
745 | { | 740 | { |
746 | return 6; | 741 | return 6; |
747 | } | 742 | } |
748 | 743 | ||
749 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 744 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
750 | { | 745 | { |
751 | if ( m_dialog-> isVisible ( )) | 746 | if ( m_dialog-> isVisible ( )) |
752 | m_dialog-> hide ( ); | 747 | m_dialog-> hide ( ); |
753 | else | 748 | else |
754 | m_dialog-> show ( true ); | 749 | m_dialog-> show ( true ); |
755 | } | 750 | } |
756 | 751 | ||
757 | void VolumeApplet::redraw ( bool all ) | 752 | void VolumeApplet::redraw ( bool all ) |
758 | { | 753 | { |
759 | if ( all ) | 754 | if ( all ) |
760 | repaint ( true ); | 755 | repaint ( true ); |
761 | else | 756 | else |
762 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 757 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
763 | } | 758 | } |
764 | 759 | ||
765 | 760 | ||
766 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 761 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
767 | { | 762 | { |
768 | QPainter p ( this ); | 763 | QPainter p ( this ); |
769 | 764 | ||
770 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); | 765 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); |
771 | p. setPen ( darkGray ); | 766 | p. setPen ( darkGray ); |
772 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 767 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
773 | 768 | ||
774 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 769 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
775 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 770 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
776 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 771 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
777 | 772 | ||
778 | if ( m_dialog-> volMuted ( )) { | 773 | if ( m_dialog-> volMuted ( )) { |
779 | p. setPen ( red ); | 774 | p. setPen ( red ); |
780 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 775 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
781 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 776 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
782 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 777 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
783 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 778 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
784 | } | 779 | } |
785 | } | 780 | } |
786 | 781 | ||
787 | 782 | ||
788 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) | 783 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) |