summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-04 01:24:34 (UTC)
committer wimpie <wimpie>2005-01-04 01:24:34 (UTC)
commitf7e9672b6064a7c4ac7e485c292e6192263b271a (patch) (unidiff)
tree0e2955e6c9d49e9d57559ac73f07e67143c70b41
parent937acd0b191564bace4da11cbf6c912a6f2300cf (diff)
downloadopie-f7e9672b6064a7c4ac7e485c292e6192263b271a.zip
opie-f7e9672b6064a7c4ac7e485c292e6192263b271a.tar.gz
opie-f7e9672b6064a7c4ac7e485c292e6192263b271a.tar.bz2
oledbox is now in libopie2/opieui
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/oledbox.cpp274
-rw-r--r--core/applets/volumeapplet/oledbox.h51
-rw-r--r--core/applets/volumeapplet/volume.cpp2
-rw-r--r--core/applets/volumeapplet/volumeapplet.pro3
4 files changed, 3 insertions, 327 deletions
diff --git a/core/applets/volumeapplet/oledbox.cpp b/core/applets/volumeapplet/oledbox.cpp
deleted file mode 100644
index bf275a9..0000000
--- a/core/applets/volumeapplet/oledbox.cpp
+++ b/dev/null
@@ -1,274 +0,0 @@
1
2#include <qbitmap.h>
3#include <qpainter.h>
4
5#include "oledbox.h"
6
7
8#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
9
10/* XPM */
11static const char * ledborder_xpm[] = {
12"16 16 11 1",
13 " c None",
14 ".c #626562",
15 "+c #7B7D7B",
16 "@c #949594",
17 "#c #ACAEAC",
18 "$c #CDCACD",
19 "%c #CDCECD",
20 ";c #E6E6E6",
21 ">c #FFFFFF",
22 ",c #E6E2E6",
23 "'c #FFFAFF",
24" .++@@# ",
25" ...++@@##$ ",
26" .....+@##$$% ",
27" ..... #$%%% ",
28" ... %%; ",
29".... ;;;;",
30"++. ;>>",
31"+++ >>>",
32"@@@ >>>",
33"@@# >>>",
34"#### >>>>",
35" #$$ >>> ",
36" $$,,' >>>>> ",
37" ,,,''>>>>>>> ",
38" ,''>>>>>>> ",
39" '>>>>> "};
40
41
42QPixmap *OLedBox::s_border_pix = 0;
43
44#endif
45
46
47OLedBox::OLedBox ( const QColor &col, QWidget *parent, const char *name ) : QWidget ( parent, name )
48{
49 m_color = col;
50 m_on = false;
51
52 m_pix [ 0 ] = m_pix [ 1 ] = false;
53
54 setBackgroundMode ( PaletteBackground );
55
56#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
57 if ( !s_border_pix )
58 s_border_pix = new QPixmap ( ledborder_xpm );
59#endif
60}
61
62OLedBox::~OLedBox ( )
63{
64 delete m_pix [ 0 ];
65 delete m_pix [ 1 ];
66}
67
68QSize OLedBox::sizeHint ( ) const
69{
70 return QSize ( 16, 16 );
71}
72
73bool OLedBox::isOn ( ) const
74{
75 return m_on;
76}
77
78QColor OLedBox::color ( ) const
79{
80 return m_color;
81}
82
83void OLedBox::setOn ( bool b )
84{
85 if ( m_on != b ) {
86 m_on = b;
87 update ( );
88 }
89}
90
91void OLedBox::toggle ( )
92{
93 setOn ( !isOn ( ) );
94}
95
96void OLedBox::setColor ( const QColor &col )
97{
98 if ( m_color != col ) {
99 m_color = col;
100
101 delete m_pix [ 0 ];
102 delete m_pix [ 1 ];
103
104 update ( );
105 }
106}
107
108void OLedBox::mousePressEvent ( QMouseEvent *e )
109{
110 if ( e-> button ( ) == LeftButton ) {
111 m_on = !m_on;
112 update ( );
113 emit toggled ( m_on );
114 }
115}
116
117
118void OLedBox::resizeEvent ( QResizeEvent * )
119{
120 delete m_pix [ 0 ];
121 delete m_pix [ 1 ];
122
123 update ( );
124}
125
126void OLedBox::paintEvent ( QPaintEvent *e )
127{
128 int ind = m_on ? 1 : 0;
129
130 if ( !m_pix [ ind ] ) {
131 m_pix [ ind ] = new QPixmap ( size ( ));
132
133 drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) );
134 }
135 if ( !e-> erased ( ))
136 erase ( );
137
138 QPainter p ( this );
139 p. drawPixmap ( 0, 0, *m_pix [ ind ] );
140}
141
142// From KDE libkdeui / led.cpp
143
144void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp
145{
146 QPainter paint;
147 QColor color;
148 QBrush brush;
149 QPen pen;
150
151 pix-> fill ( black );
152
153 // First of all we want to know what area should be updated
154 // Initialize coordinates, width, and height of the LED
155 int width = pix-> width ( );
156
157 // Make sure the LED is round!
158 if ( width > pix-> height ( ))
159 width = pix-> height ( );
160 width -= 2; // leave one pixel border
161 if ( width < 0 )
162 width = 0;
163
164 // maybe we could stop HERE, if width <=0 ?
165
166 // start painting widget
167 //
168 paint.begin( pix );
169
170 // Set the color of the LED according to given parameters
171 color = col;
172
173 // Set the brush to SolidPattern, this fills the entire area
174 // of the ellipse which is drawn first
175 brush.setStyle( QBrush::SolidPattern );
176 brush.setColor( color );
177 paint.setBrush( brush ); // Assign the brush to the painter
178
179 // Draws a "flat" LED with the given color:
180 paint.drawEllipse( 1, 1, width, width );
181
182 // Draw the bright light spot of the LED now, using modified "old"
183 // painter routine taken from KDEUIs KLed widget:
184
185 // Setting the new width of the pen is essential to avoid "pixelized"
186 // shadow like it can be observed with the old LED code
187 pen.setWidth( 2 );
188
189 // shrink the light on the LED to a size about 2/3 of the complete LED
190 int pos = width / 5 + 1;
191 int light_width = width;
192 light_width *= 2;
193 light_width /= 3;
194
195 // Calculate the LEDs "light factor":
196 int light_quote = ( 130 * 2 / ( light_width ? light_width : 1 ) ) + 100;
197
198 // Now draw the bright spot on the LED:
199 while ( light_width )
200 {
201 color = color.light( light_quote ); // make color lighter
202 pen.setColor( color ); // set color as pen color
203 paint.setPen( pen ); // select the pen for drawing
204 paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle)
205 light_width--;
206 if ( !light_width )
207 break;
208 paint.drawEllipse( pos, pos, light_width, light_width );
209 light_width--;
210 if ( !light_width )
211 break;
212 paint.drawEllipse( pos, pos, light_width, light_width );
213 pos++;
214 light_width--;
215 }
216
217 // Drawing of bright spot finished, now draw a thin border
218 // around the LED which resembles a shadow with light coming
219 // from the upper left.
220
221#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
222 paint. drawPixmap ( 0, 0, *s_border_pix );
223 paint. end ( );
224
225 pix-> setMask ( pix-> createHeuristicMask ( ));
226
227#else
228 pen.setWidth( 3 );
229 brush.setStyle( QBrush::NoBrush ); // Switch off the brush
230 paint.setBrush( brush ); // This avoids filling of the ellipse
231
232 // Set the initial color value to 200 (bright) and start
233 // drawing the shadow border at 45 (45*16 = 720).
234 int shadow_color = 200, angle;
235
236 for ( angle = 720; angle < 6480; angle += 240 )
237 {
238 color.setRgb( shadow_color, shadow_color, shadow_color );
239 pen.setColor( color );
240 paint.setPen( pen );
241 paint.drawArc( 0, 0, width+2, width+2, angle, 240 );
242 paint.drawArc( 1, 1, width, width, angle, 240 );
243 paint.drawArc( 2, 2, width-2, width-2, angle, 240 );
244 if ( angle < 2320 ) {
245 shadow_color -= 25; // set color to a darker value
246 if ( shadow_color < 100 )
247 shadow_color = 100;
248 }
249 else if ( ( angle > 2320 ) && ( angle < 5760 ) ) {
250 shadow_color += 25; // set color to a brighter value
251 if ( shadow_color > 255 )
252 shadow_color = 255;
253 }
254 else {
255 shadow_color -= 25; // set color to a darker value again
256 if ( shadow_color < 100 )
257 shadow_color = 100;
258 } // end if ( angle < 2320 )
259 } // end for ( angle = 720; angle < 6480; angle += 160 )
260 paint.end();
261 //
262 // painting done
263
264 QBitmap mask ( pix-> width ( ), pix-> height ( ), true );
265 QPainter mp ( &mask );
266 mp. setPen ( Qt::NoPen );
267 mp. setBrush ( Qt::color1 );
268 mp. drawEllipse ( 0, 0, width + 2, width + 2 );
269 mp. end ( );
270
271 pix-> setMask ( mask );
272#endif
273}
274
diff --git a/core/applets/volumeapplet/oledbox.h b/core/applets/volumeapplet/oledbox.h
deleted file mode 100644
index 4371a22..0000000
--- a/core/applets/volumeapplet/oledbox.h
+++ b/dev/null
@@ -1,51 +0,0 @@
1#ifndef __OPIE_OLED_H__
2#define __OPIE_OLED_H__
3
4#include <qwidget.h>
5#include <qcolor.h>
6
7class QPixmap;
8
9#define _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
10
11class OLedBox : public QWidget {
12 Q_OBJECT
13
14public:
15 OLedBox ( const QColor &col = red, QWidget *parent = 0, const char *name = 0 );
16 virtual ~OLedBox ( );
17
18 QColor color ( ) const;
19 bool isOn ( ) const;
20
21 virtual QSize sizeHint ( ) const;
22
23public slots:
24 void toggle ( );
25 void setOn ( bool on );
26 void setColor ( const QColor &col );
27
28signals:
29 void toggled ( bool );
30
31protected:
32 virtual void paintEvent ( QPaintEvent *e );
33 virtual void resizeEvent ( QResizeEvent *e );
34
35 virtual void mousePressEvent ( QMouseEvent *e );
36
37private:
38 void drawLed ( QPixmap *, const QColor &col );
39
40private:
41 QPixmap *m_pix [2];
42
43 QColor m_color;
44 bool m_on;
45
46 #ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
47 static QPixmap *s_border_pix;
48#endif
49};
50
51#endif
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 6a14d07..45c106a 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,780 +1,780 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "volume.h" 21#include "volume.h"
22#include "oledbox.h"
23 22
23#include <opie2/oledbox.h>
24#include <opie2/odevice.h> 24#include <opie2/odevice.h>
25#include <opie2/otaskbarapplet.h> 25#include <opie2/otaskbarapplet.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
30 30
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qcheckbox.h> 32#include <qcheckbox.h>
33#include <qslider.h> 33#include <qslider.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qtimer.h> 38#include <qtimer.h>
39 39
40#include <stdio.h> 40#include <stdio.h>
41 41
42using namespace Opie::Core; 42using namespace Opie::Core;
43 43
44#define RATE_TIMER_INTERVAL 100 44#define RATE_TIMER_INTERVAL 100
45// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time 45// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
46// results in "hanging" buttons on the iPAQ due to quite high CPU consumption. 46// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
47 47
48 48
49/* XPM */ 49/* XPM */
50using namespace Opie::Ui; 50using namespace Opie::Ui;
51static const char * vol_xpm[] = { 51static const char * vol_xpm[] = {
52"20 20 3 1", 52"20 20 3 1",
53" c None", 53" c None",
54". c #0000FF", 54". c #0000FF",
55"+ c #000000", 55"+ c #000000",
56" ", 56" ",
57" . ", 57" . ",
58" . . . . ", 58" . . . . ",
59" . . . . . . ", 59" . . . . . . ",
60" . . . . . . . ", 60" . . . . . . . ",
61" . . ..... . . ", 61" . . ..... . . ",
62" . ... ..... ... ", 62" . ... ..... ... ",
63" ........... .... ", 63" ........... .... ",
64" ................. ", 64" ................. ",
65"++++++++++++++++++++", 65"++++++++++++++++++++",
66" .................. ", 66" .................. ",
67" . ............. . ", 67" . ............. . ",
68" . ..... ....... ", 68" . ..... ....... ",
69" . ... ..... . ", 69" . ... ..... . ",
70" . ... ..... . ", 70" . ... ..... . ",
71" . ... ..... ", 71" . ... ..... ",
72" . . . . . ", 72" . . . . . ",
73" . . . ", 73" . . . ",
74" . . . ", 74" . . . ",
75" "}; 75" "};
76/* XPM */ 76/* XPM */
77static const char * mic_xpm[] = { 77static const char * mic_xpm[] = {
78"20 20 21 1", 78"20 20 21 1",
79" c None", 79" c None",
80". c #000000", 80". c #000000",
81"+ c #EEEEEE", 81"+ c #EEEEEE",
82"@ c #B4B6B4", 82"@ c #B4B6B4",
83"# c #8B8D8B", 83"# c #8B8D8B",
84"$ c #D5D6D5", 84"$ c #D5D6D5",
85"% c #E6E6E6", 85"% c #E6E6E6",
86"& c #9C9D9C", 86"& c #9C9D9C",
87"* c #6A696A", 87"* c #6A696A",
88"= c #E6E2E6", 88"= c #E6E2E6",
89"- c #F6F2F6", 89"- c #F6F2F6",
90"; c #CDC6CD", 90"; c #CDC6CD",
91"> c #737573", 91"> c #737573",
92", c #4A484A", 92", c #4A484A",
93"' c #DEDEDE", 93"' c #DEDEDE",
94") c #F6EEF6", 94") c #F6EEF6",
95"! c #414041", 95"! c #414041",
96"~ c #202020", 96"~ c #202020",
97"{ c #ACAEAC", 97"{ c #ACAEAC",
98"] c #838583", 98"] c #838583",
99"^ c #6A656A", 99"^ c #6A656A",
100" ", 100" ",
101" .... ", 101" .... ",
102" .+@+#. ", 102" .+@+#. ",
103" ..$%&%*. ", 103" ..$%&%*. ",
104" .=-.;=>=,. ", 104" .=-.;=>=,. ",
105" .'+).&+!+. ", 105" .'+).&+!+. ",
106" .+;+;.~+~. ", 106" .+;+;.~+~. ",
107" ..%{%,.... ", 107" ..%{%,.... ",
108" ..&=>=~.. ", 108" ..&=>=~.. ",
109" .+..]^,.. ", 109" .+..]^,.. ",
110" .+....... ", 110" .+....... ",
111" .%... ", 111" .%... ",
112" .=... ", 112" .=... ",
113" .+... ", 113" .+... ",
114" .+... ", 114" .+... ",
115" .... ", 115" .... ",
116" .... ", 116" .... ",
117" .. ", 117" .. ",
118" . ", 118" . ",
119". "}; 119". "};
120 120
121 121
122static const char * bass_xpm[] = { 122static const char * bass_xpm[] = {
123"20 20 3 1", 123"20 20 3 1",
124" c None", 124" c None",
125". c #000000", 125". c #000000",
126"+ c #0000FF", 126"+ c #0000FF",
127" ", 127" ",
128" ", 128" ",
129" ", 129" ",
130"..... +++ ......", 130"..... +++ ......",
131" +++++++ ", 131" +++++++ ",
132" ++ ++ ", 132" ++ ++ ",
133"... ++ ... ++ ++ .", 133"... ++ ... ++ ++ .",
134" +++ ++ ++ ", 134" +++ ++ ++ ",
135" ++++ ++ ", 135" ++++ ++ ",
136"... ++++ .. ++ .....", 136"... ++++ .. ++ .....",
137" ++ ++ ", 137" ++ ++ ",
138" ++ ++ ", 138" ++ ++ ",
139"..........++ ++ .", 139"..........++ ++ .",
140" ++ ", 140" ++ ",
141" ++ ", 141" ++ ",
142"...... ++ .........", 142"...... ++ .........",
143" + ", 143" + ",
144" ", 144" ",
145" ", 145" ",
146" "}; 146" "};
147 147
148 148
149static const char * treble_xpm[] = { 149static const char * treble_xpm[] = {
150"20 20 3 1", 150"20 20 3 1",
151" c None", 151" c None",
152". c #0000FF", 152". c #0000FF",
153"+ c #000000", 153"+ c #000000",
154" .. ", 154" .. ",
155" . .. ", 155" . .. ",
156" . .. ", 156" . .. ",
157"++++++++ . .. ++++++", 157"++++++++ . .. ++++++",
158" . . ", 158" . . ",
159" ... ", 159" ... ",
160"++++++++ . +++++++", 160"++++++++ . +++++++",
161" .. ", 161" .. ",
162" .. . ", 162" .. . ",
163"+++ .. ... +++++++", 163"+++ .. ... +++++++",
164" .. .. .. ", 164" .. .. .. ",
165" .. . . .. ", 165" .. . . .. ",
166"+++ .. . . + . +++++", 166"+++ .. . . + . +++++",
167" .. . .. ", 167" .. . .. ",
168" .. . .. ", 168" .. . .. ",
169"++++ ...... +++++++", 169"++++ ...... +++++++",
170" . ", 170" . ",
171" .. . ", 171" .. . ",
172" .. . ", 172" .. . ",
173" .. "}; 173" .. "};
174 174
175 175
176 176
177 177
178/* XPM */ 178/* XPM */
179static const char * alarm_xpm[] = { 179static const char * alarm_xpm[] = {
180"20 20 33 1", 180"20 20 33 1",
181" c None", 181" c None",
182". c #080602", 182". c #080602",
183"+ c #AAA602", 183"+ c #AAA602",
184"@ c #252002", 184"@ c #252002",
185"# c #434202", 185"# c #434202",
186"$ c #795602", 186"$ c #795602",
187"% c #C3C20D", 187"% c #C3C20D",
188"& c #DADAC2", 188"& c #DADAC2",
189"* c #826002", 189"* c #826002",
190"= c #740502", 190"= c #740502",
191"- c #D6D602", 191"- c #D6D602",
192"; c #322E02", 192"; c #322E02",
193"> c #826A02", 193"> c #826A02",
194", c #F1F195", 194", c #F1F195",
195"' c #959215", 195"' c #959215",
196") c #423602", 196") c #423602",
197"! c #4B0302", 197"! c #4B0302",
198"~ c #844315", 198"~ c #844315",
199"{ c #AAAA2A", 199"{ c #AAAA2A",
200"] c #E2DE42", 200"] c #E2DE42",
201"^ c #BA7E04", 201"^ c #BA7E04",
202"/ c #7F7502", 202"/ c #7F7502",
203"( c #828276", 203"( c #828276",
204"_ c #FEFE4E", 204"_ c #FEFE4E",
205": c #7D1902", 205": c #7D1902",
206"< c #989656", 206"< c #989656",
207"[ c #260B02", 207"[ c #260B02",
208"} c #F7F7D8", 208"} c #F7F7D8",
209"| c #DCDA5A", 209"| c #DCDA5A",
210"1 c #823102", 210"1 c #823102",
211"2 c #B1AC6B", 211"2 c #B1AC6B",
212"3 c #F7F710", 212"3 c #F7F710",
213"4 c #838204", 213"4 c #838204",
214" ", 214" ",
215" ", 215" ",
216" 4'4/ ", 216" 4'4/ ",
217" /-^= ", 217" /-^= ",
218" 42{4>4 ", 218" 42{4>4 ",
219" '2|+*$44 ", 219" '2|+*$44 ",
220" +2&3+$1*44 ", 220" +2&3+$1*44 ",
221" (%_}_+/$:>/4 ", 221" (%_}_+/$:>/4 ",
222" 4%_}3+#;>:*4 ", 222" 4%_}3+#;>:*4 ",
223" 4%_}&+#[1$/4 ", 223" 4%_}&+#[1$/4 ",
224" 4%_,2')[~~>4 ", 224" 4%_,2')[~~>4 ",
225" 4%33'4#@~1>4 ", 225" 4%33'4#@~1>4 ",
226" 4%3344#[:>/4 ", 226" 4%3344#[:>/4 ",
227" 42&_3'4#@>:*44 ", 227" 42&_3'4#@>:*44 ",
228" 42|}}3'4#[;$)$44 ", 228" 42|}}3'4#[;$)$44 ",
229"444{]]2^~~:!!#.@##/ ", 229"444{]]2^~~:!!#.@##/ ",
230"4444-%*:==!!=...../ ", 230"4444-%*:==!!=...../ ",
231" /:[.. ", 231" /:[.. ",
232" /@. ", 232" /@. ",
233" "}; 233" "};
234 234
235VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) 235VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name )
236 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) 236 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
237{ 237{
238 m_icon = icon; 238 m_icon = icon;
239 239
240 bool has_wav_alarm = true; 240 bool has_wav_alarm = true;
241 bool has_bass = true; 241 bool has_bass = true;
242 bool has_treble = true; 242 bool has_treble = true;
243 243
244 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually 244 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
245 case Model_Zaurus_SL5000: 245 case Model_Zaurus_SL5000:
246 has_wav_alarm = false; //poor guys probably feeling left out... 246 has_wav_alarm = false; //poor guys probably feeling left out...
247 break; 247 break;
248 default: 248 default:
249 break; 249 break;
250 } 250 }
251 251
252 if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { 252 if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) {
253 has_bass = false; 253 has_bass = false;
254 has_treble = false; 254 has_treble = false;
255 } 255 }
256 256
257 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); 257 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
258 258
259 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); 259 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
260 grid-> setSpacing ( 4 ); 260 grid-> setSpacing ( 4 );
261 grid-> setMargin ( 6 ); 261 grid-> setMargin ( 6 );
262 262
263 QVBoxLayout *vbox; 263 QVBoxLayout *vbox;
264 QLabel *l; 264 QLabel *l;
265 265
266 vbox = new QVBoxLayout ( ); 266 vbox = new QVBoxLayout ( );
267 vbox-> setSpacing ( 4 ); 267 vbox-> setSpacing ( 4 );
268 grid-> addLayout ( vbox, 1, 0 ); 268 grid-> addLayout ( vbox, 1, 0 );
269 269
270 upButton = new QPushButton ( this ); 270 upButton = new QPushButton ( this );
271 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 271 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
272 upButton-> setPixmap ( Resource::loadPixmap ( "up" )); 272 upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
273 upButton-> setFocusPolicy ( QWidget::NoFocus ); 273 upButton-> setFocusPolicy ( QWidget::NoFocus );
274 274
275 vbox-> addWidget ( upButton ); 275 vbox-> addWidget ( upButton );
276 276
277 downButton = new QPushButton ( this ); 277 downButton = new QPushButton ( this );
278 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 278 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
279 downButton-> setPixmap ( Resource::loadPixmap ( "down" )); 279 downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
280 downButton-> setFocusPolicy ( QWidget::NoFocus ); 280 downButton-> setFocusPolicy ( QWidget::NoFocus );
281 281
282 vbox-> addWidget ( downButton ); 282 vbox-> addWidget ( downButton );
283 283
284 volSlider = new QSlider ( this ); 284 volSlider = new QSlider ( this );
285 volSlider-> setRange ( 0, 100 ); 285 volSlider-> setRange ( 0, 100 );
286 volSlider-> setTickmarks ( QSlider::Both ); 286 volSlider-> setTickmarks ( QSlider::Both );
287 volSlider-> setTickInterval ( 20 ); 287 volSlider-> setTickInterval ( 20 );
288 volSlider-> setFocusPolicy ( QWidget::NoFocus ); 288 volSlider-> setFocusPolicy ( QWidget::NoFocus );
289 289
290 l = new QLabel ( this ); 290 l = new QLabel ( this );
291 l-> setPixmap ( QPixmap ( vol_xpm )); 291 l-> setPixmap ( QPixmap ( vol_xpm ));
292 292
293 grid-> addWidget ( l, 0, 1, AlignCenter ); 293 grid-> addWidget ( l, 0, 1, AlignCenter );
294 grid-> addWidget ( volSlider, 1, 1, AlignCenter ); 294 grid-> addWidget ( volSlider, 1, 1, AlignCenter );
295 295
296 volLed = new OLedBox ( green, this ); 296 volLed = new OLedBox ( green, this );
297 volLed-> setFocusPolicy ( QWidget::NoFocus ); 297 volLed-> setFocusPolicy ( QWidget::NoFocus );
298 volLed-> setFixedSize ( 16, 16 ); 298 volLed-> setFixedSize ( 16, 16 );
299 299
300 grid-> addWidget ( volLed, 2, 1, AlignCenter ); 300 grid-> addWidget ( volLed, 2, 1, AlignCenter );
301 301
302 QVBox *basstrebleBox = new QVBox( this ); 302 QVBox *basstrebleBox = new QVBox( this );
303 303
304 trebleSlider = new QSlider ( basstrebleBox ); 304 trebleSlider = new QSlider ( basstrebleBox );
305 trebleSlider-> setRange ( 0, 100 ); 305 trebleSlider-> setRange ( 0, 100 );
306 trebleSlider-> setTickmarks ( QSlider::Both ); 306 trebleSlider-> setTickmarks ( QSlider::Both );
307 trebleSlider-> setTickInterval ( 20 ); 307 trebleSlider-> setTickInterval ( 20 );
308 trebleSlider->setMaximumHeight( 40 ); 308 trebleSlider->setMaximumHeight( 40 );
309 trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); 309 trebleSlider-> setFocusPolicy ( QWidget::NoFocus );
310 310
311 bassSlider = new QSlider ( basstrebleBox ); 311 bassSlider = new QSlider ( basstrebleBox );
312 bassSlider-> setRange ( 0, 100 ); 312 bassSlider-> setRange ( 0, 100 );
313 bassSlider-> setTickmarks ( QSlider::Both ); 313 bassSlider-> setTickmarks ( QSlider::Both );
314 bassSlider-> setTickInterval ( 20 ); 314 bassSlider-> setTickInterval ( 20 );
315 bassSlider->setMaximumHeight( 40 ); 315 bassSlider->setMaximumHeight( 40 );
316 bassSlider-> setFocusPolicy ( QWidget::NoFocus ); 316 bassSlider-> setFocusPolicy ( QWidget::NoFocus );
317 317
318 QLabel *bassLabel = new QLabel ( this ); 318 QLabel *bassLabel = new QLabel ( this );
319 bassLabel-> setPixmap ( QPixmap ( bass_xpm )); 319 bassLabel-> setPixmap ( QPixmap ( bass_xpm ));
320 320
321 QLabel *trebleLabel = new QLabel( this ); 321 QLabel *trebleLabel = new QLabel( this );
322 trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); 322 trebleLabel->setPixmap( QPixmap ( treble_xpm ) );
323 323
324 grid->addWidget( trebleLabel, 0, 4, AlignCenter ); 324 grid->addWidget( trebleLabel, 0, 4, AlignCenter );
325 grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); 325 grid->addWidget( basstrebleBox, 1, 4, AlignCenter );
326 grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); 326 grid-> addWidget ( bassLabel, 2, 4, AlignCenter );
327 327
328 if ( !has_bass ) { 328 if ( !has_bass ) {
329 bassSlider->hide(); 329 bassSlider->hide();
330 bassLabel->hide(); 330 bassLabel->hide();
331 } 331 }
332 332
333 if ( !has_treble ) { 333 if ( !has_treble ) {
334 trebleSlider->hide(); 334 trebleSlider->hide();
335 trebleLabel->hide(); 335 trebleLabel->hide();
336 } 336 }
337 337
338 micSlider = new QSlider ( this ); 338 micSlider = new QSlider ( this );
339 micSlider-> setRange ( 0, 100 ); 339 micSlider-> setRange ( 0, 100 );
340 micSlider-> setTickmarks ( QSlider::Both ); 340 micSlider-> setTickmarks ( QSlider::Both );
341 micSlider-> setTickInterval ( 20 ); 341 micSlider-> setTickInterval ( 20 );
342 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 342 micSlider-> setFocusPolicy ( QWidget::NoFocus );
343 343
344 l = new QLabel ( this ); 344 l = new QLabel ( this );
345 l-> setPixmap ( QPixmap ( mic_xpm )); 345 l-> setPixmap ( QPixmap ( mic_xpm ));
346 346
347 grid-> addWidget ( l, 0, 2, AlignCenter ); 347 grid-> addWidget ( l, 0, 2, AlignCenter );
348 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 348 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
349 349
350 micLed = new OLedBox ( red, this ); 350 micLed = new OLedBox ( red, this );
351 micLed-> setFocusPolicy ( QWidget::NoFocus ); 351 micLed-> setFocusPolicy ( QWidget::NoFocus );
352 micLed-> setFixedSize ( 16, 16 ); 352 micLed-> setFixedSize ( 16, 16 );
353 353
354 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 354 grid-> addWidget ( micLed, 2, 2, AlignCenter );
355 355
356 alarmSlider = new QSlider ( this ); 356 alarmSlider = new QSlider ( this );
357 alarmSlider-> setRange ( 0, 100 ); 357 alarmSlider-> setRange ( 0, 100 );
358 alarmSlider-> setTickmarks ( QSlider::Both ); 358 alarmSlider-> setTickmarks ( QSlider::Both );
359 alarmSlider-> setTickInterval ( 20 ); 359 alarmSlider-> setTickInterval ( 20 );
360 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 360 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
361 361
362 QLabel *alarmLabel = new QLabel ( this ); 362 QLabel *alarmLabel = new QLabel ( this );
363 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 363 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
364 364
365 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 365 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
366 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 366 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
367 367
368 alarmLed = new OLedBox ( yellow, this ); 368 alarmLed = new OLedBox ( yellow, this );
369 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 369 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
370 alarmLed-> setFixedSize ( 16, 16 ); 370 alarmLed-> setFixedSize ( 16, 16 );
371 371
372 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 372 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
373 373
374 if ( !has_wav_alarm ) { 374 if ( !has_wav_alarm ) {
375 alarmSlider-> hide ( ); 375 alarmSlider-> hide ( );
376 alarmLabel-> hide ( ); 376 alarmLabel-> hide ( );
377 alarmLed-> hide ( ); 377 alarmLed-> hide ( );
378 } 378 }
379 379
380 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); 380 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft );
381 381
382 vbox = new QVBoxLayout ( ); 382 vbox = new QVBoxLayout ( );
383 vbox-> setSpacing ( 4 ); 383 vbox-> setSpacing ( 4 );
384 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); 384 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
385 385
386 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 386 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
387 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 387 tapBox-> setFocusPolicy ( QWidget::NoFocus );
388 388
389 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 389 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
390 390
391 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 391 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
392 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 392 keyBox-> setFocusPolicy ( QWidget::NoFocus );
393 393
394 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 394 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
395 395
396 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 396 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
397 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 397 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
398 398
399 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 399 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
400 400
401 if ( has_wav_alarm ) { 401 if ( has_wav_alarm ) {
402 alarmBox-> hide ( ); 402 alarmBox-> hide ( );
403 } 403 }
404 404
405 vbox-> addStretch ( 100 ); 405 vbox-> addStretch ( 100 );
406 406
407 setFixedSize ( sizeHint ( )); 407 setFixedSize ( sizeHint ( ));
408 setFocusPolicy ( QWidget::NoFocus ); 408 setFocusPolicy ( QWidget::NoFocus );
409 409
410 rateTimer = new QTimer( this ); 410 rateTimer = new QTimer( this );
411 connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); 411 connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone()));
412 412
413 connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); 413 connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
414 connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); 414 connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged()));
415 connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); 415 connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
416 connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); 416 connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged()));
417 417
418 connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); 418 connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int)));
419 connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); 419 connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int)));
420 connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); 420 connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int)));
421 connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); 421 connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int)));
422 connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); 422 connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int)));
423 423
424 424
425 connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); 425 connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool)));
426 connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); 426 connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool)));
427 connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); 427 connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
428 428
429 connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); 429 connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
430 connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); 430 connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool)));
431 connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); 431 connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool)));
432 432
433 // initialize variables 433 // initialize variables
434 434
435 readConfig ( true ); 435 readConfig ( true );
436 436
437 // initialize the config file, in case some entries are missing 437 // initialize the config file, in case some entries are missing
438 438
439 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 439 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
440 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); 440 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
441 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); 441 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
442 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 442 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
443 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 443 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
444 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 444 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
445 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 445 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
446 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 446 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
447 447
448 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 448 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
449 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 449 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
450} 450}
451 451
452bool VolumeControl::volMuted ( ) const 452bool VolumeControl::volMuted ( ) const
453{ 453{
454 return m_vol_muted; 454 return m_vol_muted;
455} 455}
456 456
457int VolumeControl::volPercent ( ) const 457int VolumeControl::volPercent ( ) const
458{ 458{
459 return m_vol_percent; 459 return m_vol_percent;
460} 460}
461 461
462void VolumeControl::keyPressEvent ( QKeyEvent *e ) 462void VolumeControl::keyPressEvent ( QKeyEvent *e )
463{ 463{
464 switch ( e-> key ( )) { 464 switch ( e-> key ( )) {
465 case Key_Up: 465 case Key_Up:
466 volSlider-> subtractStep ( ); 466 volSlider-> subtractStep ( );
467 break; 467 break;
468 case Key_Down: 468 case Key_Down:
469 volSlider-> addStep ( ); 469 volSlider-> addStep ( );
470 break; 470 break;
471 case Key_Space: 471 case Key_Space:
472 volLed-> toggle ( ); 472 volLed-> toggle ( );
473 break; 473 break;
474 case Key_Escape: 474 case Key_Escape:
475 hide ( ); 475 hide ( );
476 break; 476 break;
477 } 477 }
478} 478}
479 479
480void VolumeControl::buttonChanged ( ) 480void VolumeControl::buttonChanged ( )
481{ 481{
482 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 482 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
483 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 483 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
484 // called at all when a button is pressed for a time 484 // called at all when a button is pressed for a time
485 // shorter than RATE_TIMER_INTERVAL. 485 // shorter than RATE_TIMER_INTERVAL.
486 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 486 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
487 } 487 }
488 else 488 else
489 rateTimer-> stop ( ); 489 rateTimer-> stop ( );
490} 490}
491 491
492void VolumeControl::rateTimerDone ( ) 492void VolumeControl::rateTimerDone ( )
493{ 493{
494 if ( upButton-> isDown ( )) 494 if ( upButton-> isDown ( ))
495 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 495 volSlider-> setValue ( volSlider-> value ( ) - 2 );
496 else // if ( downButton-> isDown ( )) 496 else // if ( downButton-> isDown ( ))
497 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 497 volSlider-> setValue ( volSlider-> value ( ) + 2 );
498} 498}
499 499
500void VolumeControl::show ( bool /*showMic*/ ) 500void VolumeControl::show ( bool /*showMic*/ )
501{ 501{
502 readConfig ( ); 502 readConfig ( );
503 503
504 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 504 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
505 505
506 int w = sizeHint ( ). width ( ); 506 int w = sizeHint ( ). width ( );
507 int x = curPos.x ( ) - ( w / 2 ); 507 int x = curPos.x ( ) - ( w / 2 );
508 508
509 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 509 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
510 x = QPEApplication::desktop ( )-> width ( ) - w; 510 x = QPEApplication::desktop ( )-> width ( ) - w;
511 511
512 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 512 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
513 QFrame::show ( ); 513 QFrame::show ( );
514 514
515} 515}
516 516
517void VolumeControl::readConfig ( bool force ) 517void VolumeControl::readConfig ( bool force )
518{ 518{
519 Config cfg ( "qpe" ); 519 Config cfg ( "qpe" );
520 cfg. setGroup ( "Volume" ); 520 cfg. setGroup ( "Volume" );
521 521
522 int old_vp = m_vol_percent; 522 int old_vp = m_vol_percent;
523 int old_mp = m_mic_percent; 523 int old_mp = m_mic_percent;
524 int old_bass = m_bass_percent; 524 int old_bass = m_bass_percent;
525 int old_treble = m_treble_percent; 525 int old_treble = m_treble_percent;
526 bool old_vm = m_vol_muted; 526 bool old_vm = m_vol_muted;
527 bool old_mm = m_mic_muted; 527 bool old_mm = m_mic_muted;
528 bool old_sk = m_snd_key; 528 bool old_sk = m_snd_key;
529 bool old_st = m_snd_touch; 529 bool old_st = m_snd_touch;
530 bool old_sa = m_snd_alarm; 530 bool old_sa = m_snd_alarm;
531 int old_ap = m_alarm_percent; 531 int old_ap = m_alarm_percent;
532 532
533 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 533 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
534 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 534 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
535 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); 535 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
536 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); 536 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
537 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 537 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
538 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 538 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
539 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 539 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
540 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 540 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
541 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 541 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
542 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 542 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
543 543
544 if ( force || ( m_vol_percent != old_vp )) 544 if ( force || ( m_vol_percent != old_vp ))
545 volSlider-> setValue ( 100 - m_vol_percent ); 545 volSlider-> setValue ( 100 - m_vol_percent );
546 if ( force || ( m_mic_percent != old_mp )) 546 if ( force || ( m_mic_percent != old_mp ))
547 micSlider-> setValue ( 100 - m_mic_percent ); 547 micSlider-> setValue ( 100 - m_mic_percent );
548 if ( force || ( m_alarm_percent != old_ap )) 548 if ( force || ( m_alarm_percent != old_ap ))
549 alarmSlider-> setValue ( 100 - m_alarm_percent ); 549 alarmSlider-> setValue ( 100 - m_alarm_percent );
550 if ( force || ( m_bass_percent != old_bass )) 550 if ( force || ( m_bass_percent != old_bass ))
551 bassSlider-> setValue ( 100 - m_bass_percent ); 551 bassSlider-> setValue ( 100 - m_bass_percent );
552 if ( force || ( m_treble_percent != old_treble )) 552 if ( force || ( m_treble_percent != old_treble ))
553 trebleSlider-> setValue ( 100 - m_treble_percent ); 553 trebleSlider-> setValue ( 100 - m_treble_percent );
554 554
555 555
556 if ( force || ( m_vol_muted != old_vm )) 556 if ( force || ( m_vol_muted != old_vm ))
557 volLed-> setOn ( !m_vol_muted ); 557 volLed-> setOn ( !m_vol_muted );
558 if ( force || ( m_mic_muted != old_mm )) 558 if ( force || ( m_mic_muted != old_mm ))
559 micLed-> setOn ( !m_mic_muted ); 559 micLed-> setOn ( !m_mic_muted );
560 if ( force || ( m_snd_alarm != old_sa )) 560 if ( force || ( m_snd_alarm != old_sa ))
561 alarmLed-> setOn ( m_snd_alarm ); 561 alarmLed-> setOn ( m_snd_alarm );
562 562
563 if ( force || ( m_snd_key != old_sk )) 563 if ( force || ( m_snd_key != old_sk ))
564 keyBox-> setChecked ( m_snd_key ); 564 keyBox-> setChecked ( m_snd_key );
565 if ( force || ( m_snd_touch != old_st )) 565 if ( force || ( m_snd_touch != old_st ))
566 tapBox-> setChecked ( m_snd_touch ); 566 tapBox-> setChecked ( m_snd_touch );
567 if ( force || ( m_snd_alarm != old_sa )) 567 if ( force || ( m_snd_alarm != old_sa ))
568 alarmBox-> setChecked ( m_snd_alarm ); 568 alarmBox-> setChecked ( m_snd_alarm );
569} 569}
570 570
571 571
572void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) 572void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
573{ 573{
574 int prevVol = m_vol_percent; 574 int prevVol = m_vol_percent;
575 bool prevMute = m_vol_muted; 575 bool prevMute = m_vol_muted;
576 576
577 readConfig ( ); 577 readConfig ( );
578 578
579 // Handle case where muting it toggled 579 // Handle case where muting it toggled
580 if ( m_vol_muted != prevMute ) 580 if ( m_vol_muted != prevMute )
581 m_icon-> redraw ( true ); 581 m_icon-> redraw ( true );
582 else if ( prevVol != m_vol_percent ) // Avoid over repainting 582 else if ( prevVol != m_vol_percent ) // Avoid over repainting
583 m_icon-> redraw ( false ); 583 m_icon-> redraw ( false );
584} 584}
585 585
586void VolumeControl::micChanged ( bool nowMuted ) 586void VolumeControl::micChanged ( bool nowMuted )
587{ 587{
588 if ( !nowMuted ) 588 if ( !nowMuted )
589 readConfig ( ); 589 readConfig ( );
590 m_mic_muted = nowMuted; 590 m_mic_muted = nowMuted;
591} 591}
592 592
593void VolumeControl::screenTapToggled ( bool b ) 593void VolumeControl::screenTapToggled ( bool b )
594{ 594{
595 m_snd_touch = b; 595 m_snd_touch = b;
596 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); 596 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
597} 597}
598 598
599void VolumeControl::keyClickToggled ( bool b ) 599void VolumeControl::keyClickToggled ( bool b )
600{ 600{
601 m_snd_key = b; 601 m_snd_key = b;
602 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); 602 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
603} 603}
604 604
605void VolumeControl::alarmSoundToggled ( bool b ) 605void VolumeControl::alarmSoundToggled ( bool b )
606{ 606{
607 m_snd_alarm = b; 607 m_snd_alarm = b;
608 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 608 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
609} 609}
610 610
611void VolumeControl::volMuteToggled ( bool b ) 611void VolumeControl::volMuteToggled ( bool b )
612{ 612{
613 m_vol_muted = !b; 613 m_vol_muted = !b;
614 614
615 m_icon-> redraw ( true ); 615 m_icon-> redraw ( true );
616 616
617 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 617 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
618} 618}
619 619
620void VolumeControl::micMuteToggled ( bool b ) 620void VolumeControl::micMuteToggled ( bool b )
621{ 621{
622 m_mic_muted = !b; 622 m_mic_muted = !b;
623 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 623 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
624} 624}
625 625
626 626
627void VolumeControl::volMoved ( int percent ) 627void VolumeControl::volMoved ( int percent )
628{ 628{
629 m_vol_percent = 100 - percent; 629 m_vol_percent = 100 - percent;
630 630
631 // clamp volume percent to be between 0 and 100 631 // clamp volume percent to be between 0 and 100
632 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); 632 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
633 // repaint just the little volume rectangle 633 // repaint just the little volume rectangle
634 m_icon-> redraw ( false ); 634 m_icon-> redraw ( false );
635 635
636 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 636 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
637} 637}
638 638
639void VolumeControl::micMoved ( int percent ) 639void VolumeControl::micMoved ( int percent )
640{ 640{
641 m_mic_percent = 100 - percent; 641 m_mic_percent = 100 - percent;
642 642
643 // clamp volume percent to be between 0 and 100 643 // clamp volume percent to be between 0 and 100
644 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); 644 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
645 645
646 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); 646 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
647} 647}
648 648
649void VolumeControl::alarmMoved ( int percent ) 649void VolumeControl::alarmMoved ( int percent )
650{ 650{
651 m_alarm_percent = 100 - percent; 651 m_alarm_percent = 100 - percent;
652 652
653 // clamp volume percent to be between 0 and 100 653 // clamp volume percent to be between 0 and 100
654 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); 654 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
655 655
656 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 656 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
657} 657}
658 658
659 659
660void VolumeControl::bassMoved ( int percent ) 660void VolumeControl::bassMoved ( int percent )
661{ 661{
662 m_bass_percent = 100 - percent; 662 m_bass_percent = 100 - percent;
663 663
664 // clamp bass percent to be between 0 and 100 664 // clamp bass percent to be between 0 and 100
665 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); 665 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent );
666 666
667 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); 667 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
668} 668}
669 669
670 670
671 671
672void VolumeControl::trebleMoved ( int percent ) 672void VolumeControl::trebleMoved ( int percent )
673{ 673{
674 m_treble_percent = 100 - percent; 674 m_treble_percent = 100 - percent;
675 675
676 // clamp treble percent to be between 0 and 100 676 // clamp treble percent to be between 0 and 100
677 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); 677 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent );
678 678
679 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); 679 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
680} 680}
681 681
682 682
683 683
684void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 684void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
685{ 685{
686 Config cfg ( "qpe" ); 686 Config cfg ( "qpe" );
687 cfg. setGroup ( "Volume" ); 687 cfg. setGroup ( "Volume" );
688 cfg. writeEntry ( entry, val ); 688 cfg. writeEntry ( entry, val );
689// cfg. write ( ); 689// cfg. write ( );
690 690
691#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 691#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
692 switch ( upd ) { 692 switch ( upd ) {
693 case UPD_Vol: { 693 case UPD_Vol: {
694 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 694 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
695 break; 695 break;
696 } 696 }
697 case UPD_Mic: { 697 case UPD_Mic: {
698 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 698 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
699 break; 699 break;
700 } 700 }
701 case UPD_Bass: { 701 case UPD_Bass: {
702 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; 702 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
703 break; 703 break;
704 } 704 }
705 case UPD_Treble: { 705 case UPD_Treble: {
706 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; 706 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
707 break; 707 break;
708 } 708 }
709 709
710 case UPD_None: 710 case UPD_None:
711 break; 711 break;
712 } 712 }
713#endif 713#endif
714} 714}
715 715
716//=========================================================================== 716//===========================================================================
717 717
718VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 718VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
719 : QWidget( parent, name ) 719 : QWidget( parent, name )
720{ 720{
721 setFixedWidth ( AppLnk::smallIconSize() ); 721 setFixedWidth ( AppLnk::smallIconSize() );
722 setFixedHeight ( AppLnk::smallIconSize()+4 ); 722 setFixedHeight ( AppLnk::smallIconSize()+4 );
723 723
724 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); 724 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
725 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); 725 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
726 726
727 connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); 727 connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool)));
728 connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); 728 connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool)));
729} 729}
730 730
731VolumeApplet::~VolumeApplet() 731VolumeApplet::~VolumeApplet()
732{ 732{
733 delete m_pixmap; 733 delete m_pixmap;
734} 734}
735 735
736int VolumeApplet::position() 736int VolumeApplet::position()
737{ 737{
738 return 6; 738 return 6;
739} 739}
740 740
741void VolumeApplet::mousePressEvent ( QMouseEvent * ) 741void VolumeApplet::mousePressEvent ( QMouseEvent * )
742{ 742{
743 if ( m_dialog-> isVisible ( )) 743 if ( m_dialog-> isVisible ( ))
744 m_dialog-> hide ( ); 744 m_dialog-> hide ( );
745 else 745 else
746 m_dialog-> show ( true ); 746 m_dialog-> show ( true );
747} 747}
748 748
749void VolumeApplet::redraw ( bool all ) 749void VolumeApplet::redraw ( bool all )
750{ 750{
751 if ( all ) 751 if ( all )
752 repaint ( true ); 752 repaint ( true );
753 else 753 else
754 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 754 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
755} 755}
756 756
757 757
758void VolumeApplet::paintEvent ( QPaintEvent * ) 758void VolumeApplet::paintEvent ( QPaintEvent * )
759{ 759{
760 QPainter p ( this ); 760 QPainter p ( this );
761 761
762 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); 762 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap );
763 p. setPen ( darkGray ); 763 p. setPen ( darkGray );
764 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 764 p. drawRect ( 1, height() - 4, width() - 2, 4 );
765 765
766 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; 766 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
767 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 767 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
768 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 768 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
769 769
770 if ( m_dialog-> volMuted ( )) { 770 if ( m_dialog-> volMuted ( )) {
771 p. setPen ( red ); 771 p. setPen ( red );
772 p. drawLine ( 1, 2, width() - 2, height() - 5 ); 772 p. drawLine ( 1, 2, width() - 2, height() - 5 );
773 p. drawLine ( 1, 3, width() - 2, height() - 4 ); 773 p. drawLine ( 1, 3, width() - 2, height() - 4 );
774 p. drawLine ( width() - 2, 2, 1, height() - 5 ); 774 p. drawLine ( width() - 2, 2, 1, height() - 5 );
775 p. drawLine ( width() - 2, 3, 1, height() - 4 ); 775 p. drawLine ( width() - 2, 3, 1, height() - 4 );
776 } 776 }
777} 777}
778 778
779 779
780EXPORT_OPIE_APPLET_v1( VolumeApplet ) 780EXPORT_OPIE_APPLET_v1( VolumeApplet )
diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro
index a76bafb..e118dbd 100644
--- a/core/applets/volumeapplet/volumeapplet.pro
+++ b/core/applets/volumeapplet/volumeapplet.pro
@@ -1,13 +1,14 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt plugin warn_on 2 CONFIG += qt plugin warn_on
3 HEADERS = volume.h oledbox.h 3 HEADERS = volume.h oledbox.h
4 SOURCES = volume.cpp oledbox.cpp 4 #SOURCES= volume.cpp oledbox.cpp
5 SOURCES = volume.cpp
5 TARGET = volumeapplet 6 TARGET = volumeapplet
6 DESTDIR = $(OPIEDIR)/plugins/applets 7 DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 8INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += 9DEPENDPATH +=
9LIBS += -lqpe -lopiecore2 10LIBS += -lqpe -lopiecore2
10 VERSION = 1.0.0 11 VERSION = 1.0.0
11 12
12include( $(OPIEDIR)/include.pro ) 13include( $(OPIEDIR)/include.pro )
13target.path = $$prefix/plugins/applets 14target.path = $$prefix/plugins/applets