-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 800 |
1 files changed, 402 insertions, 398 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index a000087..b047877 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,635 +1,639 @@ | |||
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 <stdio.h> | 21 | #include <stdio.h> |
22 | 22 | ||
23 | #include "volume.h" | 23 | #include "volume.h" |
24 | 24 | ||
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 28 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
29 | #include <qpe/qcopenvelope_qws.h> | 29 | #include <qpe/qcopenvelope_qws.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include <qpainter.h> | 32 | #include <qpainter.h> |
33 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
34 | #include <qslider.h> | 34 | #include <qslider.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qframe.h> | 36 | #include <qframe.h> |
37 | #include <qpixmap.h> | 37 | #include <qpixmap.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | 39 | ||
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | 43 | ||
44 | #include <opie/odevice.h> | 44 | #include <opie/odevice.h> |
45 | 45 | ||
46 | #include "oledbox.h" | 46 | #include "oledbox.h" |
47 | 47 | ||
48 | #define RATE_TIMER_INTERVAL 100 | 48 | #define RATE_TIMER_INTERVAL 100 |
49 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 49 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time |
50 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. | 50 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
51 | 51 | ||
52 | 52 | ||
53 | /* XPM */ | 53 | /* XPM */ |
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 | /* XPM */ | 124 | /* XPM */ |
125 | static const char * alarm_xpm[] = { | 125 | static const char * alarm_xpm[] = { |
126 | "20 20 33 1", | 126 | "20 20 33 1", |
127 | " c None", | 127 | " c None", |
128 | ".c #080602", | 128 | ". c #080602", |
129 | "+c #AAA602", | 129 | "+ c #AAA602", |
130 | "@c #252002", | 130 | "@ c #252002", |
131 | "#c #434202", | 131 | "# c #434202", |
132 | "$c #795602", | 132 | "$ c #795602", |
133 | "%c #C3C20D", | 133 | "% c #C3C20D", |
134 | "&c #DADAC2", | 134 | "& c #DADAC2", |
135 | "*c #826002", | 135 | "* c #826002", |
136 | "=c #740502", | 136 | "= c #740502", |
137 | "-c #D6D602", | 137 | "- c #D6D602", |
138 | ";c #322E02", | 138 | "; c #322E02", |
139 | ">c #826A02", | 139 | "> c #826A02", |
140 | ",c #F1F195", | 140 | ", c #F1F195", |
141 | "'c #959215", | 141 | "' c #959215", |
142 | ")c #423602", | 142 | ") c #423602", |
143 | "!c #4B0302", | 143 | "! c #4B0302", |
144 | "~c #844315", | 144 | "~ c #844315", |
145 | "{c #AAAA2A", | 145 | "{ c #AAAA2A", |
146 | "]c #E2DE42", | 146 | "] c #E2DE42", |
147 | "^c #BA7E04", | 147 | "^ c #BA7E04", |
148 | "/c #7F7502", | 148 | "/ c #7F7502", |
149 | "(c #828276", | 149 | "( c #828276", |
150 | "_c #FEFE4E", | 150 | "_ c #FEFE4E", |
151 | ":c #7D1902", | 151 | ": c #7D1902", |
152 | "<c #989656", | 152 | "< c #989656", |
153 | "[c #260B02", | 153 | "[ c #260B02", |
154 | "}c #F7F7D8", | 154 | "} c #F7F7D8", |
155 | "|c #DCDA5A", | 155 | "| c #DCDA5A", |
156 | "1c #823102", | 156 | "1 c #823102", |
157 | "2c #B1AC6B", | 157 | "2 c #B1AC6B", |
158 | "3c #F7F710", | 158 | "3 c #F7F710", |
159 | "4c #838204", | 159 | "4 c #838204", |
160 | " ", | 160 | " ", |
161 | " ", | 161 | " ", |
162 | " 4'4/ ", | 162 | " 4'4/ ", |
163 | " /-^= ", | 163 | " /-^= ", |
164 | " 42{4>4 ", | 164 | " 42{4>4 ", |
165 | " '2|+*$44 ", | 165 | " '2|+*$44 ", |
166 | " +2&3+$1*44 ", | 166 | " +2&3+$1*44 ", |
167 | " (%_}_+/$:>/4 ", | 167 | " (%_}_+/$:>/4 ", |
168 | " 4%_}3+#;>:*4 ", | 168 | " 4%_}3+#;>:*4 ", |
169 | " 4%_}&+#[1$/4 ", | 169 | " 4%_}&+#[1$/4 ", |
170 | " 4%_,2')[~~>4 ", | 170 | " 4%_,2')[~~>4 ", |
171 | " 4%33'4#@~1>4 ", | 171 | " 4%33'4#@~1>4 ", |
172 | " 4%3344#[:>/4 ", | 172 | " 4%3344#[:>/4 ", |
173 | " 42&_3'4#@>:*44 ", | 173 | " 42&_3'4#@>:*44 ", |
174 | " 42|}}3'4#[;$)$44 ", | 174 | " 42|}}3'4#[;$)$44 ", |
175 | "444{]]2^~~:!!#.@##/ ", | 175 | "444{]]2^~~:!!#.@##/ ", |
176 | "4444-%*:==!!=...../ ", | 176 | "4444-%*:==!!=...../ ", |
177 | " /:[.. ", | 177 | " /:[.. ", |
178 | " /@. ", | 178 | " /@. ", |
179 | " "}; | 179 | " "}; |
180 | 180 | ||
181 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 181 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
182 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 182 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
183 | { | 183 | { |
184 | m_icon = icon; | 184 | m_icon = icon; |
185 | 185 | ||
186 | bool has_wav_alarm = false; | 186 | bool has_wav_alarm = false; |
187 | 187 | ||
188 | switch ( ODevice::inst ( )-> model ( )) { | 188 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
189 | case OMODEL_iPAQ_H31xx: | 189 | case OMODEL_iPAQ_H31xx: |
190 | case OMODEL_iPAQ_H36xx: | 190 | case OMODEL_iPAQ_H36xx: |
191 | case OMODEL_iPAQ_H37xx: | 191 | case OMODEL_iPAQ_H37xx: |
192 | case OMODEL_iPAQ_H38xx: | 192 | case OMODEL_iPAQ_H38xx: |
193 | has_wav_alarm = true; | 193 | has_wav_alarm = true; |
194 | break; | 194 | break; |
195 | default: | 195 | case OMODEL_Zaurus_SL5000: |
196 | break; | 196 | has_wav_alarm = false; //poor guys probably feeling left out... |
197 | } | 197 | break; |
198 | 198 | default: | |
199 | 199 | has_wav_alarm = true; //lets just presume | |
200 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 200 | break; |
201 | 201 | } | |
202 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 202 | |
203 | grid-> setSpacing ( 4 ); | 203 | |
204 | grid-> setMargin ( 6 ); | 204 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
205 | 205 | ||
206 | QVBoxLayout *vbox; | 206 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
207 | QLabel *l; | 207 | grid-> setSpacing ( 4 ); |
208 | 208 | grid-> setMargin ( 6 ); | |
209 | vbox = new QVBoxLayout ( ); | 209 | |
210 | vbox-> setSpacing ( 4 ); | 210 | QVBoxLayout *vbox; |
211 | grid-> addLayout ( vbox, 1, 0 ); | 211 | QLabel *l; |
212 | 212 | ||
213 | upButton = new QPushButton ( this ); | 213 | vbox = new QVBoxLayout ( ); |
214 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 214 | vbox-> setSpacing ( 4 ); |
215 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | 215 | grid-> addLayout ( vbox, 1, 0 ); |
216 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 216 | |
217 | 217 | upButton = new QPushButton ( this ); | |
218 | vbox-> addWidget ( upButton ); | 218 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
219 | 219 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | |
220 | downButton = new QPushButton ( this ); | 220 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
221 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 221 | |
222 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | 222 | vbox-> addWidget ( upButton ); |
223 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 223 | |
224 | 224 | downButton = new QPushButton ( this ); | |
225 | vbox-> addWidget ( downButton ); | 225 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
226 | 226 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | |
227 | volSlider = new QSlider ( this ); | 227 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
228 | volSlider-> setRange ( 0, 100 ); | 228 | |
229 | volSlider-> setTickmarks ( QSlider::Both ); | 229 | vbox-> addWidget ( downButton ); |
230 | volSlider-> setTickInterval ( 20 ); | 230 | |
231 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 231 | volSlider = new QSlider ( this ); |
232 | 232 | volSlider-> setRange ( 0, 100 ); | |
233 | l = new QLabel ( this ); | 233 | volSlider-> setTickmarks ( QSlider::Both ); |
234 | l-> setPixmap ( QPixmap ( vol_xpm )); | 234 | volSlider-> setTickInterval ( 20 ); |
235 | 235 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | |
236 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 236 | |
237 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 237 | l = new QLabel ( this ); |
238 | 238 | l-> setPixmap ( QPixmap ( vol_xpm )); | |
239 | volLed = new OLedBox ( green, this ); | 239 | |
240 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 240 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
241 | volLed-> setFixedSize ( 16, 16 ); | 241 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
242 | 242 | ||
243 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 243 | volLed = new OLedBox ( green, this ); |
244 | 244 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | |
245 | micSlider = new QSlider ( this ); | 245 | volLed-> setFixedSize ( 16, 16 ); |
246 | micSlider-> setRange ( 0, 100 ); | 246 | |
247 | micSlider-> setTickmarks ( QSlider::Both ); | 247 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
248 | micSlider-> setTickInterval ( 20 ); | 248 | |
249 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 249 | micSlider = new QSlider ( this ); |
250 | 250 | micSlider-> setRange ( 0, 100 ); | |
251 | l = new QLabel ( this ); | 251 | micSlider-> setTickmarks ( QSlider::Both ); |
252 | l-> setPixmap ( QPixmap ( mic_xpm )); | 252 | micSlider-> setTickInterval ( 20 ); |
253 | 253 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | |
254 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 254 | |
255 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 255 | l = new QLabel ( this ); |
256 | 256 | l-> setPixmap ( QPixmap ( mic_xpm )); | |
257 | micLed = new OLedBox ( red, this ); | 257 | |
258 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 258 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
259 | micLed-> setFixedSize ( 16, 16 ); | 259 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
260 | 260 | ||
261 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 261 | micLed = new OLedBox ( red, this ); |
262 | 262 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | |
263 | alarmSlider = new QSlider ( this ); | 263 | micLed-> setFixedSize ( 16, 16 ); |
264 | alarmSlider-> setRange ( 0, 100 ); | 264 | |
265 | alarmSlider-> setTickmarks ( QSlider::Both ); | 265 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
266 | alarmSlider-> setTickInterval ( 20 ); | 266 | |
267 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 267 | alarmSlider = new QSlider ( this ); |
268 | 268 | alarmSlider-> setRange ( 0, 100 ); | |
269 | QLabel *alarmLabel = new QLabel ( this ); | 269 | alarmSlider-> setTickmarks ( QSlider::Both ); |
270 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 270 | alarmSlider-> setTickInterval ( 20 ); |
271 | 271 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | |
272 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 272 | |
273 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 273 | QLabel *alarmLabel = new QLabel ( this ); |
274 | 274 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | |
275 | alarmLed = new OLedBox ( yellow, this ); | 275 | |
276 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 276 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
277 | alarmLed-> setFixedSize ( 16, 16 ); | 277 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
278 | 278 | ||
279 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 279 | alarmLed = new OLedBox ( yellow, this ); |
280 | 280 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | |
281 | if ( !has_wav_alarm ) { | 281 | alarmLed-> setFixedSize ( 16, 16 ); |
282 | alarmSlider-> hide ( ); | 282 | |
283 | alarmLabel-> hide ( ); | 283 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
284 | alarmLed-> hide ( ); | 284 | |
285 | } | 285 | if ( !has_wav_alarm ) { |
286 | 286 | alarmSlider-> hide ( ); | |
287 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); | 287 | alarmLabel-> hide ( ); |
288 | 288 | alarmLed-> hide ( ); | |
289 | vbox = new QVBoxLayout ( ); | 289 | } |
290 | vbox-> setSpacing ( 4 ); | 290 | |
291 | grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); | 291 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); |
292 | 292 | ||
293 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 293 | vbox = new QVBoxLayout ( ); |
294 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 294 | vbox-> setSpacing ( 4 ); |
295 | 295 | grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); | |
296 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 296 | |
297 | 297 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | |
298 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 298 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
299 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 299 | |
300 | 300 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | |
301 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 301 | |
302 | 302 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | |
303 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 303 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
304 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 304 | |
305 | 305 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | |
306 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 306 | |
307 | 307 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | |
308 | if ( has_wav_alarm ) { | 308 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
309 | alarmBox-> hide ( ); | 309 | |
310 | } | 310 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
311 | 311 | ||
312 | vbox-> addStretch ( 100 ); | 312 | if ( has_wav_alarm ) { |
313 | 313 | alarmBox-> hide ( ); | |
314 | setFixedSize ( sizeHint ( )); | 314 | } |
315 | setFocusPolicy ( QWidget::NoFocus ); | 315 | |
316 | 316 | vbox-> addStretch ( 100 ); | |
317 | rateTimer = new QTimer( this ); | 317 | |
318 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); | 318 | setFixedSize ( sizeHint ( )); |
319 | 319 | setFocusPolicy ( QWidget::NoFocus ); | |
320 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 320 | |
321 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 321 | rateTimer = new QTimer( this ); |
322 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 322 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); |
323 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 323 | |
324 | 324 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | |
325 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); | 325 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
326 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); | 326 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); |
327 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); | 327 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
328 | 328 | ||
329 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); | 329 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); |
330 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); | 330 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); |
331 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 331 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); |
332 | 332 | ||
333 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 333 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); |
334 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); | 334 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); |
335 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); | 335 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
336 | 336 | ||
337 | // initialize variables | 337 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
338 | 338 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); | |
339 | readConfig ( true ); | 339 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); |
340 | 340 | ||
341 | // initialize the config file, in case some entries are missing | 341 | // initialize variables |
342 | 342 | ||
343 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 343 | readConfig ( true ); |
344 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 344 | |
345 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 345 | // initialize the config file, in case some entries are missing |
346 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 346 | |
347 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 347 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
348 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 348 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
349 | 349 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | |
350 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 350 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
351 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 351 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
352 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | ||
353 | |||
354 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | ||
355 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | ||
352 | } | 356 | } |
353 | 357 | ||
354 | bool VolumeControl::volMuted ( ) const | 358 | bool VolumeControl::volMuted ( ) const |
355 | { | 359 | { |
356 | return m_vol_muted; | 360 | return m_vol_muted; |
357 | } | 361 | } |
358 | 362 | ||
359 | int VolumeControl::volPercent ( ) const | 363 | int VolumeControl::volPercent ( ) const |
360 | { | 364 | { |
361 | return m_vol_percent; | 365 | return m_vol_percent; |
362 | } | 366 | } |
363 | 367 | ||
364 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 368 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
365 | { | 369 | { |
366 | switch ( e-> key ( )) { | 370 | switch ( e-> key ( )) { |
367 | case Key_Up: | 371 | case Key_Up: |
368 | volSlider-> subtractStep ( ); | 372 | volSlider-> subtractStep ( ); |
369 | break; | 373 | break; |
370 | case Key_Down: | 374 | case Key_Down: |
371 | volSlider-> addStep ( ); | 375 | volSlider-> addStep ( ); |
372 | break; | 376 | break; |
373 | case Key_Space: | 377 | case Key_Space: |
374 | volLed-> toggle ( ); | 378 | volLed-> toggle ( ); |
375 | break; | 379 | break; |
376 | case Key_Escape: | 380 | case Key_Escape: |
377 | hide ( ); | 381 | hide ( ); |
378 | break; | 382 | break; |
379 | } | 383 | } |
380 | } | 384 | } |
381 | 385 | ||
382 | void VolumeControl::buttonChanged ( ) | 386 | void VolumeControl::buttonChanged ( ) |
383 | { | 387 | { |
384 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 388 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
385 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 389 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
386 | // called at all when a button is pressed for a time | 390 | // called at all when a button is pressed for a time |
387 | // shorter than RATE_TIMER_INTERVAL. | 391 | // shorter than RATE_TIMER_INTERVAL. |
388 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 392 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
389 | } | 393 | } |
390 | else | 394 | else |
391 | rateTimer-> stop ( ); | 395 | rateTimer-> stop ( ); |
392 | } | 396 | } |
393 | 397 | ||
394 | void VolumeControl::rateTimerDone ( ) | 398 | void VolumeControl::rateTimerDone ( ) |
395 | { | 399 | { |
396 | if ( upButton-> isDown ( )) | 400 | if ( upButton-> isDown ( )) |
397 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 401 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
398 | else // if ( downButton-> isDown ( )) | 402 | else // if ( downButton-> isDown ( )) |
399 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 403 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
400 | } | 404 | } |
401 | 405 | ||
402 | void VolumeControl::show ( bool /*showMic*/ ) | 406 | void VolumeControl::show ( bool /*showMic*/ ) |
403 | { | 407 | { |
404 | readConfig ( ); | 408 | readConfig ( ); |
405 | 409 | ||
406 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 410 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
407 | printf ( "SHOW AT : %d/%d\n", curPos.x(), curPos.y()); | 411 | printf ( "SHOW AT : %d/%d\n", curPos.x(), curPos.y()); |
408 | printf ( "SIZEHINT: %d/%d\n", sizeHint().width(),sizeHint().height()); | 412 | printf ( "SIZEHINT: %d/%d\n", sizeHint().width(),sizeHint().height()); |
409 | 413 | ||
410 | int w = sizeHint ( ). width ( ); | 414 | int w = sizeHint ( ). width ( ); |
411 | int x = curPos.x ( ) - ( w / 2 ); | 415 | int x = curPos.x ( ) - ( w / 2 ); |
412 | 416 | ||
413 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 417 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
414 | x = QPEApplication::desktop ( )-> width ( ) - w; | 418 | x = QPEApplication::desktop ( )-> width ( ) - w; |
415 | 419 | ||
416 | 420 | ||
417 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 421 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |
418 | QFrame::show ( ); | 422 | QFrame::show ( ); |
419 | 423 | ||
420 | } | 424 | } |
421 | 425 | ||
422 | void VolumeControl::readConfig ( bool force ) | 426 | void VolumeControl::readConfig ( bool force ) |
423 | { | 427 | { |
424 | Config cfg ( "qpe" ); | 428 | Config cfg ( "qpe" ); |
425 | cfg. setGroup ( "Volume" ); | 429 | cfg. setGroup ( "Volume" ); |
426 | 430 | ||
427 | int old_vp = m_vol_percent; | 431 | int old_vp = m_vol_percent; |
428 | int old_mp = m_mic_percent; | 432 | int old_mp = m_mic_percent; |
429 | bool old_vm = m_vol_muted; | 433 | bool old_vm = m_vol_muted; |
430 | bool old_mm = m_mic_muted; | 434 | bool old_mm = m_mic_muted; |
431 | bool old_sk = m_snd_key; | 435 | bool old_sk = m_snd_key; |
432 | bool old_st = m_snd_touch; | 436 | bool old_st = m_snd_touch; |
433 | bool old_sa = m_snd_alarm; | 437 | bool old_sa = m_snd_alarm; |
434 | int old_ap = m_alarm_percent; | 438 | int old_ap = m_alarm_percent; |
435 | 439 | ||
436 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 440 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
437 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 441 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
438 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 442 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
439 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 443 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
440 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 444 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
441 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 445 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
442 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 446 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
443 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 447 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
444 | 448 | ||
445 | if ( force || ( m_vol_percent != old_vp )) | 449 | if ( force || ( m_vol_percent != old_vp )) |
446 | volSlider-> setValue ( 100 - m_vol_percent ); | 450 | volSlider-> setValue ( 100 - m_vol_percent ); |
447 | if ( force || ( m_mic_percent != old_mp )) | 451 | if ( force || ( m_mic_percent != old_mp )) |
448 | micSlider-> setValue ( 100 - m_mic_percent ); | 452 | micSlider-> setValue ( 100 - m_mic_percent ); |
449 | if ( force || ( m_alarm_percent != old_ap )) | 453 | if ( force || ( m_alarm_percent != old_ap )) |
450 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 454 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
451 | 455 | ||
452 | if ( force || ( m_vol_muted != old_vm )) | 456 | if ( force || ( m_vol_muted != old_vm )) |
453 | volLed-> setOn ( !m_vol_muted ); | 457 | volLed-> setOn ( !m_vol_muted ); |
454 | if ( force || ( m_mic_muted != old_mm )) | 458 | if ( force || ( m_mic_muted != old_mm )) |
455 | micLed-> setOn ( !m_mic_muted ); | 459 | micLed-> setOn ( !m_mic_muted ); |
456 | if ( force || ( m_snd_alarm != old_sa )) | 460 | if ( force || ( m_snd_alarm != old_sa )) |
457 | alarmLed-> setOn ( m_snd_alarm ); | 461 | alarmLed-> setOn ( m_snd_alarm ); |
458 | 462 | ||
459 | if ( force || ( m_snd_key != old_sk )) | 463 | if ( force || ( m_snd_key != old_sk )) |
460 | keyBox-> setChecked ( m_snd_key ); | 464 | keyBox-> setChecked ( m_snd_key ); |
461 | if ( force || ( m_snd_touch != old_st )) | 465 | if ( force || ( m_snd_touch != old_st )) |
462 | tapBox-> setChecked ( m_snd_touch ); | 466 | tapBox-> setChecked ( m_snd_touch ); |
463 | if ( force || ( m_snd_alarm != old_sa )) | 467 | if ( force || ( m_snd_alarm != old_sa )) |
464 | alarmBox-> setChecked ( m_snd_alarm ); | 468 | alarmBox-> setChecked ( m_snd_alarm ); |
465 | } | 469 | } |
466 | 470 | ||
467 | 471 | ||
468 | void VolumeControl::volumeChanged ( bool nowMuted ) | 472 | void VolumeControl::volumeChanged ( bool nowMuted ) |
469 | { | 473 | { |
470 | int previousVolume = m_vol_percent; | 474 | int previousVolume = m_vol_percent; |
471 | 475 | ||
472 | if ( !nowMuted ) | 476 | if ( !nowMuted ) |
473 | readConfig ( ); | 477 | readConfig ( ); |
474 | 478 | ||
475 | // Handle case where muting it toggled | 479 | // Handle case where muting it toggled |
476 | if ( m_vol_muted != nowMuted ) { | 480 | if ( m_vol_muted != nowMuted ) { |
477 | m_vol_muted = nowMuted; | 481 | m_vol_muted = nowMuted; |
478 | m_icon-> repaint ( true ); | 482 | m_icon-> repaint ( true ); |
479 | } | 483 | } |
480 | else if ( previousVolume != m_vol_percent ) { | 484 | else if ( previousVolume != m_vol_percent ) { |
481 | // Avoid over repainting | 485 | // Avoid over repainting |
482 | m_icon-> repaint( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 486 | m_icon-> repaint( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
483 | } | 487 | } |
484 | 488 | ||
485 | } | 489 | } |
486 | 490 | ||
487 | void VolumeControl::micChanged ( bool nowMuted ) | 491 | void VolumeControl::micChanged ( bool nowMuted ) |
488 | { | 492 | { |
489 | if ( !nowMuted ) | 493 | if ( !nowMuted ) |
490 | readConfig ( ); | 494 | readConfig ( ); |
491 | m_mic_muted = nowMuted; | 495 | m_mic_muted = nowMuted; |
492 | } | 496 | } |
493 | 497 | ||
494 | void VolumeControl::screenTapToggled ( bool b ) | 498 | void VolumeControl::screenTapToggled ( bool b ) |
495 | { | 499 | { |
496 | m_snd_touch = b; | 500 | m_snd_touch = b; |
497 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 501 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
498 | } | 502 | } |
499 | 503 | ||
500 | void VolumeControl::keyClickToggled ( bool b ) | 504 | void VolumeControl::keyClickToggled ( bool b ) |
501 | { | 505 | { |
502 | m_snd_key = b; | 506 | m_snd_key = b; |
503 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 507 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
504 | } | 508 | } |
505 | 509 | ||
506 | void VolumeControl::alarmSoundToggled ( bool b ) | 510 | void VolumeControl::alarmSoundToggled ( bool b ) |
507 | { | 511 | { |
508 | m_snd_alarm = b; | 512 | m_snd_alarm = b; |
509 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 513 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
510 | } | 514 | } |
511 | 515 | ||
512 | void VolumeControl::volMuteToggled ( bool b ) | 516 | void VolumeControl::volMuteToggled ( bool b ) |
513 | { | 517 | { |
514 | m_vol_muted = !b; | 518 | m_vol_muted = !b; |
515 | 519 | ||
516 | m_icon-> repaint ( !m_vol_muted ); // clear if removing mute | 520 | m_icon-> repaint ( !m_vol_muted ); // clear if removing mute |
517 | 521 | ||
518 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 522 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
519 | } | 523 | } |
520 | 524 | ||
521 | void VolumeControl::micMuteToggled ( bool b ) | 525 | void VolumeControl::micMuteToggled ( bool b ) |
522 | { | 526 | { |
523 | m_mic_muted = !b; | 527 | m_mic_muted = !b; |
524 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 528 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
525 | } | 529 | } |
526 | 530 | ||
527 | 531 | ||
528 | void VolumeControl::volMoved ( int percent ) | 532 | void VolumeControl::volMoved ( int percent ) |
529 | { | 533 | { |
530 | m_vol_percent = 100 - percent; | 534 | m_vol_percent = 100 - percent; |
531 | 535 | ||
532 | // clamp volume percent to be between 0 and 100 | 536 | // clamp volume percent to be between 0 and 100 |
533 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 537 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
534 | // repaint just the little volume rectangle | 538 | // repaint just the little volume rectangle |
535 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 539 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
536 | 540 | ||
537 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 541 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
538 | } | 542 | } |
539 | 543 | ||
540 | void VolumeControl::micMoved ( int percent ) | 544 | void VolumeControl::micMoved ( int percent ) |
541 | { | 545 | { |
542 | m_mic_percent = 100 - percent; | 546 | m_mic_percent = 100 - percent; |
543 | 547 | ||
544 | // clamp volume percent to be between 0 and 100 | 548 | // clamp volume percent to be between 0 and 100 |
545 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 549 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
546 | 550 | ||
547 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 551 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
548 | } | 552 | } |
549 | 553 | ||
550 | void VolumeControl::alarmMoved ( int percent ) | 554 | void VolumeControl::alarmMoved ( int percent ) |
551 | { | 555 | { |
552 | m_alarm_percent = 100 - percent; | 556 | m_alarm_percent = 100 - percent; |
553 | 557 | ||
554 | // clamp volume percent to be between 0 and 100 | 558 | // clamp volume percent to be between 0 and 100 |
555 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 559 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
556 | 560 | ||
557 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 561 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
558 | } | 562 | } |
559 | 563 | ||
560 | 564 | ||
561 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 565 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
562 | { | 566 | { |
563 | Config cfg ( "qpe" ); | 567 | Config cfg ( "qpe" ); |
564 | cfg. setGroup ( "Volume" ); | 568 | cfg. setGroup ( "Volume" ); |
565 | cfg. writeEntry ( entry, val ); | 569 | cfg. writeEntry ( entry, val ); |
566 | //cfg. write ( ); | 570 | // cfg. write ( ); |
567 | 571 | ||
568 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 572 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
569 | switch ( upd ) { | 573 | switch ( upd ) { |
570 | case UPD_Vol: { | 574 | case UPD_Vol: { |
571 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 575 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
572 | break; | 576 | break; |
573 | } | 577 | } |
574 | case UPD_Mic: { | 578 | case UPD_Mic: { |
575 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 579 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
576 | break; | 580 | break; |
577 | } | 581 | } |
578 | case UPD_None: | 582 | case UPD_None: |
579 | break; | 583 | break; |
580 | } | 584 | } |
581 | #endif | 585 | #endif |
582 | } | 586 | } |
583 | 587 | ||
584 | //=========================================================================== | 588 | //=========================================================================== |
585 | 589 | ||
586 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 590 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
587 | : QWidget( parent, name ) | 591 | : QWidget( parent, name ) |
588 | { | 592 | { |
589 | setFixedHeight ( 18 ); | 593 | setFixedHeight ( 18 ); |
590 | setFixedWidth ( 14 ); | 594 | setFixedWidth ( 14 ); |
591 | 595 | ||
592 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); | 596 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); |
593 | m_dialog = new VolumeControl ( this ); | 597 | m_dialog = new VolumeControl ( this ); |
594 | 598 | ||
595 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); | 599 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); |
596 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); | 600 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); |
597 | } | 601 | } |
598 | 602 | ||
599 | VolumeApplet::~VolumeApplet() | 603 | VolumeApplet::~VolumeApplet() |
600 | { | 604 | { |
601 | delete m_pixmap; | 605 | delete m_pixmap; |
602 | } | 606 | } |
603 | 607 | ||
604 | 608 | ||
605 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 609 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
606 | { | 610 | { |
607 | if ( m_dialog-> isVisible ( )) | 611 | if ( m_dialog-> isVisible ( )) |
608 | m_dialog-> hide ( ); | 612 | m_dialog-> hide ( ); |
609 | else | 613 | else |
610 | m_dialog-> show ( true ); | 614 | m_dialog-> show ( true ); |
611 | } | 615 | } |
612 | 616 | ||
613 | 617 | ||
614 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 618 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
615 | { | 619 | { |
616 | QPainter p ( this ); | 620 | QPainter p ( this ); |
617 | 621 | ||
618 | p. drawPixmap ( 0, 1, *m_pixmap ); | 622 | p. drawPixmap ( 0, 1, *m_pixmap ); |
619 | p. setPen ( darkGray ); | 623 | p. setPen ( darkGray ); |
620 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 624 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
621 | 625 | ||
622 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 626 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
623 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 627 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
624 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 628 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
625 | 629 | ||
626 | if ( m_dialog-> volMuted ( )) { | 630 | if ( m_dialog-> volMuted ( )) { |
627 | p. setPen ( red ); | 631 | p. setPen ( red ); |
628 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 632 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
629 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 633 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
630 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 634 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
631 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 635 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
632 | } | 636 | } |
633 | } | 637 | } |
634 | 638 | ||
635 | 639 | ||