author | llornkcor <llornkcor> | 2002-05-23 02:03:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-23 02:03:12 (UTC) |
commit | d295491048567c8424643b983a21dc503857d91a (patch) (unidiff) | |
tree | 54cc32b49eef8518ffbeeacb99ffcbb35ec60769 | |
parent | 7cec3bc3d3b8945e80c9171b9173d3d2dbdd2eaf (diff) | |
download | opie-d295491048567c8424643b983a21dc503857d91a.zip opie-d295491048567c8424643b983a21dc503857d91a.tar.gz opie-d295491048567c8424643b983a21dc503857d91a.tar.bz2 |
new sound config
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 14 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 168 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 9 |
3 files changed, 130 insertions, 61 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index c27050d..7cc4062 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -1,514 +1,512 @@ | |||
1 | /************************************************************************************ | 1 | /************************************************************************************ |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | ************************************************************************************/ | 11 | ************************************************************************************/ |
12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> | 12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> |
13 | /* | 13 | /* |
14 | * $Id$ | 14 | * $Id$ |
15 | */ | 15 | */ |
16 | // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> | 16 | // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> |
17 | #include <sys/utsname.h> | 17 | #include <sys/utsname.h> |
18 | #include <sys/time.h> | 18 | #include <sys/time.h> |
19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
20 | #include <unistd.h> | 20 | #include <unistd.h> |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <sys/stat.h> | 22 | #include <sys/stat.h> |
23 | #include <fcntl.h> | 23 | #include <fcntl.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
25 | #include <linux/soundcard.h> | 25 | #include <linux/soundcard.h> |
26 | 26 | ||
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | 30 | ||
31 | typedef struct _waveheader { | 31 | typedef struct _waveheader { |
32 | u_long main_chunk; /* 'RIFF' */ | 32 | u_long main_chunk; /* 'RIFF' */ |
33 | u_long length; /* filelen */ | 33 | u_long length; /* filelen */ |
34 | u_long chunk_type; /* 'WAVE' */ | 34 | u_long chunk_type; /* 'WAVE' */ |
35 | u_long sub_chunk; /* 'fmt ' */ | 35 | u_long sub_chunk; /* 'fmt ' */ |
36 | u_long sc_len; /* length of sub_chunk, =16 | 36 | u_long sc_len; /* length of sub_chunk, =16 |
37 | (chunckSize) format len */ | 37 | (chunckSize) format len */ |
38 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 38 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
39 | 39 | ||
40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ | 43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ |
44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
45 | 45 | ||
46 | u_long data_chunk; /* 'data' */ | 46 | u_long data_chunk; /* 'data' */ |
47 | 47 | ||
48 | u_long data_length;/* samplecount */ | 48 | u_long data_length;/* samplecount */ |
49 | } WaveHeader; | 49 | } WaveHeader; |
50 | 50 | ||
51 | #define RIFF 0x46464952 | 51 | #define RIFF 0x46464952 |
52 | #define WAVE 0x45564157 | 52 | #define WAVE 0x45564157 |
53 | #define FMT 0x20746D66 | 53 | #define FMT 0x20746D66 |
54 | #define DATA 0x61746164 | 54 | #define DATA 0x61746164 |
55 | #define PCM_CODE 1 | 55 | #define PCM_CODE 1 |
56 | #define WAVE_MONO 1 | 56 | #define WAVE_MONO 1 |
57 | #define WAVE_STEREO 2 | 57 | #define WAVE_STEREO 2 |
58 | 58 | ||
59 | #include "vmemo.h" | 59 | #include "vmemo.h" |
60 | 60 | ||
61 | #include <qpe/qpeapplication.h> | 61 | #include <qpe/qpeapplication.h> |
62 | #include <qpe/resource.h> | 62 | #include <qpe/resource.h> |
63 | #include <qpe/config.h> | 63 | #include <qpe/config.h> |
64 | 64 | ||
65 | #include <qpainter.h> | 65 | #include <qpainter.h> |
66 | #include <qdatetime.h> | 66 | #include <qdatetime.h> |
67 | #include <qregexp.h> | 67 | #include <qregexp.h> |
68 | #include <qsound.h> | 68 | #include <qsound.h> |
69 | #include <qfile.h> | 69 | #include <qfile.h> |
70 | #include <qmessagebox.h> | 70 | #include <qmessagebox.h> |
71 | 71 | ||
72 | int seq = 0; | 72 | int seq = 0; |
73 | 73 | ||
74 | /* XPM */ | 74 | /* XPM */ |
75 | static char * vmemo_xpm[] = { | 75 | static char * vmemo_xpm[] = { |
76 | "16 16 102 2", | 76 | "16 16 102 2", |
77 | " c None", | 77 | " c None", |
78 | ". c #60636A", | 78 | ". c #60636A", |
79 | "+ c #6E6E72", | 79 | "+ c #6E6E72", |
80 | "@ c #68696E", | 80 | "@ c #68696E", |
81 | "# c #4D525C", | 81 | "# c #4D525C", |
82 | "$ c #6B6C70", | 82 | "$ c #6B6C70", |
83 | "% c #E3E3E8", | 83 | "% c #E3E3E8", |
84 | "& c #EEEEF2", | 84 | "& c #EEEEF2", |
85 | "* c #EAEAEF", | 85 | "* c #EAEAEF", |
86 | "= c #CACAD0", | 86 | "= c #CACAD0", |
87 | "- c #474A51", | 87 | "- c #474A51", |
88 | "; c #171819", | 88 | "; c #171819", |
89 | "> c #9B9B9F", | 89 | "> c #9B9B9F", |
90 | ", c #EBEBF0", | 90 | ", c #EBEBF0", |
91 | "' c #F4F4F7", | 91 | "' c #F4F4F7", |
92 | ") c #F1F1F5", | 92 | ") c #F1F1F5", |
93 | "! c #DEDEE4", | 93 | "! c #DEDEE4", |
94 | "~ c #57575C", | 94 | "~ c #57575C", |
95 | "{ c #010101", | 95 | "{ c #010101", |
96 | "] c #A2A2A6", | 96 | "] c #A2A2A6", |
97 | "^ c #747477", | 97 | "^ c #747477", |
98 | "/ c #B5B5B8", | 98 | "/ c #B5B5B8", |
99 | "( c #AEAEB2", | 99 | "( c #AEAEB2", |
100 | "_ c #69696D", | 100 | "_ c #69696D", |
101 | ": c #525256", | 101 | ": c #525256", |
102 | "< c #181C24", | 102 | "< c #181C24", |
103 | "[ c #97979B", | 103 | "[ c #97979B", |
104 | "} c #A7A7AC", | 104 | "} c #A7A7AC", |
105 | "| c #B0B0B4", | 105 | "| c #B0B0B4", |
106 | "1 c #C8C8D1", | 106 | "1 c #C8C8D1", |
107 | "2 c #75757B", | 107 | "2 c #75757B", |
108 | "3 c #46464A", | 108 | "3 c #46464A", |
109 | "4 c #494A4F", | 109 | "4 c #494A4F", |
110 | "5 c #323234", | 110 | "5 c #323234", |
111 | "6 c #909095", | 111 | "6 c #909095", |
112 | "7 c #39393B", | 112 | "7 c #39393B", |
113 | "8 c #757578", | 113 | "8 c #757578", |
114 | "9 c #87878E", | 114 | "9 c #87878E", |
115 | "0 c #222224", | 115 | "0 c #222224", |
116 | "a c #414144", | 116 | "a c #414144", |
117 | "b c #6A6A6E", | 117 | "b c #6A6A6E", |
118 | "c c #020C16", | 118 | "c c #020C16", |
119 | "d c #6B6B6F", | 119 | "d c #6B6B6F", |
120 | "e c #68686D", | 120 | "e c #68686D", |
121 | "f c #5B5B60", | 121 | "f c #5B5B60", |
122 | "g c #8A8A8F", | 122 | "g c #8A8A8F", |
123 | "h c #6B6B6E", | 123 | "h c #6B6B6E", |
124 | "i c #ADADB2", | 124 | "i c #ADADB2", |
125 | "j c #828289", | 125 | "j c #828289", |
126 | "k c #3E3E41", | 126 | "k c #3E3E41", |
127 | "l c #CFCFD7", | 127 | "l c #CFCFD7", |
128 | "m c #4C4C50", | 128 | "m c #4C4C50", |
129 | "n c #000000", | 129 | "n c #000000", |
130 | "o c #66666A", | 130 | "o c #66666A", |
131 | "p c #505054", | 131 | "p c #505054", |
132 | "q c #838388", | 132 | "q c #838388", |
133 | "r c #A1A1A7", | 133 | "r c #A1A1A7", |
134 | "s c #A9A9AE", | 134 | "s c #A9A9AE", |
135 | "t c #A8A8B0", | 135 | "t c #A8A8B0", |
136 | "u c #5E5E63", | 136 | "u c #5E5E63", |
137 | "v c #3A3A3E", | 137 | "v c #3A3A3E", |
138 | "w c #BDBDC6", | 138 | "w c #BDBDC6", |
139 | "x c #59595E", | 139 | "x c #59595E", |
140 | "y c #76767C", | 140 | "y c #76767C", |
141 | "z c #373738", | 141 | "z c #373738", |
142 | "A c #717174", | 142 | "A c #717174", |
143 | "B c #727278", | 143 | "B c #727278", |
144 | "C c #1C1C1E", | 144 | "C c #1C1C1E", |
145 | "D c #3C3C3F", | 145 | "D c #3C3C3F", |
146 | "E c #ADADB6", | 146 | "E c #ADADB6", |
147 | "F c #54555A", | 147 | "F c #54555A", |
148 | "G c #8B8C94", | 148 | "G c #8B8C94", |
149 | "H c #5A5A5F", | 149 | "H c #5A5A5F", |
150 | "I c #BBBBC3", | 150 | "I c #BBBBC3", |
151 | "J c #C4C4CB", | 151 | "J c #C4C4CB", |
152 | "K c #909098", | 152 | "K c #909098", |
153 | "L c #737379", | 153 | "L c #737379", |
154 | "M c #343437", | 154 | "M c #343437", |
155 | "N c #8F8F98", | 155 | "N c #8F8F98", |
156 | "O c #000407", | 156 | "O c #000407", |
157 | "P c #2D3137", | 157 | "P c #2D3137", |
158 | "Q c #B0B1BC", | 158 | "Q c #B0B1BC", |
159 | "R c #3B3C40", | 159 | "R c #3B3C40", |
160 | "S c #6E6E74", | 160 | "S c #6E6E74", |
161 | "T c #95959C", | 161 | "T c #95959C", |
162 | "U c #74747A", | 162 | "U c #74747A", |
163 | "V c #1D1D1E", | 163 | "V c #1D1D1E", |
164 | "W c #91929A", | 164 | "W c #91929A", |
165 | "X c #42444A", | 165 | "X c #42444A", |
166 | "Y c #22282E", | 166 | "Y c #22282E", |
167 | "Z c #B0B2BC", | 167 | "Z c #B0B2BC", |
168 | "` c #898A90", | 168 | "` c #898A90", |
169 | " . c #65656A", | 169 | " . c #65656A", |
170 | ".. c #999AA2", | 170 | ".. c #999AA2", |
171 | "+. c #52535A", | 171 | "+. c #52535A", |
172 | "@. c #151B21", | 172 | "@. c #151B21", |
173 | "#. c #515257", | 173 | "#. c #515257", |
174 | "$. c #B5B5BE", | 174 | "$. c #B5B5BE", |
175 | "%. c #616167", | 175 | "%. c #616167", |
176 | "&. c #1A1D22", | 176 | "&. c #1A1D22", |
177 | "*. c #000713", | 177 | "*. c #000713", |
178 | "=. c #1F1F21", | 178 | "=. c #1F1F21", |
179 | " ", | 179 | " ", |
180 | " . + @ # ", | 180 | " . + @ # ", |
181 | " $ % & * = - ", | 181 | " $ % & * = - ", |
182 | " ; > , ' ) ! ~ ", | 182 | " ; > , ' ) ! ~ ", |
183 | " { ] ^ / ( _ : ", | 183 | " { ] ^ / ( _ : ", |
184 | " < [ } | 1 2 3 ", | 184 | " < [ } | 1 2 3 ", |
185 | " 4 5 6 7 8 9 0 a b c ", | 185 | " 4 5 6 7 8 9 0 a b c ", |
186 | " d e f g h i j 3 k l m n ", | 186 | " d e f g h i j 3 k l m n ", |
187 | " o p q r s t u v w n ", | 187 | " o p q r s t u v w n ", |
188 | " o x y z A B C D E n ", | 188 | " o x y z A B C D E n ", |
189 | " F G H I J K L M N O ", | 189 | " F G H I J K L M N O ", |
190 | " P Q R S T U V W X ", | 190 | " P Q R S T U V W X ", |
191 | " Y Z ` b ...+. ", | 191 | " Y Z ` b ...+. ", |
192 | " @.#.$.%.&. ", | 192 | " @.#.$.%.&. ", |
193 | " *.B =. ", | 193 | " *.B =. ", |
194 | " n n n n n n n n n "}; | 194 | " n n n n n n n n n "}; |
195 | 195 | ||
196 | 196 | ||
197 | VMemo::VMemo( QWidget *parent, const char *_name ) | 197 | VMemo::VMemo( QWidget *parent, const char *_name ) |
198 | : QWidget( parent, _name ) | 198 | : QWidget( parent, _name ) |
199 | { | 199 | { |
200 | setFixedHeight( 18 ); | 200 | setFixedHeight( 18 ); |
201 | setFixedWidth( 14 ); | 201 | setFixedWidth( 14 ); |
202 | 202 | ||
203 | recording = FALSE; | 203 | recording = FALSE; |
204 | 204 | ||
205 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 205 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
206 | if (uname(&name) != -1) { | 206 | if (uname(&name) != -1) { |
207 | QString release=name.release; | 207 | QString release=name.release; |
208 | Config vmCfg("VMemo"); | 208 | Config vmCfg("VMemo"); |
209 | vmCfg.setGroup("Defaults"); | 209 | vmCfg.setGroup("Defaults"); |
210 | int toggleKey = vmCfg.readNumEntry("toggleKey", -1); | 210 | int toggleKey = vmCfg.readNumEntry("toggleKey", -1); |
211 | 211 | ||
212 | if(release.find("embedix",0,TRUE) !=-1) | 212 | if(release.find("embedix",0,TRUE) !=-1) |
213 | systemZaurus=TRUE; | 213 | systemZaurus=TRUE; |
214 | else | 214 | else |
215 | systemZaurus=FALSE; | 215 | systemZaurus=FALSE; |
216 | 216 | ||
217 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 217 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
218 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 218 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
219 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 219 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
220 | 220 | ||
221 | if( toggleKey != -1 ) { | 221 | if( toggleKey != -1 ) { |
222 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 222 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
223 | // e << 4096; // Key_Escape | 223 | // e << 4096; // Key_Escape |
224 | // e << Key_F5; //4148 | 224 | // e << Key_F5; //4148 |
225 | e << toggleKey; | 225 | e << toggleKey; |
226 | e << QString("QPE/VMemo"); | 226 | e << QString("QPE/VMemo"); |
227 | e << QString("toggleRecord()"); | 227 | e << QString("toggleRecord()"); |
228 | } | 228 | } |
229 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 229 | if( vmCfg.readNumEntry("hideIcon",0) == 1) |
230 | hide(); | 230 | hide(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | VMemo::~VMemo() | 234 | VMemo::~VMemo() |
235 | { | 235 | { |
236 | } | 236 | } |
237 | 237 | ||
238 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 238 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
239 | { | 239 | { |
240 | QDataStream stream( data, IO_ReadOnly ); | 240 | QDataStream stream( data, IO_ReadOnly ); |
241 | if (msg == "toggleRecord()") { | 241 | if (msg == "toggleRecord()") { |
242 | if (recording) { | 242 | if (recording) { |
243 | fromToggle = TRUE; | 243 | fromToggle = TRUE; |
244 | stopRecording(); | 244 | stopRecording(); |
245 | } else { | 245 | } else { |
246 | fromToggle = TRUE; | 246 | fromToggle = TRUE; |
247 | startRecording(); | 247 | startRecording(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | void VMemo::paintEvent( QPaintEvent* ) | 252 | void VMemo::paintEvent( QPaintEvent* ) |
253 | { | 253 | { |
254 | QPainter p(this); | 254 | QPainter p(this); |
255 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 255 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void VMemo::mousePressEvent( QMouseEvent * ) | 258 | void VMemo::mousePressEvent( QMouseEvent * ) |
259 | { | 259 | { |
260 | startRecording(); | 260 | startRecording(); |
261 | } | 261 | } |
262 | 262 | ||
263 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 263 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
264 | { | 264 | { |
265 | stopRecording(); | 265 | stopRecording(); |
266 | } | 266 | } |
267 | 267 | ||
268 | bool VMemo::startRecording() { | 268 | bool VMemo::startRecording() { |
269 | 269 | ||
270 | if ( recording) | 270 | if ( recording) |
271 | return FALSE;; | 271 | return FALSE;; |
272 | Config config( "Sound" ); | 272 | Config config( "Vmemo" ); |
273 | config.setGroup( "System" ); | 273 | config.setGroup( "System" ); |
274 | useAlerts = config.readBoolEntry("Alert"); | 274 | useAlerts = config.readBoolEntry("Alert"); |
275 | 275 | ||
276 | // if(useAlerts) | 276 | // if(useAlerts) |
277 | // QMessageBox::message("VMemo","Really Record?");//) ==1) | 277 | // QMessageBox::message("VMemo","Really Record?");//) ==1) |
278 | // return; | 278 | // return; |
279 | // } else { | 279 | // } else { |
280 | if (!systemZaurus ) | 280 | if (!systemZaurus ) |
281 | QSound::play(Resource::findSound("vmemob")); | 281 | QSound::play(Resource::findSound("vmemob")); |
282 | // } | 282 | // } |
283 | qDebug("Start recording"); | 283 | qDebug("Start recording"); |
284 | recording = TRUE; | 284 | recording = TRUE; |
285 | if (openDSP() == -1) { | 285 | if (openDSP() == -1) { |
286 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); | 286 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); |
287 | recording = FALSE; | 287 | recording = FALSE; |
288 | return FALSE; | 288 | return FALSE; |
289 | } | 289 | } |
290 | 290 | ||
291 | Config vmCfg("VMemo"); | 291 | config.setGroup("Defaults"); |
292 | vmCfg.setGroup("Defaults"); | ||
293 | 292 | ||
294 | QDateTime dt = QDateTime::currentDateTime(); | 293 | QDateTime dt = QDateTime::currentDateTime(); |
295 | 294 | ||
296 | QString fName; | 295 | QString fName; |
297 | Config cfg( "Sound" ); | 296 | config.setGroup( "System" ); |
298 | cfg.setGroup( "System" ); | ||
299 | fName = QPEApplication::documentDir() ; | 297 | fName = QPEApplication::documentDir() ; |
300 | fileName = cfg.readEntry("RecLocation", fName); | 298 | fileName = config.readEntry("RecLocation", fName); |
301 | 299 | ||
302 | int s; | 300 | int s; |
303 | s=fileName.find(':'); | 301 | s=fileName.find(':'); |
304 | if(s) | 302 | if(s) |
305 | fileName=fileName.right(fileName.length()-s-2); | 303 | fileName=fileName.right(fileName.length()-s-2); |
306 | qDebug("filename will be "+fileName); | 304 | qDebug("filename will be "+fileName); |
307 | if( fileName.right(1).find('/') == -1) | 305 | if( fileName.right(1).find('/') == -1) |
308 | fileName+="/"; | 306 | fileName+="/"; |
309 | fName = "vm_"+ dt.toString()+ ".wav"; | 307 | fName = "vm_"+ dt.toString()+ ".wav"; |
310 | 308 | ||
311 | fileName+=fName; | 309 | fileName+=fName; |
312 | qDebug("filename is "+fileName); | 310 | qDebug("filename is "+fileName); |
313 | // No spaces in the filename | 311 | // No spaces in the filename |
314 | fileName.replace(QRegExp("'"),""); | 312 | fileName.replace(QRegExp("'"),""); |
315 | fileName.replace(QRegExp(" "),"_"); | 313 | fileName.replace(QRegExp(" "),"_"); |
316 | fileName.replace(QRegExp(":"),"."); | 314 | fileName.replace(QRegExp(":"),"."); |
317 | fileName.replace(QRegExp(","),""); | 315 | fileName.replace(QRegExp(","),""); |
318 | 316 | ||
319 | if(openWAV(fileName.latin1()) == -1) { | 317 | if(openWAV(fileName.latin1()) == -1) { |
320 | QString err("Could not open the output file\n"); | 318 | QString err("Could not open the output file\n"); |
321 | err += fileName; | 319 | err += fileName; |
322 | QMessageBox::critical(0, "VMemo", err, "Abort"); | 320 | QMessageBox::critical(0, "VMemo", err, "Abort"); |
323 | close(dsp); | 321 | close(dsp); |
324 | return FALSE; | 322 | return FALSE; |
325 | } | 323 | } |
326 | 324 | ||
327 | QArray<int> cats(1); | 325 | QArray<int> cats(1); |
328 | cats[0] = vmCfg.readNumEntry("Category", 0); | 326 | cats[0] = config.readNumEntry("Category", 0); |
329 | 327 | ||
330 | QString dlName("vm_"); | 328 | QString dlName("vm_"); |
331 | dlName += dt.toString(); | 329 | dlName += dt.toString(); |
332 | DocLnk l; | 330 | DocLnk l; |
333 | l.setFile(fileName); | 331 | l.setFile(fileName); |
334 | l.setName(dlName); | 332 | l.setName(dlName); |
335 | l.setType("audio/x-wav"); | 333 | l.setType("audio/x-wav"); |
336 | l.setCategories(cats); | 334 | l.setCategories(cats); |
337 | l.writeLink(); | 335 | l.writeLink(); |
338 | 336 | ||
339 | record(); | 337 | record(); |
340 | return TRUE; | 338 | return TRUE; |
341 | } | 339 | } |
342 | 340 | ||
343 | void VMemo::stopRecording() { | 341 | void VMemo::stopRecording() { |
344 | recording = FALSE; | 342 | recording = FALSE; |
345 | } | 343 | } |
346 | 344 | ||
347 | int VMemo::openDSP() | 345 | int VMemo::openDSP() |
348 | { | 346 | { |
349 | Config cfg("Sound"); | 347 | Config cfg("Vmemo"); |
350 | cfg.setGroup("Record"); | 348 | cfg.setGroup("Record"); |
351 | 349 | ||
352 | speed = cfg.readNumEntry("SampleRate", 22050); | 350 | speed = cfg.readNumEntry("SampleRate", 22050); |
353 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 351 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
354 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 352 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
355 | format = AFMT_S16_LE; | 353 | format = AFMT_S16_LE; |
356 | resolution = 16; | 354 | resolution = 16; |
357 | } else { | 355 | } else { |
358 | format = AFMT_U8; | 356 | format = AFMT_U8; |
359 | resolution = 8; | 357 | resolution = 8; |
360 | } | 358 | } |
361 | 359 | ||
362 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 360 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
363 | 361 | ||
364 | if(systemZaurus) { | 362 | if(systemZaurus) { |
365 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 363 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
366 | channels=1; //zaurus has one input channel | 364 | channels=1; //zaurus has one input channel |
367 | } else { | 365 | } else { |
368 | dsp = open("/dev/dsp", O_RDWR); | 366 | dsp = open("/dev/dsp", O_RDWR); |
369 | } | 367 | } |
370 | 368 | ||
371 | if(dsp == -1) { | 369 | if(dsp == -1) { |
372 | perror("open(\"/dev/dsp\")"); | 370 | perror("open(\"/dev/dsp\")"); |
373 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 371 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
374 | return -1; | 372 | return -1; |
375 | } | 373 | } |
376 | 374 | ||
377 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 375 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
378 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 376 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
379 | return -1; | 377 | return -1; |
380 | } | 378 | } |
381 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 379 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
382 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 380 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
383 | return -1; | 381 | return -1; |
384 | } | 382 | } |
385 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 383 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
386 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 384 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
387 | return -1; | 385 | return -1; |
388 | } | 386 | } |
389 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 387 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
390 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 388 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
391 | return -1; | 389 | return -1; |
392 | } | 390 | } |
393 | 391 | ||
394 | return 1; | 392 | return 1; |
395 | } | 393 | } |
396 | 394 | ||
397 | int VMemo::openWAV(const char *filename) | 395 | int VMemo::openWAV(const char *filename) |
398 | { | 396 | { |
399 | track.setName(filename); | 397 | track.setName(filename); |
400 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 398 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
401 | errorMsg=filename; | 399 | errorMsg=filename; |
402 | return -1; | 400 | return -1; |
403 | } | 401 | } |
404 | 402 | ||
405 | wav=track.handle(); | 403 | wav=track.handle(); |
406 | 404 | ||
407 | WaveHeader wh; | 405 | WaveHeader wh; |
408 | 406 | ||
409 | wh.main_chunk = RIFF; | 407 | wh.main_chunk = RIFF; |
410 | wh.length=0; | 408 | wh.length=0; |
411 | wh.chunk_type = WAVE; | 409 | wh.chunk_type = WAVE; |
412 | wh.sub_chunk = FMT; | 410 | wh.sub_chunk = FMT; |
413 | wh.sc_len = 16; | 411 | wh.sc_len = 16; |
414 | wh.format = PCM_CODE; | 412 | wh.format = PCM_CODE; |
415 | wh.modus = channels; | 413 | wh.modus = channels; |
416 | wh.sample_fq = speed; | 414 | wh.sample_fq = speed; |
417 | wh.byte_p_sec = speed * channels * resolution/8; | 415 | wh.byte_p_sec = speed * channels * resolution/8; |
418 | wh.byte_p_spl = channels * (resolution / 8); | 416 | wh.byte_p_spl = channels * (resolution / 8); |
419 | wh.bit_p_spl = resolution; | 417 | wh.bit_p_spl = resolution; |
420 | wh.data_chunk = DATA; | 418 | wh.data_chunk = DATA; |
421 | wh.data_length= 0; | 419 | wh.data_length= 0; |
422 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" | 420 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" |
423 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); | 421 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); |
424 | write (wav, &wh, sizeof(WaveHeader)); | 422 | write (wav, &wh, sizeof(WaveHeader)); |
425 | 423 | ||
426 | return 1; | 424 | return 1; |
427 | } | 425 | } |
428 | 426 | ||
429 | void VMemo::record(void) | 427 | void VMemo::record(void) |
430 | { | 428 | { |
431 | int length=0, result, value; | 429 | int length=0, result, value; |
432 | qDebug("Recording"); | 430 | qDebug("Recording"); |
433 | 431 | ||
434 | if(systemZaurus) { | 432 | if(systemZaurus) { |
435 | signed short sound[512], monoBuffer[512]; | 433 | signed short sound[512], monoBuffer[512]; |
436 | if(format==AFMT_S16_LE) { | 434 | if(format==AFMT_S16_LE) { |
437 | while(recording) { | 435 | while(recording) { |
438 | result = read(dsp, sound, 512); // 8192 | 436 | result = read(dsp, sound, 512); // 8192 |
439 | int j=0; | 437 | int j=0; |
440 | if(systemZaurus) { | 438 | if(systemZaurus) { |
441 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 439 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
442 | monoBuffer[i] = sound[i]; | 440 | monoBuffer[i] = sound[i]; |
443 | } | 441 | } |
444 | length+=write(wav, monoBuffer, result); | 442 | length+=write(wav, monoBuffer, result); |
445 | } else { //ipaq /stereo inputs | 443 | } else { //ipaq /stereo inputs |
446 | for (int i = 0; i < result; i+=2) { | 444 | for (int i = 0; i < result; i+=2) { |
447 | monoBuffer[j] = (sound[i]+sound[i+1])/2; | 445 | monoBuffer[j] = (sound[i]+sound[i+1])/2; |
448 | j++; | 446 | j++; |
449 | } | 447 | } |
450 | length+=write(wav, monoBuffer, result/2); | 448 | length+=write(wav, monoBuffer, result/2); |
451 | } | 449 | } |
452 | // printf("%d\r",length); | 450 | // printf("%d\r",length); |
453 | // fflush(stdout); | 451 | // fflush(stdout); |
454 | } | 452 | } |
455 | } else { //AFMT_U8 | 453 | } else { //AFMT_U8 |
456 | // 8bit unsigned | 454 | // 8bit unsigned |
457 | unsigned short sound[512], monoBuffer[512]; | 455 | unsigned short sound[512], monoBuffer[512]; |
458 | while(recording) { | 456 | while(recording) { |
459 | result = read(dsp, sound, 512); // 8192 | 457 | result = read(dsp, sound, 512); // 8192 |
460 | int j=0; | 458 | int j=0; |
461 | if(systemZaurus) { | 459 | if(systemZaurus) { |
462 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 460 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
463 | monoBuffer[i] = sound[i]; | 461 | monoBuffer[i] = sound[i]; |
464 | } | 462 | } |
465 | length+=write(wav, monoBuffer, result); | 463 | length+=write(wav, monoBuffer, result); |
466 | } else { //ipaq /stereo inputs | 464 | } else { //ipaq /stereo inputs |
467 | for (int i = 0; i < result; i+=2) { | 465 | for (int i = 0; i < result; i+=2) { |
468 | monoBuffer[j] = (sound[i]+sound[i+1])/2; | 466 | monoBuffer[j] = (sound[i]+sound[i+1])/2; |
469 | j++; | 467 | j++; |
470 | } | 468 | } |
471 | length+=write(wav, monoBuffer, result/2); | 469 | length+=write(wav, monoBuffer, result/2); |
472 | } | 470 | } |
473 | length += result; | 471 | length += result; |
474 | // printf("%d\r",length); | 472 | // printf("%d\r",length); |
475 | // fflush(stdout); | 473 | // fflush(stdout); |
476 | } | 474 | } |
477 | 475 | ||
478 | qApp->processEvents(); | 476 | qApp->processEvents(); |
479 | } | 477 | } |
480 | 478 | ||
481 | } else { // this is specific for ipaqs that do not have 8 bit capabilities | 479 | } else { // this is specific for ipaqs that do not have 8 bit capabilities |
482 | 480 | ||
483 | signed short sound[512], monoBuffer[512]; | 481 | signed short sound[512], monoBuffer[512]; |
484 | 482 | ||
485 | while(recording) { | 483 | while(recording) { |
486 | result = read(dsp, sound, 512); // 8192 | 484 | result = read(dsp, sound, 512); // 8192 |
487 | write(wav, sound, result); | 485 | write(wav, sound, result); |
488 | length += result; | 486 | length += result; |
489 | 487 | ||
490 | qApp->processEvents(); | 488 | qApp->processEvents(); |
491 | } | 489 | } |
492 | // printf("%d\r",length); | 490 | // printf("%d\r",length); |
493 | // fflush(stdout); | 491 | // fflush(stdout); |
494 | // qDebug("file has length of %d lasting %d seconds", | 492 | // qDebug("file has length of %d lasting %d seconds", |
495 | // length, (( length / speed) / channels) / 2 ); | 493 | // length, (( length / speed) / channels) / 2 ); |
496 | // medialplayer states wrong length in secs | 494 | // medialplayer states wrong length in secs |
497 | } | 495 | } |
498 | 496 | ||
499 | value = length+36; | 497 | value = length+36; |
500 | lseek(wav, 4, SEEK_SET); | 498 | lseek(wav, 4, SEEK_SET); |
501 | write(wav, &value, 4); | 499 | write(wav, &value, 4); |
502 | lseek(wav, 40, SEEK_SET); | 500 | lseek(wav, 40, SEEK_SET); |
503 | write(wav, &length, 4); | 501 | write(wav, &length, 4); |
504 | track.close(); | 502 | track.close(); |
505 | 503 | ||
506 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 504 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
507 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 505 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
508 | ::close(dsp); | 506 | ::close(dsp); |
509 | fileName = fileName.left(fileName.length()-4); | 507 | fileName = fileName.left(fileName.length()-4); |
510 | if(useAlerts) | 508 | if(useAlerts) |
511 | QMessageBox::message("Vmemo"," Done recording\n"+ fileName); | 509 | QMessageBox::message("Vmemo"," Done recording\n"+ fileName); |
512 | qDebug("done recording "+fileName); | 510 | qDebug("done recording "+fileName); |
513 | QSound::play(Resource::findSound("vmemoe")); | 511 | QSound::play(Resource::findSound("vmemoe")); |
514 | } | 512 | } |
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index e393f0f..e8921f0 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,380 +1,444 @@ | |||
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 | 21 | ||
22 | #include "volume.h" | 22 | #include "volume.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 27 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #endif | 29 | #endif |
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 <qframe.h> | 35 | #include <qframe.h> |
36 | #include <qpixmap.h> | 36 | #include <qpixmap.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | 38 | ||
39 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
40 | #include <qtimer.h> | 40 | #include <qtimer.h> |
41 | 41 | ||
42 | #define RATE_TIMER_INTERVAL 100 | 42 | #define RATE_TIMER_INTERVAL 100 |
43 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 43 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time |
44 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. | 44 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
45 | 45 | ||
46 | VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) | 46 | VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) |
47 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 47 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
48 | { | 48 | { |
49 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 49 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
50 | createView(showMic); | 50 | createView(showMic); |
51 | } | 51 | } |
52 | 52 | ||
53 | void VolumeControl::createView(bool showMic) | 53 | void VolumeControl::createView(bool showMic) |
54 | { | 54 | { |
55 | Config cfg("Sound"); | 55 | Config cfg("qpe"); |
56 | cfg.setGroup("System"); | 56 | cfg.setGroup("Volume"); |
57 | //showMic = TRUE; | 57 | //showMic = TRUE; |
58 | QHBoxLayout *hboxLayout = new QHBoxLayout(this); | 58 | QHBoxLayout *hboxLayout = new QHBoxLayout(this); |
59 | hboxLayout->setMargin( 3 ); | 59 | hboxLayout->setMargin( 3 ); |
60 | hboxLayout->setSpacing( 0); | 60 | hboxLayout->setSpacing( 0); |
61 | 61 | ||
62 | QVBoxLayout *vboxButtons = new QVBoxLayout(this); | 62 | QVBoxLayout *vboxButtons = new QVBoxLayout(this); |
63 | upButton = new QPushButton( this ); | 63 | upButton = new QPushButton( this ); |
64 | upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 64 | upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
65 | upButton->setPixmap( Resource::loadPixmap( "up" ) ); | 65 | upButton->setPixmap( Resource::loadPixmap( "up" ) ); |
66 | downButton = new QPushButton( this ); | 66 | downButton = new QPushButton( this ); |
67 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 67 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
68 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); | 68 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); |
69 | vboxButtons->setSpacing( 2 ); | 69 | vboxButtons->setSpacing( 2 ); |
70 | |||
71 | upButton->setFixedHeight(26); | ||
72 | downButton->setFixedHeight(26); | ||
70 | 73 | ||
71 | vboxButtons->addWidget( upButton ); | 74 | vboxButtons->addWidget( upButton ); |
72 | vboxButtons->addWidget( downButton ); | 75 | vboxButtons->addWidget( downButton ); |
73 | 76 | ||
74 | QVBoxLayout *vbox = new QVBoxLayout( this ); | 77 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
75 | QHBoxLayout *hbox = NULL; | 78 | QHBoxLayout *hbox = NULL; |
76 | 79 | ||
77 | slider = new QSlider( this ); | 80 | slider = new QSlider( this ); |
78 | slider->setRange( 0, 100 ); | 81 | slider->setRange( 0, 100 ); |
79 | slider->setTickmarks( QSlider::Both ); | 82 | slider->setTickmarks( QSlider::Both ); |
80 | slider->setTickInterval( 20 ); | 83 | slider->setTickInterval( 20 ); |
81 | slider->setFocusPolicy( QWidget::NoFocus ); | 84 | slider->setFocusPolicy( QWidget::NoFocus ); |
82 | slider->setValue(cfg.readNumEntry("Volume")); | 85 | slider->setValue(cfg.readNumEntry("VolumePercent")); |
83 | 86 | ||
84 | QVBoxLayout *sbox = new QVBoxLayout(this); | 87 | QVBoxLayout *sbox = new QVBoxLayout(this); |
85 | sbox->setMargin( 3 ); | 88 | sbox->setMargin( 3 ); |
86 | sbox->setSpacing( 3 ); | 89 | sbox->setSpacing( 3 ); |
87 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 90 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
88 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 91 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
89 | 92 | ||
90 | if (showMic == TRUE) { | 93 | // if (showMic == TRUE) { |
91 | mic = new QSlider(this); | 94 | mic = new QSlider(this); |
92 | mic->setRange( 0, 100 ); | 95 | mic->setRange( 0, 100 ); |
93 | mic->setTickmarks( QSlider::Both ); | 96 | mic->setTickmarks( QSlider::Both ); |
94 | mic->setTickInterval( 20 ); | 97 | mic->setTickInterval( 20 ); |
95 | mic->setFocusPolicy( QWidget::NoFocus ); | 98 | mic->setFocusPolicy( QWidget::NoFocus ); |
96 | mic->setValue(cfg.readNumEntry("Mic")); | 99 | mic->setValue(cfg.readNumEntry("Mic")); |
97 | 100 | ||
98 | QVBoxLayout *mbox = new QVBoxLayout(this); | 101 | QVBoxLayout *mbox = new QVBoxLayout(this); |
99 | mbox->setMargin( 3 ); | 102 | mbox->setMargin( 3 ); |
100 | mbox->setSpacing( 3 ); | 103 | mbox->setSpacing( 3 ); |
101 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 104 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
102 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 105 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
103 | 106 | ||
104 | hbox = new QHBoxLayout( this ); | 107 | hbox = new QHBoxLayout( this ); |
105 | hbox->setMargin( 3 ); | 108 | hbox->setMargin( 3 ); |
106 | hbox->setSpacing( 3 ); | 109 | hbox->setSpacing( 3 ); |
107 | hbox->addLayout( sbox, 1); | 110 | hbox->addLayout( sbox, 1); |
108 | hbox->addLayout( mbox, 1); | 111 | hbox->addLayout( mbox, 1); |
109 | } | 112 | // } |
110 | 113 | ||
111 | muteBox = new QCheckBox( tr("Mute"), this ); | 114 | muteBox = new QCheckBox( tr("Mute"), this ); |
112 | muteBox->setFocusPolicy( QWidget::NoFocus ); | 115 | muteBox->setFocusPolicy( QWidget::NoFocus ); |
113 | 116 | ||
117 | QVBoxLayout *klbox = new QVBoxLayout(this); | ||
118 | |||
119 | QLabel *Label1; | ||
120 | Label1 = new QLabel( this, "Label1" ); | ||
121 | Label1->setText( tr( "Enable Sounds for:" )); | ||
122 | |||
123 | alarmSound = new QCheckBox( tr("Alarm Sound"), this ); | ||
124 | alarmSound->setFocusPolicy( QWidget::NoFocus ); | ||
125 | |||
126 | keyclicks = new QCheckBox( tr("Key Clicks"), this ); | ||
127 | keyclicks->setFocusPolicy( QWidget::NoFocus ); | ||
128 | |||
129 | screentaps = new QCheckBox( tr("Screen taps"), this ); | ||
130 | screentaps->setFocusPolicy( QWidget::NoFocus ); | ||
131 | |||
132 | |||
133 | keyclicks->setChecked( cfg.readBoolEntry("KeySound",0)); | ||
134 | screentaps->setChecked( cfg.readBoolEntry("TouchSound",0)); | ||
135 | alarmSound->setChecked( cfg.readBoolEntry("AlarmSound",1)); | ||
136 | |||
137 | klbox->setMargin( 3 ); | ||
138 | klbox->setSpacing( 0 ); | ||
139 | klbox->addWidget( Label1, 1); | ||
140 | klbox->addWidget( alarmSound, 1); | ||
141 | klbox->addWidget( keyclicks, 1); | ||
142 | klbox->addWidget( screentaps, 1); | ||
114 | vbox->setMargin( 3 ); | 143 | vbox->setMargin( 3 ); |
115 | vbox->setSpacing( 0 ); | 144 | vbox->setSpacing( 0 ); |
116 | if (showMic == TRUE) | 145 | // if (showMic == TRUE) |
117 | vbox->addLayout( hbox, 1 ); | 146 | vbox->addLayout( hbox, 1 ); |
118 | else | 147 | // else |
119 | vbox->addLayout( sbox, 1); | 148 | // vbox->addLayout( sbox, 1); |
120 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 149 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
121 | 150 | ||
122 | hboxLayout->addLayout( vboxButtons ); | 151 | hboxLayout->addLayout( vboxButtons ); |
123 | hboxLayout->addLayout(vbox); | 152 | hboxLayout->addLayout( vbox); |
153 | hboxLayout->addLayout( klbox); | ||
124 | 154 | ||
125 | setFixedHeight( 120 ); | 155 | |
126 | setFixedWidth( sizeHint().width() ); | 156 | setFixedHeight( 120); |
157 | // setFixedWidth( sizeHint().width() ); | ||
127 | setFocusPolicy(QWidget::NoFocus); | 158 | setFocusPolicy(QWidget::NoFocus); |
128 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); | 159 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); |
129 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); | 160 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); |
130 | connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); | 161 | connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); |
131 | connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); | 162 | connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); |
132 | 163 | ||
133 | rateTimer = new QTimer(this); | 164 | rateTimer = new QTimer(this); |
134 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); | 165 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); |
135 | } | 166 | } |
136 | 167 | ||
137 | void VolumeControl::keyPressEvent( QKeyEvent *e) | 168 | void VolumeControl::keyPressEvent( QKeyEvent *e) |
138 | { | 169 | { |
139 | switch(e->key()) | 170 | switch(e->key()) |
140 | { | 171 | { |
141 | case Key_Up: | 172 | case Key_Up: |
142 | slider->subtractStep(); | 173 | slider->subtractStep(); |
143 | break; | 174 | break; |
144 | case Key_Down: | 175 | case Key_Down: |
145 | slider->addStep(); | 176 | slider->addStep(); |
146 | break; | 177 | break; |
147 | case Key_Space: | 178 | case Key_Space: |
148 | muteBox->toggle(); | 179 | muteBox->toggle(); |
149 | break; | 180 | break; |
150 | case Key_Escape: | 181 | case Key_Escape: |
151 | close(); | 182 | close(); |
152 | break; | 183 | break; |
153 | } | 184 | } |
154 | } | 185 | } |
155 | 186 | ||
156 | void VolumeControl::ButtonChanged() | 187 | void VolumeControl::ButtonChanged() |
157 | { | 188 | { |
158 | if ( upButton->isDown() || downButton->isDown() ) | 189 | if ( upButton->isDown() || downButton->isDown() ) |
159 | { | 190 | { |
160 | rateTimerDone(); // Call it one time manually, otherwise it wont get | 191 | rateTimerDone(); // Call it one time manually, otherwise it wont get |
161 | // called at all when a button is pressed for a time | 192 | // called at all when a button is pressed for a time |
162 | // shorter than RATE_TIMER_INTERVAL. | 193 | // shorter than RATE_TIMER_INTERVAL. |
163 | rateTimer->start( RATE_TIMER_INTERVAL, false ); | 194 | rateTimer->start( RATE_TIMER_INTERVAL, false ); |
164 | } | 195 | } |
165 | else | 196 | else |
166 | rateTimer->stop(); | 197 | rateTimer->stop(); |
167 | } | 198 | } |
168 | 199 | ||
169 | void VolumeControl::rateTimerDone() | 200 | void VolumeControl::rateTimerDone() |
170 | { | 201 | { |
171 | if ( upButton->isDown() ) | 202 | if ( upButton->isDown() ) |
172 | slider->setValue( slider->value() - 2 ); | 203 | slider->setValue( slider->value() - 2 ); |
173 | else // downButton->isDown() | 204 | else // downButton->isDown() |
174 | slider->setValue( slider->value() + 2 ); | 205 | slider->setValue( slider->value() + 2 ); |
175 | } | 206 | } |
176 | 207 | ||
177 | //=========================================================================== | 208 | //=========================================================================== |
178 | 209 | ||
179 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 210 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
180 | : QWidget( parent, name ) | 211 | : QWidget( parent, name ) |
181 | { | 212 | { |
182 | Config cfg("Sound"); | 213 | Config cfg("qpe"); |
183 | cfg.setGroup("System"); | 214 | cfg.setGroup("Volume"); |
184 | 215 | ||
185 | setFixedHeight( 18 ); | 216 | setFixedHeight( 18 ); |
186 | setFixedWidth( 14 ); | 217 | setFixedWidth( 14 ); |
187 | 218 | ||
188 | volumePixmap = Resource::loadPixmap( "volume" ); | 219 | volumePixmap = Resource::loadPixmap( "volume" ); |
189 | 220 | ||
190 | volumePercent = cfg.readNumEntry("Volume",50); | 221 | volumePercent = cfg.readNumEntry("VolumePercent",50); |
191 | micPercent = cfg.readNumEntry("Mic", 50); | 222 | micPercent = cfg.readNumEntry("Mic", 50); |
192 | muted = FALSE; // ### read from pref | 223 | muted = FALSE; // ### read from pref |
193 | micMuted = FALSE; // ### read from pref | 224 | micMuted = FALSE; // ### read from pref |
194 | 225 | ||
195 | advancedTimer = new QTimer(this); | 226 | advancedTimer = new QTimer(this); |
196 | 227 | ||
197 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 228 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
198 | connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); | 229 | connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); |
199 | connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); | 230 | connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); |
200 | 231 | ||
201 | writeSystemVolume(); | 232 | writeSystemVolume(); |
202 | writeSystemMic(); | 233 | writeSystemMic(); |
203 | } | 234 | } |
204 | 235 | ||
205 | VolumeApplet::~VolumeApplet() | 236 | VolumeApplet::~VolumeApplet() |
206 | { | 237 | { |
207 | } | 238 | } |
208 | 239 | ||
209 | void VolumeApplet::keyPressEvent ( QKeyEvent * e ) | 240 | void VolumeApplet::keyPressEvent ( QKeyEvent * e ) |
210 | { | 241 | { |
211 | QString s; | 242 | QString s; |
212 | s.setNum(e->key()); | 243 | s.setNum(e->key()); |
213 | qWarning(s); | 244 | qWarning(s); |
214 | } | 245 | } |
215 | void VolumeApplet::mousePressEvent( QMouseEvent * ) | 246 | void VolumeApplet::mousePressEvent( QMouseEvent * ) |
216 | { | 247 | { |
217 | advancedTimer->start( 750, TRUE ); | 248 | advancedTimer->start( 750, TRUE ); |
218 | } | 249 | } |
219 | 250 | ||
220 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) | 251 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) |
221 | { | 252 | { |
222 | showVolControl(FALSE); | 253 | showVolControl(FALSE); |
223 | } | 254 | } |
224 | 255 | ||
225 | void VolumeApplet::advVolControl() | 256 | void VolumeApplet::advVolControl() |
226 | { | 257 | { |
227 | showVolControl(TRUE); | 258 | showVolControl(TRUE); |
228 | } | 259 | } |
229 | 260 | ||
230 | void VolumeApplet::showVolControl(bool showMic) | 261 | void VolumeApplet::showVolControl(bool showMic) |
231 | { | 262 | { |
232 | Config cfg("Sound"); | 263 | Config cfg("qpe"); |
233 | cfg.setGroup("System"); | 264 | cfg.setGroup("Volume"); |
234 | volumePercent = cfg.readNumEntry("Volume",50); | 265 | volumePercent = cfg.readNumEntry("VolumePercent",50); |
235 | micPercent = cfg.readNumEntry("Mic", 50); | 266 | micPercent = cfg.readNumEntry("Mic", 50); |
236 | QString show = cfg.readEntry("ShowMic", "FALSE"); | 267 | |
237 | if(show == "TRUE") showMic = TRUE; | ||
238 | // Create a small volume control window to adjust the volume with | 268 | // Create a small volume control window to adjust the volume with |
239 | VolumeControl *vc = new VolumeControl(showMic); | 269 | VolumeControl *vc = new VolumeControl(showMic); |
240 | vc->slider->setValue( 100 - volumePercent ); | 270 | vc->slider->setValue( 100 - volumePercent ); |
241 | if (showMic) | 271 | // if (showMic) |
242 | { | 272 | // { |
243 | vc->mic->setValue( 100 - micPercent ); | 273 | vc->mic->setValue( 100 - micPercent ); |
244 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); | 274 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); |
245 | } | 275 | // } |
246 | 276 | ||
247 | vc->muteBox->setChecked( muted ); | 277 | vc->muteBox->setChecked( muted ); |
248 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); | 278 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); |
249 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); | 279 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); |
280 | |||
281 | Config config("qpe"); | ||
282 | config.setGroup("Volume"); | ||
283 | |||
284 | vc->keyclicks->setChecked( config.readBoolEntry("KeySound",0)); | ||
285 | vc->screentaps->setChecked( config.readBoolEntry("TouchSound",0)); | ||
286 | vc->alarmSound->setChecked( config.readBoolEntry("AlarmSound",1)); | ||
287 | |||
288 | connect( vc->alarmSound, SIGNAL(toggled(bool)), this, SLOT( alarmSoundCheckToggled(bool))); | ||
289 | connect( vc->keyclicks, SIGNAL(toggled(bool)), this, SLOT( keyclicksCheckToggled(bool))); | ||
290 | connect( vc->screentaps, SIGNAL(toggled(bool)), this, SLOT( screentapsCheckToggled(bool))); | ||
291 | |||
250 | QPoint curPos = mapToGlobal( rect().topLeft() ); | 292 | QPoint curPos = mapToGlobal( rect().topLeft() ); |
251 | vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 120 ); | 293 | vc->move( curPos.x()-(vc->sizeHint().width()/2+50), curPos.y() - 120 ); |
252 | vc->show(); | 294 | vc->show(); |
253 | 295 | ||
254 | advancedTimer->stop(); | 296 | advancedTimer->stop(); |
255 | } | 297 | } |
256 | 298 | ||
257 | void VolumeApplet::volumeChanged( bool nowMuted ) | 299 | void VolumeApplet::volumeChanged( bool nowMuted ) |
258 | { | 300 | { |
259 | int previousVolume = volumePercent; | 301 | int previousVolume = volumePercent; |
260 | 302 | ||
261 | if ( !nowMuted ) | 303 | if ( !nowMuted ) |
262 | readSystemVolume(); | 304 | readSystemVolume(); |
263 | 305 | ||
264 | // Handle case where muting it toggled | 306 | // Handle case where muting it toggled |
265 | if ( muted != nowMuted ) { | 307 | if ( muted != nowMuted ) { |
266 | muted = nowMuted; | 308 | muted = nowMuted; |
267 | repaint( TRUE ); | 309 | repaint( TRUE ); |
268 | return; | 310 | return; |
269 | } | 311 | } |
270 | 312 | ||
271 | // Avoid over repainting | 313 | // Avoid over repainting |
272 | if ( previousVolume != volumePercent ) | 314 | if ( previousVolume != volumePercent ) |
273 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 315 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
274 | } | 316 | } |
275 | 317 | ||
276 | void VolumeApplet::micChanged( bool nowMuted ) | 318 | void VolumeApplet::micChanged( bool nowMuted ) |
277 | { | 319 | { |
278 | if (!nowMuted) | 320 | if (!nowMuted) |
279 | readSystemMic(); | 321 | readSystemMic(); |
280 | micMuted = nowMuted; | 322 | micMuted = nowMuted; |
281 | } | 323 | } |
282 | 324 | ||
283 | void VolumeApplet::mute( bool toggled ) | 325 | void VolumeApplet::mute( bool toggled ) |
284 | { | 326 | { |
285 | muted = toggled; | 327 | muted = toggled; |
286 | 328 | ||
287 | // clear if removing mute | 329 | // clear if removing mute |
288 | repaint( !toggled ); | 330 | repaint( !toggled ); |
289 | writeSystemVolume(); | 331 | writeSystemVolume(); |
290 | } | 332 | } |
291 | 333 | ||
292 | 334 | ||
293 | void VolumeApplet::sliderMoved( int percent ) | 335 | void VolumeApplet::sliderMoved( int percent ) |
294 | { | 336 | { |
295 | setVolume( 100 - percent ); | 337 | setVolume( 100 - percent ); |
296 | } | 338 | } |
297 | 339 | ||
298 | void VolumeApplet::micMoved( int percent ) | 340 | void VolumeApplet::micMoved( int percent ) |
299 | { | 341 | { |
300 | setMic( 100 - percent ); | 342 | setMic( 100 - percent ); |
301 | } | 343 | } |
302 | 344 | ||
303 | void VolumeApplet::readSystemVolume() | 345 | void VolumeApplet::readSystemVolume() |
304 | { | 346 | { |
305 | Config cfg("Sound"); | 347 | Config cfg("qpe"); |
306 | cfg.setGroup("System"); | 348 | cfg.setGroup("Volume"); |
307 | volumePercent = cfg.readNumEntry("Volume"); | 349 | volumePercent = cfg.readNumEntry("VolumePercent"); |
308 | } | 350 | } |
309 | 351 | ||
310 | void VolumeApplet::readSystemMic() | 352 | void VolumeApplet::readSystemMic() |
311 | { | 353 | { |
312 | Config cfg("Sound"); | 354 | Config cfg("qpe"); |
313 | cfg.setGroup("System"); | 355 | cfg.setGroup("Volume"); |
314 | micPercent = cfg.readNumEntry("Mic"); | 356 | micPercent = cfg.readNumEntry("Mic"); |
315 | } | 357 | } |
316 | 358 | ||
317 | void VolumeApplet::setVolume( int percent ) | 359 | void VolumeApplet::setVolume( int percent ) |
318 | { | 360 | { |
319 | // clamp volume percent to be between 0 and 100 | 361 | // clamp volume percent to be between 0 and 100 |
320 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | 362 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); |
321 | // repaint just the little volume rectangle | 363 | // repaint just the little volume rectangle |
322 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 364 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
323 | writeSystemVolume(); | 365 | writeSystemVolume(); |
324 | } | 366 | } |
325 | 367 | ||
326 | void VolumeApplet::setMic( int percent ) | 368 | void VolumeApplet::setMic( int percent ) |
327 | { | 369 | { |
328 | // clamp volume percent to be between 0 and 100 | 370 | // clamp volume percent to be between 0 and 100 |
329 | micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | 371 | micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); |
330 | writeSystemMic(); | 372 | writeSystemMic(); |
331 | } | 373 | } |
332 | 374 | ||
333 | void VolumeApplet::writeSystemVolume() | 375 | void VolumeApplet::writeSystemVolume() |
334 | { | 376 | { |
335 | { | 377 | { |
336 | Config cfg("Sound"); | 378 | Config cfg("qpe"); |
337 | cfg.setGroup("System"); | 379 | cfg.setGroup("Volume"); |
338 | cfg.writeEntry("Volume",volumePercent); | 380 | cfg.writeEntry("VolumePercent",volumePercent); |
339 | } | 381 | } |
340 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 382 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
341 | // Send notification that the volume has changed | 383 | // Send notification that the volume has changed |
342 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 384 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
343 | #endif | 385 | #endif |
344 | } | 386 | } |
345 | 387 | ||
346 | void VolumeApplet::writeSystemMic() | 388 | void VolumeApplet::writeSystemMic() |
347 | { | 389 | { |
348 | { | 390 | { |
349 | Config cfg("Sound"); | 391 | Config cfg("qpe"); |
350 | cfg.setGroup("System"); | 392 | cfg.setGroup("Volume"); |
351 | cfg.writeEntry("Mic",micPercent); | 393 | cfg.writeEntry("Mic",micPercent); |
352 | } | 394 | } |
353 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 395 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
354 | // Send notification that the volume has changed | 396 | // Send notification that the volume has changed |
355 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; | 397 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; |
356 | #endif | 398 | #endif |
357 | } | 399 | } |
358 | 400 | ||
359 | void VolumeApplet::paintEvent( QPaintEvent* ) | 401 | void VolumeApplet::paintEvent( QPaintEvent* ) |
360 | { | 402 | { |
361 | QPainter p(this); | 403 | QPainter p(this); |
362 | 404 | ||
363 | if (volumePixmap.isNull()) | 405 | if (volumePixmap.isNull()) |
364 | volumePixmap = Resource::loadPixmap( "volume" ); | 406 | volumePixmap = Resource::loadPixmap( "volume" ); |
365 | p.drawPixmap( 0, 1, volumePixmap ); | 407 | p.drawPixmap( 0, 1, volumePixmap ); |
366 | p.setPen( darkGray ); | 408 | p.setPen( darkGray ); |
367 | p.drawRect( 1, height() - 4, width() - 2, 4 ); | 409 | p.drawRect( 1, height() - 4, width() - 2, 4 ); |
368 | 410 | ||
369 | int pixelsWide = volumePercent * (width() - 4) / 100; | 411 | int pixelsWide = volumePercent * (width() - 4) / 100; |
370 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); | 412 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); |
371 | p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 413 | p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
372 | 414 | ||
373 | if ( muted ) { | 415 | if ( muted ) { |
374 | p.setPen( red ); | 416 | p.setPen( red ); |
375 | p.drawLine( 1, 2, width() - 2, height() - 5 ); | 417 | p.drawLine( 1, 2, width() - 2, height() - 5 ); |
376 | p.drawLine( 1, 3, width() - 2, height() - 4 ); | 418 | p.drawLine( 1, 3, width() - 2, height() - 4 ); |
377 | p.drawLine( width() - 2, 2, 1, height() - 5 ); | 419 | p.drawLine( width() - 2, 2, 1, height() - 5 ); |
378 | p.drawLine( width() - 2, 3, 1, height() - 4 ); | 420 | p.drawLine( width() - 2, 3, 1, height() - 4 ); |
379 | } | 421 | } |
380 | } | 422 | } |
423 | |||
424 | void VolumeApplet::screentapsCheckToggled(bool b) { | ||
425 | Config cfg("qpe"); | ||
426 | cfg.setGroup("Volume"); | ||
427 | cfg.writeEntry("TouchSound",b ); | ||
428 | cfg.write(); | ||
429 | } | ||
430 | |||
431 | void VolumeApplet::keyclicksCheckToggled(bool b) { | ||
432 | Config cfg("qpe"); | ||
433 | cfg.setGroup("Volume"); | ||
434 | cfg.writeEntry("KeySound",b); | ||
435 | cfg.write(); | ||
436 | } | ||
437 | |||
438 | void VolumeApplet::alarmSoundCheckToggled(bool b) { | ||
439 | Config cfg("qpe"); | ||
440 | cfg.setGroup("Volume"); | ||
441 | cfg.writeEntry("AlarmSound",b); | ||
442 | cfg.write(); | ||
443 | } | ||
444 | |||
diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index 3a2da43..6e631f2 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h | |||
@@ -1,101 +1,108 @@ | |||
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 | #ifndef __VOLUME_APPLET_H__ | 21 | #ifndef __VOLUME_APPLET_H__ |
22 | #define __VOLUME_APPLET_H__ | 22 | #define __VOLUME_APPLET_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include <qwidget.h> | 25 | #include <qwidget.h> |
26 | #include <qpushbutton.h> | ||
27 | #include <qframe.h> | 26 | #include <qframe.h> |
28 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
29 | #include <qguardedptr.h> | 28 | #include <qguardedptr.h> |
30 | #include <qtimer.h> | 29 | #include <qtimer.h> |
31 | 30 | ||
32 | class QSlider; | 31 | class QSlider; |
33 | class QCheckBox; | 32 | class QCheckBox; |
34 | 33 | ||
35 | class VolumeControl : public QFrame | 34 | class VolumeControl : public QFrame |
36 | { | 35 | { |
37 | Q_OBJECT | 36 | Q_OBJECT |
38 | public: | 37 | public: |
39 | VolumeControl( bool showMic=FALSE, QWidget *parent=0, const char *name=0 ); | 38 | VolumeControl( bool showMic=FALSE, QWidget *parent=0, const char *name=0 ); |
40 | 39 | ||
41 | public: | 40 | public: |
42 | QSlider *slider; | 41 | QSlider *slider; |
43 | QSlider *mic; | 42 | QSlider *mic; |
44 | QCheckBox *muteBox; | 43 | QCheckBox *muteBox; |
44 | QCheckBox *alarmSound; | ||
45 | QCheckBox *screentaps; | ||
46 | QCheckBox *keyclicks; | ||
47 | |||
45 | 48 | ||
46 | private: | 49 | private: |
47 | QPushButton *upButton; | 50 | QPushButton *upButton; |
48 | QPushButton *downButton; | 51 | QPushButton *downButton; |
49 | QTimer *rateTimer; | 52 | QTimer *rateTimer; |
50 | 53 | ||
51 | void keyPressEvent( QKeyEvent * ); | 54 | void keyPressEvent( QKeyEvent * ); |
52 | void createView(bool showMic = FALSE); | 55 | void createView(bool showMic = FALSE); |
53 | private slots: | 56 | private slots: |
54 | void ButtonChanged(); | 57 | void ButtonChanged(); |
55 | void rateTimerDone(); | 58 | void rateTimerDone(); |
56 | 59 | ||
57 | }; | 60 | }; |
58 | 61 | ||
59 | class VolumeApplet : public QWidget | 62 | class VolumeApplet : public QWidget |
60 | { | 63 | { |
61 | Q_OBJECT | 64 | Q_OBJECT |
62 | public: | 65 | public: |
63 | VolumeApplet( QWidget *parent = 0, const char *name=0 ); | 66 | VolumeApplet( QWidget *parent = 0, const char *name=0 ); |
64 | ~VolumeApplet(); | 67 | ~VolumeApplet(); |
65 | bool isMute( ) { return muted; } | 68 | bool isMute( ) { return muted; } |
66 | int percent( ) { return volumePercent; } | 69 | int percent( ) { return volumePercent; } |
67 | 70 | ||
68 | public slots: | 71 | public slots: |
69 | void volumeChanged( bool muted ); | 72 | void volumeChanged( bool muted ); |
70 | void micChanged( bool muted ); | 73 | void micChanged( bool muted ); |
71 | void sliderMoved( int percent ); | 74 | void sliderMoved( int percent ); |
72 | void mute( bool ); | 75 | void mute( bool ); |
73 | 76 | ||
74 | void micMoved( int percent ); | 77 | void micMoved( int percent ); |
75 | void setVolume( int percent ); | 78 | void setVolume( int percent ); |
76 | void setMic( int percent ); | 79 | void setMic( int percent ); |
77 | 80 | ||
78 | void showVolControl(bool showMic = FALSE); | 81 | void showVolControl(bool showMic = FALSE); |
79 | void advVolControl(); | 82 | void advVolControl(); |
80 | 83 | ||
81 | private: | 84 | private: |
82 | int volumePercent, micPercent; | 85 | int volumePercent, micPercent; |
83 | bool muted, micMuted; | 86 | bool muted, micMuted; |
84 | QPixmap volumePixmap; | 87 | QPixmap volumePixmap; |
85 | QTimer *advancedTimer; | 88 | QTimer *advancedTimer; |
86 | 89 | ||
87 | void readSystemVolume(); | 90 | void readSystemVolume(); |
88 | void writeSystemVolume(); | 91 | void writeSystemVolume(); |
89 | void mousePressEvent( QMouseEvent * ); | 92 | void mousePressEvent( QMouseEvent * ); |
90 | void paintEvent( QPaintEvent* ); | 93 | void paintEvent( QPaintEvent* ); |
91 | 94 | ||
92 | void readSystemMic(); | 95 | void readSystemMic(); |
93 | void keyPressEvent ( QKeyEvent * e ); | 96 | void keyPressEvent ( QKeyEvent * e ); |
94 | void mouseReleaseEvent( QMouseEvent *); | 97 | void mouseReleaseEvent( QMouseEvent *); |
95 | void writeSystemMic(); | 98 | void writeSystemMic(); |
96 | 99 | ||
100 | protected slots: | ||
101 | void alarmSoundCheckToggled(bool); | ||
102 | void keyclicksCheckToggled(bool); | ||
103 | void screentapsCheckToggled(bool); | ||
97 | }; | 104 | }; |
98 | 105 | ||
99 | 106 | ||
100 | #endif // __VOLUME_APPLET_H__ | 107 | #endif // __VOLUME_APPLET_H__ |
101 | 108 | ||