-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 58 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 2 |
2 files changed, 34 insertions, 26 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index cb3e45e..2c3edf1 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -235,5 +235,8 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
235 | e << QString("toggleRecord()"); | 235 | e << QString("toggleRecord()"); |
236 | } | 236 | } |
237 | 237 | if(toggleKey == 1) | |
238 | usingIcon=TRUE; | ||
239 | else | ||
240 | usingIcon=FALSE; | ||
238 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 241 | if( vmCfg.readNumEntry("hideIcon",0) == 1) |
239 | hide(); | 242 | hide(); |
@@ -268,10 +271,14 @@ void VMemo::paintEvent( QPaintEvent* ) | |||
268 | void VMemo::mousePressEvent( QMouseEvent * ) | 271 | void VMemo::mousePressEvent( QMouseEvent * ) |
269 | { | 272 | { |
270 | startRecording(); | 273 | if(!recording) |
274 | startRecording(); | ||
275 | else | ||
276 | stopRecording(); | ||
271 | } | 277 | } |
272 | 278 | ||
273 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 279 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
274 | { | 280 | { |
275 | stopRecording(); | 281 | // if(usingIcon && !recording) |
282 | // stopRecording(); | ||
276 | } | 283 | } |
277 | 284 | ||
@@ -360,22 +367,24 @@ bool VMemo::startRecording() { | |||
360 | l.setCategories(cats); | 367 | l.setCategories(cats); |
361 | l.writeLink(); | 368 | l.writeLink(); |
362 | |||
363 | 369 | ||
364 | record(); | 370 | record(); |
365 | // delete msgLabel; | 371 | |
366 | return TRUE; | 372 | return TRUE; |
367 | } | 373 | } |
368 | 374 | ||
369 | void VMemo::stopRecording() { | 375 | void VMemo::stopRecording() { |
370 | show(); | 376 | show(); |
371 | qDebug("Stopped recording"); | 377 | qDebug("Stopped recording"); |
372 | recording = FALSE; | 378 | recording = FALSE; |
373 | if(useAlerts) | 379 | if(useAlerts) { |
374 | if( msgLabel) delete msgLabel; | 380 | msgLabel->close(); |
375 | t_timer->stop(); | 381 | msgLabel=0; |
376 | Config cfg("Vmemo"); | 382 | delete msgLabel; |
377 | cfg.setGroup("Defaults"); | 383 | } |
384 | t_timer->stop(); | ||
385 | Config cfg("Vmemo"); | ||
386 | cfg.setGroup("Defaults"); | ||
378 | if( cfg.readNumEntry("hideIcon",0) == 1 ) | 387 | if( cfg.readNumEntry("hideIcon",0) == 1 ) |
379 | hide(); | 388 | hide(); |
380 | } | 389 | } |
381 | 390 | ||
@@ -481,5 +490,5 @@ void VMemo::record(void) | |||
481 | msg.sprintf("Recording format zaurus"); | 490 | msg.sprintf("Recording format zaurus"); |
482 | qDebug(msg); | 491 | qDebug(msg); |
483 | signed short sound[512], monoBuffer[512]; | 492 | signed short sound[1024], monoBuffer[1024]; |
484 | 493 | ||
485 | if(format==AFMT_S16_LE) { | 494 | if(format==AFMT_S16_LE) { |
@@ -489,5 +498,5 @@ void VMemo::record(void) | |||
489 | while(recording) { | 498 | while(recording) { |
490 | 499 | ||
491 | result = read(dsp, sound, 512); // 8192 | 500 | result = read(dsp, sound, 1024); // 8192 |
492 | // int j=0; | 501 | // int j=0; |
493 | 502 | ||
@@ -499,6 +508,5 @@ void VMemo::record(void) | |||
499 | if(length<0) | 508 | if(length<0) |
500 | recording=false; | 509 | recording=false; |
501 | 510 | // for (int i = 0; i < result; i+=2) { | |
502 | // for (int i = 0; i < result; i+=2) { | ||
503 | // monoBuffer[j] = sound[i]; | 511 | // monoBuffer[j] = sound[i]; |
504 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 512 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; |
@@ -513,7 +521,7 @@ void VMemo::record(void) | |||
513 | } else { //AFMT_U8 | 521 | } else { //AFMT_U8 |
514 | // 8bit unsigned | 522 | // 8bit unsigned |
515 | unsigned short sound[512], monoBuffer[512]; | 523 | unsigned short sound[1024], monoBuffer[1024]; |
516 | while(recording) { | 524 | while(recording) { |
517 | result = read(dsp, sound, 512); // 8192 | 525 | result = read(dsp, sound, 1024); // 8192 |
518 | // int j=0; | 526 | // int j=0; |
519 | 527 | ||
@@ -545,12 +553,13 @@ void VMemo::record(void) | |||
545 | qDebug(msg); | 553 | qDebug(msg); |
546 | 554 | ||
547 | signed short sound[512];//, monoBuffer[512]; | 555 | signed short sound[1024];//, monoBuffer[512]; |
548 | 556 | ||
549 | while(recording) { | 557 | while(recording) { |
550 | 558 | ||
551 | result = read(dsp, sound, 512); // 8192 | 559 | result = read(dsp, sound, 1024); // 8192 |
552 | 560 | ||
553 | write(wav, sound, result); | 561 | write(wav, sound, result); |
554 | length += result; | 562 | length += result; |
563 | |||
555 | if(length<0) { | 564 | if(length<0) { |
556 | 565 | ||
@@ -590,5 +599,5 @@ void VMemo::record(void) | |||
590 | qDebug("done recording "+fileName); | 599 | qDebug("done recording "+fileName); |
591 | 600 | ||
592 | QSound::play(Resource::findSound("vmemoe")); | 601 | // QSound::play(Resource::findSound("vmemoe")); |
593 | 602 | ||
594 | Config cfg("qpe"); | 603 | Config cfg("qpe"); |
@@ -638,6 +647,5 @@ int VMemo::setToggleButton(int tog) { | |||
638 | void VMemo::timerBreak() { | 647 | void VMemo::timerBreak() { |
639 | //stop | 648 | //stop |
640 | recording=false; | 649 | stopRecording(); |
641 | |||
642 | QMessageBox::message("Vmemo","Vmemo recording has \ntimed out"); | 650 | QMessageBox::message("Vmemo","Vmemo recording has \ntimed out"); |
643 | } | 651 | } |
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h index 51ace35..823c7b8 100644 --- a/core/applets/vmemo/vmemo.h +++ b/core/applets/vmemo/vmemo.h | |||
@@ -37,5 +37,5 @@ public: | |||
37 | QLabel* msgLabel; | 37 | QLabel* msgLabel; |
38 | QTimer *t_timer; | 38 | QTimer *t_timer; |
39 | 39 | bool usingIcon; | |
40 | public slots: | 40 | public slots: |
41 | void record(); | 41 | void record(); |