author | llornkcor <llornkcor> | 2002-07-02 17:11:46 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-02 17:11:46 (UTC) |
commit | c418781fac36feb2f392e0642ed50065bb4ef99c (patch) (unidiff) | |
tree | 1a841245d0fc5e2b09231b73378e220947db9410 | |
parent | 78172d2d23543992605e273770692b5a0a84ed32 (diff) | |
download | opie-c418781fac36feb2f392e0642ed50065bb4ef99c.zip opie-c418781fac36feb2f392e0642ed50065bb4ef99c.tar.gz opie-c418781fac36feb2f392e0642ed50065bb4ef99c.tar.bz2 |
changed default icon action from hold to tap to record
-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 | |||
@@ -225,25 +225,28 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
225 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 225 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
226 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 226 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
227 | 227 | ||
228 | if( toggleKey != -1 ) { | 228 | if( toggleKey != -1 ) { |
229 | // QPEApplication::grabKeyboard(); | 229 | // QPEApplication::grabKeyboard(); |
230 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 230 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
231 | // e << 4096; // Key_Escape | 231 | // e << 4096; // Key_Escape |
232 | // e << Key_F5; //4148 | 232 | // e << Key_F5; //4148 |
233 | e << toggleKey; | 233 | e << toggleKey; |
234 | e << QString("QPE/VMemo"); | 234 | e << QString("QPE/VMemo"); |
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(); |
240 | } | 243 | } |
241 | } | 244 | } |
242 | 245 | ||
243 | VMemo::~VMemo() | 246 | VMemo::~VMemo() |
244 | { | 247 | { |
245 | } | 248 | } |
246 | 249 | ||
247 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 250 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
248 | { | 251 | { |
249 | qDebug("receive"); | 252 | qDebug("receive"); |
@@ -258,30 +261,34 @@ void VMemo::receive( const QCString &msg, const QByteArray &data ) | |||
258 | } | 261 | } |
259 | } | 262 | } |
260 | } | 263 | } |
261 | 264 | ||
262 | void VMemo::paintEvent( QPaintEvent* ) | 265 | void VMemo::paintEvent( QPaintEvent* ) |
263 | { | 266 | { |
264 | QPainter p(this); | 267 | QPainter p(this); |
265 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 268 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
266 | } | 269 | } |
267 | 270 | ||
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 | ||
278 | bool VMemo::startRecording() { | 285 | bool VMemo::startRecording() { |
279 | 286 | ||
280 | if ( recording) | 287 | if ( recording) |
281 | return FALSE; | 288 | return FALSE; |
282 | 289 | ||
283 | Config config( "Vmemo" ); | 290 | Config config( "Vmemo" ); |
284 | config.setGroup( "System" ); | 291 | config.setGroup( "System" ); |
285 | 292 | ||
286 | useAlerts = config.readBoolEntry("Alert",1); | 293 | useAlerts = config.readBoolEntry("Alert",1); |
287 | if(useAlerts) { | 294 | if(useAlerts) { |
@@ -350,42 +357,44 @@ bool VMemo::startRecording() { | |||
350 | 357 | ||
351 | QArray<int> cats(1); | 358 | QArray<int> cats(1); |
352 | cats[0] = config.readNumEntry("Category", 0); | 359 | cats[0] = config.readNumEntry("Category", 0); |
353 | 360 | ||
354 | QString dlName("vm_"); | 361 | QString dlName("vm_"); |
355 | dlName += dt.toString(); | 362 | dlName += dt.toString(); |
356 | DocLnk l; | 363 | DocLnk l; |
357 | l.setFile(fileName); | 364 | l.setFile(fileName); |
358 | l.setName(dlName); | 365 | l.setName(dlName); |
359 | l.setType("audio/x-wav"); | 366 | l.setType("audio/x-wav"); |
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 | ||
382 | int VMemo::openDSP() | 391 | int VMemo::openDSP() |
383 | { | 392 | { |
384 | Config cfg("Vmemo"); | 393 | Config cfg("Vmemo"); |
385 | cfg.setGroup("Record"); | 394 | cfg.setGroup("Record"); |
386 | 395 | ||
387 | speed = cfg.readNumEntry("SampleRate", 22050); | 396 | speed = cfg.readNumEntry("SampleRate", 22050); |
388 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 397 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
389 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 398 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
390 | format = AFMT_S16_LE; | 399 | format = AFMT_S16_LE; |
391 | resolution = 16; | 400 | resolution = 16; |
@@ -471,59 +480,58 @@ void VMemo::record(void) | |||
471 | msg.sprintf("Recording format %d", format); | 480 | msg.sprintf("Recording format %d", format); |
472 | qDebug(msg); | 481 | qDebug(msg); |
473 | Config config("Vmemo"); | 482 | Config config("Vmemo"); |
474 | config.setGroup("Record"); | 483 | config.setGroup("Record"); |
475 | int sRate=config.readNumEntry("SizeLimit", 30); | 484 | int sRate=config.readNumEntry("SizeLimit", 30); |
476 | 485 | ||
477 | t_timer->start( sRate * 1000+1000, TRUE); | 486 | t_timer->start( sRate * 1000+1000, TRUE); |
478 | 487 | ||
479 | if(systemZaurus) { | 488 | if(systemZaurus) { |
480 | 489 | ||
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) { |
486 | 495 | ||
487 | 496 | ||
488 | 497 | ||
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 | ||
494 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 503 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
495 | monoBuffer[i] = sound[i]; | 504 | monoBuffer[i] = sound[i]; |
496 | } | 505 | } |
497 | 506 | ||
498 | length+=write(wav, monoBuffer, result); | 507 | length+=write(wav, monoBuffer, result); |
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; |
505 | 513 | ||
506 | // j++; | 514 | // j++; |
507 | // } | 515 | // } |
508 | qApp->processEvents(); | 516 | qApp->processEvents(); |
509 | // printf("%d\r",length); | 517 | // printf("%d\r",length); |
510 | // fflush(stdout); | 518 | // fflush(stdout); |
511 | } | 519 | } |
512 | 520 | ||
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 | ||
520 | // if(systemZaurus) { | 528 | // if(systemZaurus) { |
521 | 529 | ||
522 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 530 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
523 | monoBuffer[i] = sound[i]; | 531 | monoBuffer[i] = sound[i]; |
524 | } | 532 | } |
525 | 533 | ||
526 | length+=write(wav, monoBuffer, result); | 534 | length+=write(wav, monoBuffer, result); |
527 | 535 | ||
528 | // for (int i = 0; i < result; i+=2) { | 536 | // for (int i = 0; i < result; i+=2) { |
529 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 537 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; |
@@ -535,32 +543,33 @@ void VMemo::record(void) | |||
535 | // fflush(stdout); | 543 | // fflush(stdout); |
536 | } | 544 | } |
537 | 545 | ||
538 | qApp->processEvents(); | 546 | qApp->processEvents(); |
539 | } | 547 | } |
540 | 548 | ||
541 | } else { // 16 bit only capabilities | 549 | } else { // 16 bit only capabilities |
542 | 550 | ||
543 | 551 | ||
544 | msg.sprintf("Recording format other"); | 552 | msg.sprintf("Recording format other"); |
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 | ||
557 | recording=false; | 566 | recording=false; |
558 | perror("dev/dsp's is a lookin' messy"); | 567 | perror("dev/dsp's is a lookin' messy"); |
559 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 568 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
560 | } | 569 | } |
561 | // printf("%d\r",length); | 570 | // printf("%d\r",length); |
562 | // fflush(stdout); | 571 | // fflush(stdout); |
563 | qApp->processEvents(); | 572 | qApp->processEvents(); |
564 | } | 573 | } |
565 | // qDebug("file has length of %d lasting %d seconds", | 574 | // qDebug("file has length of %d lasting %d seconds", |
566 | // length, (( length / speed) / channels) / 2 ); | 575 | // length, (( length / speed) / channels) / 2 ); |
@@ -580,25 +589,25 @@ void VMemo::record(void) | |||
580 | track.close(); | 589 | track.close(); |
581 | qDebug("Track closed"); | 590 | qDebug("Track closed"); |
582 | 591 | ||
583 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 592 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
584 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 593 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
585 | 594 | ||
586 | ::close(dsp); | 595 | ::close(dsp); |
587 | fileName = fileName.left(fileName.length()-4); | 596 | fileName = fileName.left(fileName.length()-4); |
588 | // if(useAlerts) | 597 | // if(useAlerts) |
589 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 598 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
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"); |
595 | cfg.setGroup("Volume"); | 604 | cfg.setGroup("Volume"); |
596 | QString foo = cfg.readEntry("Mute","TRUE"); | 605 | QString foo = cfg.readEntry("Mute","TRUE"); |
597 | if(foo.find("TRUE",0,TRUE) != -1) | 606 | if(foo.find("TRUE",0,TRUE) != -1) |
598 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 607 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
599 | 608 | ||
600 | } | 609 | } |
601 | 610 | ||
602 | int VMemo::setToggleButton(int tog) { | 611 | int VMemo::setToggleButton(int tog) { |
603 | 612 | ||
604 | for( int i=0; i < 10;i++) { | 613 | for( int i=0; i < 10;i++) { |
@@ -628,16 +637,15 @@ int VMemo::setToggleButton(int tog) { | |||
628 | return Key_F11; | 637 | return Key_F11; |
629 | break; | 638 | break; |
630 | case 8: | 639 | case 8: |
631 | return Key_F13; | 640 | return Key_F13; |
632 | break; | 641 | break; |
633 | }; | 642 | }; |
634 | } | 643 | } |
635 | return -1; | 644 | return -1; |
636 | } | 645 | } |
637 | 646 | ||
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 | |||
@@ -27,25 +27,25 @@ | |||
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | 28 | ||
29 | class VMemo : public QWidget | 29 | class VMemo : public QWidget |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | VMemo( QWidget *parent, const char *name = NULL); | 33 | VMemo( QWidget *parent, const char *name = NULL); |
34 | ~VMemo(); | 34 | ~VMemo(); |
35 | QFile track; | 35 | QFile track; |
36 | QString fileName, errorMsg; | 36 | QString fileName, errorMsg; |
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(); |
42 | void mousePressEvent( QMouseEvent * ); | 42 | void mousePressEvent( QMouseEvent * ); |
43 | void mouseReleaseEvent( QMouseEvent * ); | 43 | void mouseReleaseEvent( QMouseEvent * ); |
44 | void receive( const QCString &msg, const QByteArray &data ); | 44 | void receive( const QCString &msg, const QByteArray &data ); |
45 | bool startRecording(); | 45 | bool startRecording(); |
46 | void stopRecording(); | 46 | void stopRecording(); |
47 | void timerBreak(); | 47 | void timerBreak(); |
48 | private: | 48 | private: |
49 | bool useAlerts; | 49 | bool useAlerts; |
50 | void paintEvent( QPaintEvent* ); | 50 | void paintEvent( QPaintEvent* ); |
51 | int setToggleButton(int); | 51 | int setToggleButton(int); |