author | llornkcor <llornkcor> | 2002-05-26 23:41:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-26 23:41:26 (UTC) |
commit | ff4ab0f08fe935fd781be4caa245cb953e9f68ce (patch) (unidiff) | |
tree | 3a20249c724552e4437677dea4e407397afc1610 | |
parent | f0d0d53759436686f7f15fcd55a6706b1ecaa1cc (diff) | |
download | opie-ff4ab0f08fe935fd781be4caa245cb953e9f68ce.zip opie-ff4ab0f08fe935fd781be4caa245cb953e9f68ce.tar.gz opie-ff4ab0f08fe935fd781be4caa245cb953e9f68ce.tar.bz2 |
changed visual alert to QLabel in the corner while recording, instead of nag screen when stopping recording. made pick-a-key record work
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 78 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 6 |
2 files changed, 72 insertions, 12 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index f5d2b20..e327098 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -204,12 +204,14 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
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 = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
211 | 211 | ||
212 | qDebug("toggleKey %d", toggleKey); | ||
213 | |||
212 | if(release.find("embedix",0,TRUE) !=-1) | 214 | if(release.find("embedix",0,TRUE) !=-1) |
213 | systemZaurus=TRUE; | 215 | systemZaurus=TRUE; |
214 | else | 216 | else |
215 | systemZaurus=FALSE; | 217 | systemZaurus=FALSE; |
@@ -268,11 +270,19 @@ void VMemo::mouseReleaseEvent( QMouseEvent * ) | |||
268 | bool VMemo::startRecording() { | 270 | bool VMemo::startRecording() { |
269 | 271 | ||
270 | if ( recording) | 272 | if ( recording) |
271 | return FALSE;; | 273 | return FALSE;; |
272 | Config config( "Vmemo" ); | 274 | |
275 | Config config( "Vmemo" ); | ||
273 | config.setGroup( "System" ); | 276 | config.setGroup( "System" ); |
277 | |||
274 | useAlerts = config.readBoolEntry("Alert"); | 278 | useAlerts = config.readBoolEntry("Alert"); |
279 | if(useAlerts) { | ||
280 | |||
281 | msgLabel = new QLabel( 0, "alertLabel" ); | ||
282 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | ||
283 | msgLabel->show(); | ||
284 | } | ||
275 | 285 | ||
276 | // if(useAlerts) | 286 | // if(useAlerts) |
277 | // QMessageBox::message("VMemo","Really Record?");//) ==1) | 287 | // QMessageBox::message("VMemo","Really Record?");//) ==1) |
278 | // return; | 288 | // return; |
@@ -282,9 +292,9 @@ bool VMemo::startRecording() { | |||
282 | // } | 292 | // } |
283 | qDebug("Start recording"); | 293 | qDebug("Start recording"); |
284 | recording = TRUE; | 294 | recording = TRUE; |
285 | if (openDSP() == -1) { | 295 | if (openDSP() == -1) { |
286 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); | 296 | QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); |
287 | recording = FALSE; | 297 | recording = FALSE; |
288 | return FALSE; | 298 | return FALSE; |
289 | } | 299 | } |
290 | 300 | ||
@@ -318,9 +328,9 @@ bool VMemo::startRecording() { | |||
318 | 328 | ||
319 | if(openWAV(fileName.latin1()) == -1) { | 329 | if(openWAV(fileName.latin1()) == -1) { |
320 | QString err("Could not open the output file\n"); | 330 | QString err("Could not open the output file\n"); |
321 | err += fileName; | 331 | err += fileName; |
322 | QMessageBox::critical(0, "VMemo", err, "Abort"); | 332 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
323 | close(dsp); | 333 | close(dsp); |
324 | return FALSE; | 334 | return FALSE; |
325 | } | 335 | } |
326 | 336 | ||
@@ -334,15 +344,18 @@ bool VMemo::startRecording() { | |||
334 | l.setName(dlName); | 344 | l.setName(dlName); |
335 | l.setType("audio/x-wav"); | 345 | l.setType("audio/x-wav"); |
336 | l.setCategories(cats); | 346 | l.setCategories(cats); |
337 | l.writeLink(); | 347 | l.writeLink(); |
348 | |||
338 | 349 | ||
339 | record(); | 350 | record(); |
340 | return TRUE; | 351 | return TRUE; |
341 | } | 352 | } |
342 | 353 | ||
343 | void VMemo::stopRecording() { | 354 | void VMemo::stopRecording() { |
344 | recording = FALSE; | 355 | recording = FALSE; |
356 | if(useAlerts) | ||
357 | if( msgLabel) delete msgLabel; | ||
345 | } | 358 | } |
346 | 359 | ||
347 | int VMemo::openDSP() | 360 | int VMemo::openDSP() |
348 | { | 361 | { |
@@ -428,32 +441,42 @@ int VMemo::openWAV(const char *filename) | |||
428 | 441 | ||
429 | void VMemo::record(void) | 442 | void VMemo::record(void) |
430 | { | 443 | { |
431 | int length=0, result, value; | 444 | int length=0, result, value; |
432 | qDebug("Recording"); | 445 | QString msg; |
446 | msg.sprintf("Recording format %d", format); | ||
447 | qDebug(msg); | ||
433 | 448 | ||
434 | if(systemZaurus) { | 449 | if(systemZaurus) { |
435 | signed short sound[512], monoBuffer[512]; | 450 | signed short sound[512], monoBuffer[512]; |
436 | if(format==AFMT_S16_LE) { | 451 | if(format==AFMT_S16_LE) { |
452 | |||
437 | while(recording) { | 453 | while(recording) { |
454 | |||
438 | result = read(dsp, sound, 512); // 8192 | 455 | result = read(dsp, sound, 512); // 8192 |
439 | int j=0; | 456 | int j=0; |
457 | |||
440 | if(systemZaurus) { | 458 | if(systemZaurus) { |
441 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 459 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
442 | monoBuffer[i] = sound[i]; | 460 | monoBuffer[i] = sound[i]; |
443 | } | 461 | } |
462 | |||
444 | length+=write(wav, monoBuffer, result); | 463 | length+=write(wav, monoBuffer, result); |
464 | |||
445 | } else { //ipaq /stereo inputs | 465 | } else { //ipaq /stereo inputs |
466 | |||
446 | for (int i = 0; i < result; i+=2) { | 467 | for (int i = 0; i < result; i+=2) { |
447 | monoBuffer[j] = (sound[i]+sound[i+1])/2; | 468 | monoBuffer[j] = (sound[i]+sound[i+1])/2; |
448 | j++; | 469 | j++; |
449 | } | 470 | } |
471 | |||
450 | length+=write(wav, monoBuffer, result/2); | 472 | length+=write(wav, monoBuffer, result/2); |
451 | } | 473 | } |
474 | qApp->processEvents(); | ||
452 | // printf("%d\r",length); | 475 | // printf("%d\r",length); |
453 | // fflush(stdout); | 476 | // fflush(stdout); |
454 | } | 477 | } |
455 | } else { //AFMT_U8 | 478 | } else { //AFMT_U8 |
456 | // 8bit unsigned | 479 | // 8bit unsigned |
457 | unsigned short sound[512], monoBuffer[512]; | 480 | unsigned short sound[512], monoBuffer[512]; |
458 | while(recording) { | 481 | while(recording) { |
459 | result = read(dsp, sound, 512); // 8192 | 482 | result = read(dsp, sound, 512); // 8192 |
@@ -506,9 +529,44 @@ void VMemo::record(void) | |||
506 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 529 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
507 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 530 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
508 | ::close(dsp); | 531 | ::close(dsp); |
509 | fileName = fileName.left(fileName.length()-4); | 532 | fileName = fileName.left(fileName.length()-4); |
510 | if(useAlerts) | 533 | // if(useAlerts) |
511 | QMessageBox::message("Vmemo"," Done recording\n"+ fileName); | 534 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
512 | qDebug("done recording "+fileName); | 535 | qDebug("done recording "+fileName); |
513 | QSound::play(Resource::findSound("vmemoe")); | 536 | QSound::play(Resource::findSound("vmemoe")); |
514 | } | 537 | } |
538 | |||
539 | int VMemo::setToggleButton(int tog) { | ||
540 | |||
541 | for( int i=0; i < 10;i++) { | ||
542 | switch (tog) { | ||
543 | case 0: | ||
544 | return -1; | ||
545 | break; | ||
546 | case 1: | ||
547 | return 0; | ||
548 | break; | ||
549 | case 2: | ||
550 | return Key_Escape; | ||
551 | break; | ||
552 | case 3: | ||
553 | return Key_Space; | ||
554 | break; | ||
555 | case 4: | ||
556 | return Key_F12; | ||
557 | break; | ||
558 | case 5: | ||
559 | return Key_F9; | ||
560 | break; | ||
561 | case 6: | ||
562 | return Key_F10; | ||
563 | break; | ||
564 | case 7: | ||
565 | return Key_F11; | ||
566 | break; | ||
567 | case 8: | ||
568 | return Key_F13; | ||
569 | break; | ||
570 | }; | ||
571 | } | ||
572 | } | ||
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h index 701663f..b33ab55 100644 --- a/core/applets/vmemo/vmemo.h +++ b/core/applets/vmemo/vmemo.h | |||
@@ -16,13 +16,15 @@ | |||
16 | 16 | ||
17 | #ifndef __VMEMO_H__ | 17 | #ifndef __VMEMO_H__ |
18 | #define __VMEMO_H__ | 18 | #define __VMEMO_H__ |
19 | 19 | ||
20 | |||
20 | #include <qwidget.h> | 21 | #include <qwidget.h> |
21 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
22 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
23 | #include <qfile.h> | 24 | #include <qfile.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qlabel.h> | ||
25 | 27 | ||
26 | class VMemo : public QWidget | 28 | class VMemo : public QWidget |
27 | { | 29 | { |
28 | Q_OBJECT | 30 | Q_OBJECT |
@@ -30,9 +32,9 @@ public: | |||
30 | VMemo( QWidget *parent, const char *name = NULL); | 32 | VMemo( QWidget *parent, const char *name = NULL); |
31 | ~VMemo(); | 33 | ~VMemo(); |
32 | QFile track; | 34 | QFile track; |
33 | QString fileName, errorMsg; | 35 | QString fileName, errorMsg; |
34 | 36 | QLabel* msgLabel; | |
35 | public slots: | 37 | public slots: |
36 | void record(); | 38 | void record(); |
37 | void mousePressEvent( QMouseEvent * ); | 39 | void mousePressEvent( QMouseEvent * ); |
38 | void mouseReleaseEvent( QMouseEvent * ); | 40 | void mouseReleaseEvent( QMouseEvent * ); |
@@ -41,9 +43,9 @@ public slots: | |||
41 | void stopRecording(); | 43 | void stopRecording(); |
42 | private: | 44 | private: |
43 | bool useAlerts; | 45 | bool useAlerts; |
44 | void paintEvent( QPaintEvent* ); | 46 | void paintEvent( QPaintEvent* ); |
45 | 47 | int setToggleButton(int); | |
46 | int openDSP(); | 48 | int openDSP(); |
47 | int openWAV(const char *filename); | 49 | int openWAV(const char *filename); |
48 | bool fromToggle; | 50 | bool fromToggle; |
49 | QPixmap vmemoPixmap; | 51 | QPixmap vmemoPixmap; |