-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 101 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.h | 2 |
2 files changed, 40 insertions, 63 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index c237726..6793b4e 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -341,608 +341,585 @@ void playIt() | |||
341 | timeSlider->setValue( total/4); | 341 | timeSlider->setValue( total/4); |
342 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 342 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
343 | // if(filePara.numberOfRecordedSeconds>1) | 343 | // if(filePara.numberOfRecordedSeconds>1) |
344 | // timeLabel->setText( timeString+ tr(" seconds")); | 344 | // timeLabel->setText( timeString+ tr(" seconds")); |
345 | // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); | 345 | // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); |
346 | // fflush(stdout); | 346 | // fflush(stdout); |
347 | 347 | ||
348 | qApp->processEvents(); | 348 | qApp->processEvents(); |
349 | 349 | ||
350 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 350 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
351 | // if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { | 351 | // if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { |
352 | stopped = true; | 352 | stopped = true; |
353 | break; | 353 | break; |
354 | } | 354 | } |
355 | } | 355 | } |
356 | } else { | 356 | } else { |
357 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> | 357 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> |
358 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; | 358 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; |
359 | memset( inbuffer, 0, BUFSIZE); | 359 | memset( inbuffer, 0, BUFSIZE); |
360 | memset( outbuffer, 0, BUFSIZE); | 360 | memset( outbuffer, 0, BUFSIZE); |
361 | 361 | ||
362 | for(;;) { // play loop | 362 | for(;;) { // play loop |
363 | if ( stopped) { | 363 | if ( stopped) { |
364 | break; | 364 | break; |
365 | return; | 365 | return; |
366 | } | 366 | } |
367 | // stop if playing was set to false | 367 | // stop if playing was set to false |
368 | number = ::read( filePara.fd, inbuffer, BUFSIZE); | 368 | number = ::read( filePara.fd, inbuffer, BUFSIZE); |
369 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 369 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
370 | // // for (int i=0;i< number ; i++) { //2*i is left channel | 370 | // // for (int i=0;i< number ; i++) { //2*i is left channel |
371 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; | 371 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; |
372 | // } | 372 | // } |
373 | bytesWritten = ::write( filePara.sd, inbuffer, number); | 373 | bytesWritten = ::write( filePara.sd, inbuffer, number); |
374 | waveform->newSamples( inbuffer, number); | 374 | waveform->newSamples( inbuffer, number); |
375 | //-------------->>>> out to device | 375 | //-------------->>>> out to device |
376 | // total+=bytesWritten; | 376 | // total+=bytesWritten; |
377 | // if(filePara.channels==1) | 377 | // if(filePara.channels==1) |
378 | // total += bytesWritten/2; //mono | 378 | // total += bytesWritten/2; //mono |
379 | // else | 379 | // else |
380 | total += bytesWritten; | 380 | total += bytesWritten; |
381 | timeSlider->setValue( total); | 381 | timeSlider->setValue( total); |
382 | 382 | ||
383 | filePara.numberSamples = total; | 383 | filePara.numberSamples = total; |
384 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; | 384 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; |
385 | 385 | ||
386 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); | 386 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); |
387 | // timeLabel->setText( timeString + tr(" seconds")); | 387 | // timeLabel->setText( timeString + tr(" seconds")); |
388 | 388 | ||
389 | qApp->processEvents(); | 389 | qApp->processEvents(); |
390 | 390 | ||
391 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 391 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
392 | owarn << "Jane! Stop this crazy thing!" << oendl; | 392 | owarn << "Jane! Stop this crazy thing!" << oendl; |
393 | stopped = true; | 393 | stopped = true; |
394 | // playing = false; | 394 | // playing = false; |
395 | break; | 395 | break; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | // printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); | 398 | // printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); |
399 | // fflush(stdout); | 399 | // fflush(stdout); |
400 | } //end loop | 400 | } //end loop |
401 | } else { | 401 | } else { |
402 | /////////////////////////////// format = AFMT_U8; | 402 | /////////////////////////////// format = AFMT_U8; |
403 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; | 403 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; |
404 | memset( unsigned_inbuffer, 0, BUFSIZE); | 404 | memset( unsigned_inbuffer, 0, BUFSIZE); |
405 | for(;;) { | 405 | for(;;) { |
406 | // main loop | 406 | // main loop |
407 | if (stopped) { | 407 | if (stopped) { |
408 | break; // stop if playing was set to false | 408 | break; // stop if playing was set to false |
409 | return; | 409 | return; |
410 | } | 410 | } |
411 | number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); | 411 | number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); |
412 | //data = (val >> 8) ^ 0x80; | 412 | //data = (val >> 8) ^ 0x80; |
413 | // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; | 413 | // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; |
414 | bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); | 414 | bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); |
415 | waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); | 415 | waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); |
416 | total += bytesWritten; | 416 | total += bytesWritten; |
417 | 417 | ||
418 | timeSlider->setValue( total); | 418 | timeSlider->setValue( total); |
419 | filePara.numberSamples = total; | 419 | filePara.numberSamples = total; |
420 | 420 | ||
421 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; | 421 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; |
422 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); | 422 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); |
423 | // timeLabel->setText( timeString + tr(" seconds")); | 423 | // timeLabel->setText( timeString + tr(" seconds")); |
424 | qApp->processEvents(); | 424 | qApp->processEvents(); |
425 | 425 | ||
426 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 426 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
427 | // if( total >= filePara.numberSamples ) { | 427 | // if( total >= filePara.numberSamples ) { |
428 | stopped = true; | 428 | stopped = true; |
429 | break; | 429 | break; |
430 | } | 430 | } |
431 | // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); | 431 | // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); |
432 | // fflush(stdout); | 432 | // fflush(stdout); |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
438 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | 438 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) |
439 | : QWidget( parent, name, fl ) | 439 | : QWidget( parent, name, fl ) |
440 | { | 440 | { |
441 | if ( !name ) | 441 | if ( !name ) |
442 | setName( "OpieRec" ); | 442 | setName( "OpieRec" ); |
443 | init(); | 443 | init(); |
444 | initConfig(); | 444 | initConfig(); |
445 | initConnections(); | 445 | initConnections(); |
446 | renameBox = 0; | 446 | renameBox = 0; |
447 | 447 | ||
448 | // open sound device to get volumes | 448 | // open sound device to get volumes |
449 | Config hwcfg("OpieRec"); | 449 | Config hwcfg("OpieRec"); |
450 | hwcfg.setGroup("Hardware"); | 450 | hwcfg.setGroup("Hardware"); |
451 | 451 | ||
452 | 452 | ||
453 | soundDevice = new Device( this, | 453 | soundDevice = new Device( this, |
454 | hwcfg.readEntry( "Audio",DSPSTROUT), | 454 | hwcfg.readEntry( "Audio",DSPSTROUT), |
455 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); | 455 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); |
456 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); | 456 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); |
457 | 457 | ||
458 | // soundDevice->setDeviceFormat(AFMT_S16_LE); | 458 | // soundDevice->setDeviceFormat(AFMT_S16_LE); |
459 | // soundDevice->setDeviceChannels(1); | 459 | // soundDevice->setDeviceChannels(1); |
460 | // soundDevice->setDeviceRate( 22050); | 460 | // soundDevice->setDeviceRate( 22050); |
461 | 461 | ||
462 | getInVol(); | 462 | getInVol(); |
463 | getOutVol(); | 463 | getOutVol(); |
464 | 464 | ||
465 | soundDevice->closeDevice( true); | 465 | soundDevice->closeDevice( true); |
466 | soundDevice->sd = -1; | 466 | soundDevice->sd = -1; |
467 | soundDevice = 0; | 467 | soundDevice = 0; |
468 | wavFile = 0; | 468 | wavFile = 0; |
469 | |||
470 | // if( soundDevice) delete soundDevice; | 469 | // if( soundDevice) delete soundDevice; |
471 | 470 | QTimer::singleShot(100,this, SLOT(initIconView())); | |
472 | initIconView(); | ||
473 | 471 | ||
474 | if( autoMute) | 472 | if( autoMute) |
475 | doMute( true); | 473 | doMute( true); |
476 | ListView1->setFocus(); | 474 | // ListView1->setFocus(); |
477 | playing = false; | 475 | playing = false; |
478 | } | 476 | } |
479 | 477 | ||
480 | QtRec::~QtRec() { | 478 | QtRec::~QtRec() { |
481 | // if( soundDevice) delete soundDevice; | 479 | // if( soundDevice) delete soundDevice; |
482 | 480 | ||
483 | } | 481 | } |
484 | 482 | ||
485 | void QtRec::cleanUp() { | 483 | void QtRec::cleanUp() { |
486 | 484 | ||
487 | if( !stopped) { | 485 | if( !stopped) { |
488 | stopped = true; | 486 | stopped = true; |
489 | endRecording(); | 487 | endRecording(); |
490 | } | 488 | } |
491 | 489 | ||
492 | ListView1->clear(); | 490 | ListView1->clear(); |
493 | 491 | ||
494 | if( autoMute) | 492 | if( autoMute) |
495 | doMute(false); | 493 | doMute(false); |
496 | 494 | ||
497 | // if( wavFile) delete wavFile; | 495 | // if( wavFile) delete wavFile; |
498 | // if(soundDevice) delete soundDevice; | 496 | // if(soundDevice) delete soundDevice; |
499 | } | 497 | } |
500 | 498 | ||
501 | void QtRec::init() { | 499 | void QtRec::init() { |
502 | 500 | ||
503 | needsStereoOut = false; | 501 | needsStereoOut = false; |
504 | QPixmap image3( ( const char** ) image3_data ); | 502 | QPixmap image3( ( const char** ) image3_data ); |
505 | QPixmap image4( ( const char** ) image4_data ); | 503 | QPixmap image4( ( const char** ) image4_data ); |
506 | QPixmap image6( ( const char** ) image6_data ); | 504 | QPixmap image6( ( const char** ) image6_data ); |
507 | 505 | ||
508 | stopped = true; | 506 | stopped = true; |
509 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 507 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
510 | QGridLayout *layout = new QGridLayout( this ); | 508 | QGridLayout *layout = new QGridLayout( this ); |
511 | layout->setSpacing( 2); | 509 | layout->setSpacing( 2); |
512 | layout->setMargin( 2); | 510 | layout->setMargin( 2); |
513 | 511 | ||
514 | TabWidget = new QTabWidget( this, "TabWidget" ); | 512 | TabWidget = new QTabWidget( this, "TabWidget" ); |
515 | layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); | 513 | layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); |
516 | // TabWidget->setTabShape(QTabWidget::Triangular); | 514 | // TabWidget->setTabShape(QTabWidget::Triangular); |
517 | 515 | ||
518 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 516 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
519 | tab = new QWidget( TabWidget, "tab" ); | 517 | tab = new QWidget( TabWidget, "tab" ); |
520 | 518 | ||
521 | QGridLayout *layout1 = new QGridLayout( tab); | 519 | QGridLayout *layout1 = new QGridLayout( tab); |
522 | layout1->setSpacing( 2); | 520 | layout1->setSpacing( 2); |
523 | layout1->setMargin( 2); | 521 | layout1->setMargin( 2); |
524 | 522 | ||
525 | timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); | 523 | timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); |
526 | layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); | 524 | layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); |
527 | 525 | ||
528 | // timeLabel = new QLabel( tab, "TimeLabel" ); | 526 | // timeLabel = new QLabel( tab, "TimeLabel" ); |
529 | // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); | 527 | // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); |
530 | 528 | ||
531 | // playLabel2 = new QLabel(tab, "PlayLabel2" ); | 529 | // playLabel2 = new QLabel(tab, "PlayLabel2" ); |
532 | // playLabel2->setText(tr("Play") ); | 530 | // playLabel2->setText(tr("Play") ); |
533 | // playLabel2->setFixedHeight( 18); | 531 | // playLabel2->setFixedHeight( 18); |
534 | // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); | 532 | // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); |
535 | 533 | ||
536 | Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); | 534 | Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); |
537 | layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); | 535 | layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); |
538 | Stop_PushButton->setFixedSize( 22, 22); | 536 | Stop_PushButton->setFixedSize( 22, 22); |
539 | Stop_PushButton->setPixmap( image4 ); | 537 | Stop_PushButton->setPixmap( image4 ); |
540 | 538 | ||
541 | toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); | 539 | toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); |
542 | layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); | 540 | layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); |
543 | toBeginningButton->setFixedSize( 22, 22); | 541 | toBeginningButton->setFixedSize( 22, 22); |
544 | toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); | 542 | toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); |
545 | 543 | ||
546 | toEndButton = new QPushButton( tab, "End_PushButton" ); | 544 | toEndButton = new QPushButton( tab, "End_PushButton" ); |
547 | layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); | 545 | layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); |
548 | toEndButton->setFixedSize( 22, 22); | 546 | toEndButton->setFixedSize( 22, 22); |
549 | toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); | 547 | toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); |
550 | 548 | ||
551 | // QLabel *recLabel2; | 549 | // QLabel *recLabel2; |
552 | // recLabel2 = new QLabel( tab, "recLabel2" ); | 550 | // recLabel2 = new QLabel( tab, "recLabel2" ); |
553 | // recLabel2->setText(tr("Rec")); | 551 | // recLabel2->setText(tr("Rec")); |
554 | // recLabel2->setFixedHeight( 18); | 552 | // recLabel2->setFixedHeight( 18); |
555 | // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); | 553 | // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); |
556 | 554 | ||
557 | Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); | 555 | Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); |
558 | layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); | 556 | layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); |
559 | Rec_PushButton->setFixedSize( 22, 22); | 557 | Rec_PushButton->setFixedSize( 22, 22); |
560 | Rec_PushButton->setPixmap( image6 ); | 558 | Rec_PushButton->setPixmap( image6 ); |
561 | 559 | ||
562 | t = new QTimer( this ); | 560 | t = new QTimer( this ); |
563 | connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 561 | connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
564 | 562 | ||
565 | rewindTimer = new QTimer( this ); | 563 | rewindTimer = new QTimer( this ); |
566 | connect( rewindTimer, SIGNAL( timeout() ), | 564 | connect( rewindTimer, SIGNAL( timeout() ), |
567 | this, SLOT( rewindTimerTimeout() ) ); | 565 | this, SLOT( rewindTimerTimeout() ) ); |
568 | 566 | ||
569 | forwardTimer = new QTimer( this ); | 567 | forwardTimer = new QTimer( this ); |
570 | connect( forwardTimer, SIGNAL( timeout() ), | 568 | connect( forwardTimer, SIGNAL( timeout() ), |
571 | this, SLOT( forwardTimerTimeout() ) ); | 569 | this, SLOT( forwardTimerTimeout() ) ); |
572 | 570 | ||
573 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); | 571 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); |
574 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); | 572 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); |
575 | deleteSoundButton->setText( tr( "Del" ) ); | 573 | deleteSoundButton->setText( tr( "Del" ) ); |
576 | 574 | ||
577 | ListView1 = new QListView( tab, "IconView1" ); | 575 | ListView1 = new QListView( tab, "IconView1" ); |
578 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); | 576 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); |
579 | 577 | ||
580 | ListView1->addColumn( tr( "Name" ) ); | 578 | ListView1->addColumn( tr( "Name" ) ); |
581 | // ListView1->setColumnWidth( 0, 140); | 579 | // ListView1->setColumnWidth( 0, 140); |
582 | ListView1->setSorting( 1, false); | 580 | ListView1->setSorting( 1, false); |
583 | ListView1->addColumn( tr( "Time" ) ); //in seconds | 581 | ListView1->addColumn( tr( "Time" ) ); //in seconds |
584 | // ListView1->setColumnWidth( 1, -1); | 582 | // ListView1->setColumnWidth( 1, -1); |
585 | // ListView1->addColumn( tr("Location") ); | 583 | // ListView1->addColumn( tr("Location") ); |
586 | // ListView1->setColumnWidth( 2, -1); | 584 | // ListView1->setColumnWidth( 2, -1); |
587 | // ListView1->addColumn( tr("Date") ); | 585 | // ListView1->addColumn( tr("Date") ); |
588 | // ListView1->setColumnWidth( 3, -1); | 586 | // ListView1->setColumnWidth( 3, -1); |
589 | ListView1->setColumnWidthMode(0, QListView::Maximum); | 587 | ListView1->setColumnWidthMode(0, QListView::Maximum); |
590 | // ListView1->setColumnWidthMode(1, QListView::Maximum); | 588 | // ListView1->setColumnWidthMode(1, QListView::Maximum); |
591 | 589 | ||
592 | // ListView1->setColumnWidthMode( 0, QListView::Manual); | 590 | // ListView1->setColumnWidthMode( 0, QListView::Manual); |
593 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); | 591 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); |
594 | // ListView1->setColumnAlignment( 2, QListView::AlignRight); | 592 | // ListView1->setColumnAlignment( 2, QListView::AlignRight); |
595 | // ListView1->setColumnAlignment( 3, QListView::AlignLeft); | 593 | // ListView1->setColumnAlignment( 3, QListView::AlignLeft); |
596 | ListView1->setAllColumnsShowFocus( true ); | 594 | ListView1->setAllColumnsShowFocus( true ); |
597 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); | 595 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); |
598 | 596 | ||
599 | TabWidget->insertTab( tab, tr( "Files" ) ); | 597 | TabWidget->insertTab( tab, tr( "Files" ) ); |
600 | 598 | ||
601 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 599 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
602 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 600 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
603 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); | 601 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); |
604 | glayout3->setSpacing( 2); | 602 | glayout3->setSpacing( 2); |
605 | glayout3->setMargin( 2); | 603 | glayout3->setMargin( 2); |
606 | //////////////////////////////////// | 604 | //////////////////////////////////// |
607 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); | 605 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); |
608 | sampleGroup->setTitle( tr( "Sample Rate" ) ); | 606 | sampleGroup->setTitle( tr( "Sample Rate" ) ); |
609 | sampleGroup->setFixedSize( 95,50); | 607 | sampleGroup->setFixedSize( 95,50); |
610 | 608 | ||
611 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 609 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
612 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 610 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
613 | //#ifndef QT_QWS_EBX | 611 | //#ifndef QT_QWS_EBX |
614 | QString s; | 612 | QString s; |
615 | int z = 0; | 613 | int z = 0; |
616 | while( deviceSampleRates[z] != -1) { | 614 | while( deviceSampleRates[z] != -1) { |
617 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); | 615 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); |
618 | z++; | 616 | z++; |
619 | } | 617 | } |
620 | 618 | ||
621 | 619 | ||
622 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); | 620 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); |
623 | 621 | ||
624 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); | 622 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); |
625 | sizeGroup->setTitle( tr( "Limit Size" ) ); | 623 | sizeGroup->setTitle( tr( "Limit Size" ) ); |
626 | sizeGroup->setFixedSize( 80, 50); | 624 | sizeGroup->setFixedSize( 80, 50); |
627 | 625 | ||
628 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); | 626 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); |
629 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); | 627 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); |
630 | sizeLimitCombo->insertItem(tr("Unlimited")); | 628 | sizeLimitCombo->insertItem(tr("Unlimited")); |
631 | 629 | ||
632 | for(int i=1;i<13; i++) { | 630 | for(int i=1;i<13; i++) { |
633 | sizeLimitCombo->insertItem( QString::number( i * 5)); | 631 | sizeLimitCombo->insertItem( QString::number( i * 5)); |
634 | } | 632 | } |
635 | 633 | ||
636 | 634 | ||
637 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); | 635 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); |
638 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); | 636 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); |
639 | dirGroup->setTitle( tr( "File Directory" ) ); | 637 | dirGroup->setTitle( tr( "File Directory" ) ); |
640 | dirGroup->setFixedSize( 130, 50); | 638 | dirGroup->setFixedSize( 130, 50); |
641 | 639 | ||
642 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); | 640 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); |
643 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); | 641 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); |
644 | 642 | ||
645 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); | 643 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); |
646 | 644 | ||
647 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); | 645 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); |
648 | bitGroup->setTitle( tr( "Bit Depth" ) ); | 646 | bitGroup->setTitle( tr( "Bit Depth" ) ); |
649 | bitGroup->setFixedSize( 65, 50); | 647 | bitGroup->setFixedSize( 65, 50); |
650 | 648 | ||
651 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); | 649 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); |
652 | 650 | ||
653 | z = 0; | 651 | z = 0; |
654 | while( deviceBitRates[z] != -1) { | 652 | while( deviceBitRates[z] != -1) { |
655 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); | 653 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); |
656 | z++; | 654 | z++; |
657 | } | 655 | } |
658 | 656 | ||
659 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | 657 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); |
660 | 658 | ||
661 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); | 659 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); |
662 | 660 | ||
663 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); | 661 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); |
664 | 662 | ||
665 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); | 663 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); |
666 | stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 ); | 664 | stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 ); |
667 | 665 | ||
668 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); | 666 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); |
669 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); | 667 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); |
670 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); | 668 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); |
671 | 669 | ||
672 | tab_5 = new QWidget( TabWidget, "tab_5" ); | 670 | tab_5 = new QWidget( TabWidget, "tab_5" ); |
673 | 671 | ||
674 | QHBoxLayout *Layout19a; | 672 | QHBoxLayout *Layout19a; |
675 | Layout19a = new QHBoxLayout( tab_5); | 673 | Layout19a = new QHBoxLayout( tab_5); |
676 | Layout19a->setSpacing( 2 ); | 674 | Layout19a->setSpacing( 2 ); |
677 | Layout19a->setMargin( 0 ); | 675 | Layout19a->setMargin( 0 ); |
678 | 676 | ||
679 | Layout15 = new QVBoxLayout( this); | 677 | Layout15 = new QVBoxLayout( this); |
680 | Layout15->setSpacing( 2 ); | 678 | Layout15->setSpacing( 2 ); |
681 | Layout15->setMargin( 0 ); | 679 | Layout15->setMargin( 0 ); |
682 | 680 | ||
683 | Layout15b = new QVBoxLayout( this); | 681 | Layout15b = new QVBoxLayout( this); |
684 | Layout15b->setSpacing( 2 ); | 682 | Layout15b->setSpacing( 2 ); |
685 | Layout15b->setMargin( 0 ); | 683 | Layout15b->setMargin( 0 ); |
686 | 684 | ||
687 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); | 685 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); |
688 | TextLabel2->setText( tr( "In")); | 686 | TextLabel2->setText( tr( "In")); |
689 | TextLabel2->setFixedWidth( 35); | 687 | TextLabel2->setFixedWidth( 35); |
690 | Layout15->addWidget( TextLabel2 ); | 688 | Layout15->addWidget( TextLabel2 ); |
691 | 689 | ||
692 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); | 690 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); |
693 | TextLabel3->setText( tr( "Out" ) ); | 691 | TextLabel3->setText( tr( "Out" ) ); |
694 | Layout15b->addWidget( TextLabel3 ); | 692 | Layout15b->addWidget( TextLabel3 ); |
695 | 693 | ||
696 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); | 694 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); |
697 | InputSlider->setTickmarks( QSlider::Both); | 695 | InputSlider->setTickmarks( QSlider::Both); |
698 | Layout15->addWidget( InputSlider); | 696 | Layout15->addWidget( InputSlider); |
699 | 697 | ||
700 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); | 698 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); |
701 | OutputSlider->setTickmarks( QSlider::Both); | 699 | OutputSlider->setTickmarks( QSlider::Both); |
702 | 700 | ||
703 | Layout15b->addWidget( OutputSlider ); | 701 | Layout15b->addWidget( OutputSlider ); |
704 | 702 | ||
705 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 703 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
706 | Layout15->addWidget( outMuteCheckBox ); | 704 | Layout15->addWidget( outMuteCheckBox ); |
707 | 705 | ||
708 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 706 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
709 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); | 707 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); |
710 | Layout15b->addWidget( inMuteCheckBox ); | 708 | Layout15b->addWidget( inMuteCheckBox ); |
711 | 709 | ||
712 | 710 | ||
713 | Layout19a->addLayout( Layout15 ); | 711 | Layout19a->addLayout( Layout15 ); |
714 | Layout19a->addLayout( Layout15b ); | 712 | Layout19a->addLayout( Layout15b ); |
715 | 713 | ||
716 | fillDirectoryCombo(); | 714 | fillDirectoryCombo(); |
717 | 715 | ||
718 | TabWidget->insertTab( tab_3, tr( "Options" ) ); | 716 | TabWidget->insertTab( tab_3, tr( "Options" ) ); |
719 | 717 | ||
720 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); | 718 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); |
721 | 719 | ||
722 | 720 | ||
723 | waveform = new Waveform( this, "waveform" ); | 721 | waveform = new Waveform( this, "waveform" ); |
724 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); | 722 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); |
725 | waveform->setMinimumSize( QSize( 0, 50 ) ); | 723 | waveform->setMinimumSize( QSize( 0, 50 ) ); |
726 | 724 | ||
727 | layout->addMultiCellWidget( waveform, 8, 8, 0, 8); | 725 | layout->addMultiCellWidget( waveform, 8, 8, 0, 8); |
728 | waveform->setBackgroundColor ( black ); | 726 | waveform->setBackgroundColor ( black ); |
729 | } | 727 | } |
730 | 728 | ||
731 | void QtRec::initIconView() { | 729 | void QtRec::initIconView() { |
732 | 730 | owarn << "initIconView" << oendl; | |
733 | ListView1->clear(); | 731 | ListView1->clear(); |
734 | Config cfg("OpieRec"); | 732 | Config cfg("OpieRec"); |
735 | cfg.setGroup("Sounds"); | 733 | cfg.setGroup("Sounds"); |
736 | QString temp; | 734 | QString temp; |
737 | QPixmap image0( ( const char** ) image0_data ); | 735 | QPixmap image0( ( const char** ) image0_data ); |
738 | 736 | ||
739 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 737 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
740 | // odebug << "init number of files " << nFiles << "" << oendl; | 738 | owarn << "init number of files " << nFiles << "" << oendl; |
741 | 739 | ||
742 | for(int i=1;i<= nFiles;i++) { | 740 | for(int i = 1; i <= nFiles; i++) { |
743 | 741 | ||
744 | QListViewItem * item; | 742 | QListViewItem * item; |
745 | QString fileS, mediaLocation, fileDate, filePath; | 743 | QString fileS, mediaLocation, fileDate, filePath; |
746 | 744 | ||
747 | temp.sprintf( "%d",i); | 745 | temp.sprintf( "%d",i); |
748 | temp = cfg.readEntry( temp,""); //reads currentFile | 746 | temp = cfg.readEntry( temp,""); //reads currentFile |
749 | filePath = cfg.readEntry( temp,""); //currentFileName | 747 | filePath = cfg.readEntry( temp,""); //currentFileName |
750 | 748 | ||
751 | QFileInfo info(filePath); | 749 | QFileInfo info(filePath); |
752 | fileDate = info.lastModified().toString(); | 750 | fileDate = info.lastModified().toString(); |
753 | 751 | ||
754 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds | 752 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds |
755 | mediaLocation = getStorage( filePath); | 753 | mediaLocation = getStorage( filePath); |
756 | if( info.exists()) { | 754 | if( info.exists()) { |
755 | owarn << "new item " << temp << oendl; | ||
757 | item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); | 756 | item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); |
758 | item->setPixmap( 0, image0); | 757 | item->setPixmap( 0, image0); |
759 | if( currentFileName == filePath) | 758 | if( currentFileName == filePath) |
760 | ListView1->setSelected( item, true); | 759 | ListView1->setSelected( item, true); |
761 | } | 760 | } |
762 | } | 761 | } |
763 | } | 762 | } |
764 | 763 | ||
765 | void QtRec::initConnections() { | 764 | void QtRec::initConnections() { |
766 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 765 | connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp())); |
767 | 766 | ||
768 | connect( toBeginningButton, SIGNAL( pressed()), | 767 | connect(toBeginningButton,SIGNAL(pressed()),this,SLOT(rewindPressed())); |
769 | this, SLOT( rewindPressed() )); | 768 | connect(toBeginningButton,SIGNAL(released()),this,SLOT(rewindReleased())); |
770 | connect( toBeginningButton, SIGNAL( released()), | 769 | connect(toEndButton,SIGNAL(pressed()),this,SLOT(FastforwardPressed())); |
771 | this, SLOT( rewindReleased() )); | 770 | connect(toEndButton,SIGNAL(released()),this,SLOT(FastforwardReleased())); |
772 | connect( toEndButton, SIGNAL( pressed()), | 771 | connect(deleteSoundButton,SIGNAL(released()),this,SLOT(deleteSound())); |
773 | this, SLOT( FastforwardPressed() )); | 772 | connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); |
774 | connect( toEndButton, SIGNAL( released()), | 773 | connect(Rec_PushButton,SIGNAL(released()),this,SLOT(newSound())); |
775 | this, SLOT( FastforwardReleased() )); | 774 | |
776 | connect( deleteSoundButton, SIGNAL(released()), | 775 | connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(thisTab(QWidget*))); |
777 | this, SLOT( deleteSound() )); | 776 | |
778 | connect( Stop_PushButton, SIGNAL(released()), | 777 | connect(OutputSlider,SIGNAL(sliderReleased()),this,SLOT(changedOutVolume())); |
779 | this, SLOT( doPlayBtn() )); | 778 | connect(InputSlider,SIGNAL(sliderReleased()),this,SLOT(changedInVolume())); |
780 | connect( Rec_PushButton, SIGNAL(released()), | 779 | |
781 | this, SLOT( newSound() ) ); | 780 | connect(sampleRateComboBox,SIGNAL(activated(int)),this,SLOT(changesamplerateCombo(int))); |
782 | connect( TabWidget, SIGNAL( currentChanged(QWidget*)), | 781 | connect(bitRateComboBox,SIGNAL(activated(int)),this,SLOT(changebitrateCombo(int))); |
783 | this, SLOT(thisTab(QWidget*) )); | 782 | connect(directoryComboBox,SIGNAL(activated(int)),this,SLOT(changeDirCombo(int))); |
784 | connect( OutputSlider, SIGNAL(sliderReleased()), | 783 | connect(sizeLimitCombo,SIGNAL(activated(int)),this,SLOT(changeSizeLimitCombo(int))); |
785 | this, SLOT( changedOutVolume()) ); | 784 | |
786 | connect( InputSlider, SIGNAL(sliderReleased()), | 785 | connect(stereoCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeStereoCheck(bool))); |
787 | this, SLOT( changedInVolume()) ); | 786 | connect(outMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doVolMuting(bool))); |
788 | 787 | connect(inMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doMicMuting(bool))); | |
789 | connect( sampleRateComboBox, SIGNAL(activated(int)), | 788 | |
790 | this, SLOT( changesamplerateCombo(int)) ); | 789 | connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itClick(QListViewItem*))); |
791 | connect( bitRateComboBox, SIGNAL(activated(int)), | 790 | connect(ListView1,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(listPressed(int,QListViewItem*,const QPoint&,int))); |
792 | this, SLOT( changebitrateCombo(int)) ); | 791 | |
793 | 792 | connect(timeSlider,SIGNAL(sliderMoved(int)),this,SLOT(changeTimeSlider(int))); | |
794 | connect( directoryComboBox, SIGNAL(activated(int)), | 793 | connect(timeSlider,SIGNAL(sliderPressed()),this,SLOT(timeSliderPressed())); |
795 | this, SLOT( changeDirCombo(int)) ); | 794 | connect(timeSlider,SIGNAL(sliderReleased()),this,SLOT(timeSliderReleased())); |
796 | connect( sizeLimitCombo, SIGNAL(activated(int)), | 795 | |
797 | this, SLOT( changeSizeLimitCombo(int)) ); | 796 | connect(compressionCheckBox,SIGNAL(toggled(bool)),this,SLOT(compressionSelected(bool))); |
798 | 797 | connect(autoMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(slotAutoMute(bool))); | |
799 | connect( stereoCheckBox, SIGNAL(toggled(bool)), | ||
800 | this, SLOT( changeStereoCheck(bool)) ); | ||
801 | |||
802 | connect( outMuteCheckBox, SIGNAL(toggled(bool)), | ||
803 | this, SLOT( doVolMuting(bool)) ); | ||
804 | connect( inMuteCheckBox , SIGNAL(toggled(bool)), | ||
805 | this, SLOT( doMicMuting(bool)) ); | ||
806 | |||
807 | connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), | ||
808 | this,SLOT( itClick(QListViewItem*))); | ||
809 | connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | ||
810 | this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); | ||
811 | connect( timeSlider, SIGNAL( sliderMoved(int)), | ||
812 | this, SLOT( changeTimeSlider(int) )); | ||
813 | connect( timeSlider, SIGNAL( sliderPressed()), | ||
814 | this, SLOT( timeSliderPressed() )); | ||
815 | connect( timeSlider, SIGNAL( sliderReleased()), | ||
816 | this, SLOT( timeSliderReleased() )); | ||
817 | connect( compressionCheckBox, SIGNAL( toggled(bool)), | ||
818 | this, SLOT( compressionSelected(bool))); | ||
819 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), | ||
820 | this, SLOT( slotAutoMute(bool))); | ||
821 | } | 798 | } |
822 | 799 | ||
823 | void QtRec::initConfig() { | 800 | void QtRec::initConfig() { |
824 | int index, fred, i; | 801 | int index, fred, i; |
825 | Config cfg("OpieRec"); | 802 | Config cfg("OpieRec"); |
826 | cfg.setGroup("Settings"); | 803 | cfg.setGroup("Settings"); |
827 | 804 | ||
828 | index = cfg.readNumEntry("samplerate",22050); | 805 | index = cfg.readNumEntry("samplerate",22050); |
829 | bool ok; | 806 | bool ok; |
830 | 807 | ||
831 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { | 808 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { |
832 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); | 809 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); |
833 | if( index == fred) { | 810 | if( index == fred) { |
834 | filePara.sampleRate = fred; | 811 | filePara.sampleRate = fred; |
835 | sampleRateComboBox->setCurrentItem(ws); | 812 | sampleRateComboBox->setCurrentItem(ws); |
836 | } | 813 | } |
837 | } | 814 | } |
838 | 815 | ||
839 | i = cfg.readNumEntry("bitrate",16); | 816 | i = cfg.readNumEntry("bitrate",16); |
840 | if(i == 16) | 817 | if(i == 16) |
841 | bitRateComboBox->setCurrentItem( 1); | 818 | bitRateComboBox->setCurrentItem( 1); |
842 | else if(i == 24) | 819 | else if(i == 24) |
843 | bitRateComboBox->setCurrentItem( 2); | 820 | bitRateComboBox->setCurrentItem( 2); |
844 | else if(i == 32) | 821 | else if(i == 32) |
845 | bitRateComboBox->setCurrentItem( 3); | 822 | bitRateComboBox->setCurrentItem( 3); |
846 | else | 823 | else |
847 | bitRateComboBox->setCurrentItem( 0); | 824 | bitRateComboBox->setCurrentItem( 0); |
848 | 825 | ||
849 | filePara.resolution = i; | 826 | filePara.resolution = i; |
850 | 827 | ||
851 | i = cfg.readNumEntry("sizeLimit", 5 ); | 828 | i = cfg.readNumEntry("sizeLimit", 5 ); |
852 | QString temp; | 829 | QString temp; |
853 | sizeLimitCombo->setCurrentItem((i/5)); | 830 | sizeLimitCombo->setCurrentItem((i/5)); |
854 | 831 | ||
855 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); | 832 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); |
856 | if( stereoCheckBox->isChecked()) { | 833 | if( stereoCheckBox->isChecked()) { |
857 | filePara.channels = 2; | 834 | filePara.channels = 2; |
858 | } else { | 835 | } else { |
859 | filePara.channels = 1; | 836 | filePara.channels = 1; |
860 | } | 837 | } |
861 | 838 | ||
862 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 839 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
863 | if( compressionCheckBox->isChecked()) { | 840 | if( compressionCheckBox->isChecked()) { |
864 | bitRateComboBox->setEnabled(false); | 841 | bitRateComboBox->setEnabled(false); |
865 | bitRateComboBox->setCurrentItem(0); | 842 | bitRateComboBox->setCurrentItem(0); |
866 | filePara.resolution=16; | 843 | filePara.resolution=16; |
867 | } | 844 | } |
868 | 845 | ||
869 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 846 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
870 | if( autoMuteCheckBox->isChecked()) | 847 | if( autoMuteCheckBox->isChecked()) |
871 | slotAutoMute(true); | 848 | slotAutoMute(true); |
872 | else | 849 | else |
873 | slotAutoMute(false); | 850 | slotAutoMute(false); |
874 | 851 | ||
875 | Config cofg( "qpe"); | 852 | Config cofg( "qpe"); |
876 | cofg.setGroup( "Volume"); | 853 | cofg.setGroup( "Volume"); |
877 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); | 854 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); |
878 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); | 855 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); |
879 | } | 856 | } |
880 | 857 | ||
881 | void QtRec::stop() { | 858 | void QtRec::stop() { |
882 | owarn << "STOP" << oendl; | 859 | owarn << "STOP" << oendl; |
883 | setRecordButton(false); | 860 | setRecordButton(false); |
884 | 861 | ||
885 | if( !recording) | 862 | if( !recording) |
886 | endPlaying(); | 863 | endPlaying(); |
887 | else | 864 | else |
888 | endRecording(); | 865 | endRecording(); |
889 | timeSlider->setValue(0); | 866 | timeSlider->setValue(0); |
890 | } | 867 | } |
891 | 868 | ||
892 | void QtRec::doPlayBtn() { | 869 | void QtRec::doPlayBtn() { |
893 | 870 | ||
894 | if(!stopped) { | 871 | if(!stopped) { |
895 | // playLabel2->setText(tr("Play")); | 872 | // playLabel2->setText(tr("Play")); |
896 | stop(); | 873 | stop(); |
897 | } else { | 874 | } else { |
898 | if(ListView1->currentItem() == 0) return; | 875 | if(ListView1->currentItem() == 0) return; |
899 | // playLabel2->setText(tr("Stop")); | 876 | // playLabel2->setText(tr("Stop")); |
900 | currentFile = ListView1->currentItem()->text(0); | 877 | currentFile = ListView1->currentItem()->text(0); |
901 | start(); | 878 | start(); |
902 | } | 879 | } |
903 | } | 880 | } |
904 | 881 | ||
905 | void QtRec::start() { //play | 882 | void QtRec::start() { //play |
906 | if( stopped) { | 883 | if( stopped) { |
907 | QPixmap image3( ( const char** ) image3_data ); | 884 | QPixmap image3( ( const char** ) image3_data ); |
908 | Stop_PushButton->setPixmap( image3 ); | 885 | Stop_PushButton->setPixmap( image3 ); |
909 | Stop_PushButton->setDown( true); | 886 | Stop_PushButton->setDown( true); |
910 | stopped = false; | 887 | stopped = false; |
911 | paused = false; | 888 | paused = false; |
912 | secCount = 1; | 889 | secCount = 1; |
913 | 890 | ||
914 | if( openPlayFile()) | 891 | if( openPlayFile()) |
915 | if( setupAudio( false)) //recording is false | 892 | if( setupAudio( false)) //recording is false |
916 | doPlay(); | 893 | doPlay(); |
917 | } | 894 | } |
918 | } | 895 | } |
919 | 896 | ||
920 | bool QtRec::rec() { //record | 897 | bool QtRec::rec() { //record |
921 | QString timeString; | 898 | QString timeString; |
922 | timeString.sprintf("%.0f", 0.0); | 899 | timeString.sprintf("%.0f", 0.0); |
923 | // timeLabel->setText( timeString+ " seconds"); | 900 | // timeLabel->setText( timeString+ " seconds"); |
924 | if(!stopped) { | 901 | if(!stopped) { |
925 | monitoring = true; | 902 | monitoring = true; |
926 | return false; | 903 | return false; |
927 | } else { | 904 | } else { |
928 | secCount = 1; | 905 | secCount = 1; |
929 | // playLabel2->setText(tr("Stop")); | 906 | // playLabel2->setText(tr("Stop")); |
930 | monitoring = false; | 907 | monitoring = false; |
931 | setRecordButton( true); | 908 | setRecordButton( true); |
932 | 909 | ||
933 | if( setupAudio( true)) | 910 | if( setupAudio( true)) |
934 | if(setUpFile()) { | 911 | if(setUpFile()) { |
935 | int fileSize = 0; | 912 | int fileSize = 0; |
936 | Config cfg("OpieRec"); | 913 | Config cfg("OpieRec"); |
937 | cfg.setGroup("Settings"); | 914 | cfg.setGroup("Settings"); |
938 | // odebug << "<<<<<<<Device bits " << soundDevice->getDeviceBits() | 915 | // odebug << "<<<<<<<Device bits " << soundDevice->getDeviceBits() |
939 | // << ", device rate " << soundDevice->getDeviceRate() | 916 | // << ", device rate " << soundDevice->getDeviceRate() |
940 | // << ", device channels " << soundDevice->getDeviceChannels() << oendl; | 917 | // << ", device channels " << soundDevice->getDeviceChannels() << oendl; |
941 | 918 | ||
942 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 919 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
943 | // odebug << "sample rate is " << filePara.sampleRate << "" << oendl; | 920 | // odebug << "sample rate is " << filePara.sampleRate << "" << oendl; |
944 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 921 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
945 | 922 | ||
946 | // odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl; | 923 | // odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl; |
947 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 924 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
948 | 925 | ||
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h index 3808d99..642048a 100644 --- a/noncore/multimedia/opierec/qtrec.h +++ b/noncore/multimedia/opierec/qtrec.h | |||
@@ -5,183 +5,183 @@ copyright 2002 by L.J. Potter ljp@llornkcor.com | |||
5 | #ifndef QTREC_H | 5 | #ifndef QTREC_H |
6 | #define QTREC_H | 6 | #define QTREC_H |
7 | #define VERSION 20040628 | 7 | #define VERSION 20040628 |
8 | 8 | ||
9 | #include <qpe/ir.h> | 9 | #include <qpe/ir.h> |
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qimage.h> | 12 | #include <qimage.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpixmap.h> | 14 | #include <qpixmap.h> |
15 | #include <qvariant.h> | 15 | #include <qvariant.h> |
16 | #include <qwidget.h> | 16 | #include <qwidget.h> |
17 | #include <stdio.h> | 17 | #include <stdio.h> |
18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | 19 | ||
20 | #include "device.h" | 20 | #include "device.h" |
21 | #include "wavFile.h" | 21 | #include "wavFile.h" |
22 | 22 | ||
23 | class QButtonGroup; | 23 | class QButtonGroup; |
24 | class QCheckBox; | 24 | class QCheckBox; |
25 | class QComboBox; | 25 | class QComboBox; |
26 | class QGridLayout; | 26 | class QGridLayout; |
27 | class QGroupBox; | 27 | class QGroupBox; |
28 | class QHBoxLayout; | 28 | class QHBoxLayout; |
29 | class QIconView; | 29 | class QIconView; |
30 | class QIconViewItem; | 30 | class QIconViewItem; |
31 | class QLabel; | 31 | class QLabel; |
32 | class QLabel; | 32 | class QLabel; |
33 | class QListView; | 33 | class QListView; |
34 | class QListViewItem; | 34 | class QListViewItem; |
35 | class QPushButton; | 35 | class QPushButton; |
36 | class QSlider; | 36 | class QSlider; |
37 | class QTabWidget; | 37 | class QTabWidget; |
38 | class QTimer; | 38 | class QTimer; |
39 | class QVBoxLayout; | 39 | class QVBoxLayout; |
40 | class QLineEdit; | 40 | class QLineEdit; |
41 | 41 | ||
42 | #define MAX_TRACKS 2 | 42 | #define MAX_TRACKS 2 |
43 | //#define BUFSIZE 4096 | 43 | //#define BUFSIZE 4096 |
44 | // #define BUFSIZE 8182 //Z default buffer size | 44 | // #define BUFSIZE 8182 //Z default buffer size |
45 | #define BUFSIZE 1024 | 45 | #define BUFSIZE 1024 |
46 | //#define BUFSIZE 2048 | 46 | //#define BUFSIZE 2048 |
47 | #define FRAGSIZE 0x7fff000A; | 47 | #define FRAGSIZE 0x7fff000A; |
48 | 48 | ||
49 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) | 49 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) |
50 | #define WAVE_FORMAT_PCM (0x0001) | 50 | #define WAVE_FORMAT_PCM (0x0001) |
51 | //AFMT_IMA_ADPCM | 51 | //AFMT_IMA_ADPCM |
52 | 52 | ||
53 | class QtRec : public QWidget | 53 | class QtRec : public QWidget |
54 | { | 54 | { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | 56 | ||
57 | public: | 57 | public: |
58 | static QString appName() { return QString::fromLatin1("opierec"); } | 58 | static QString appName() { return QString::fromLatin1("opierec"); } |
59 | QtRec( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 59 | QtRec( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
60 | ~QtRec(); | 60 | ~QtRec(); |
61 | QSlider *OutputSlider,*InputSlider; | 61 | QSlider *OutputSlider,*InputSlider; |
62 | 62 | ||
63 | public slots: | 63 | public slots: |
64 | private: | 64 | private: |
65 | // int fragment; | 65 | // int fragment; |
66 | int fd1; | 66 | int fd1; |
67 | int secCount; | 67 | int secCount; |
68 | QString timeString; | 68 | QString timeString; |
69 | 69 | ||
70 | QLineEdit *renameBox; | 70 | QLineEdit *renameBox; |
71 | QGroupBox* GroupBox1; | 71 | QGroupBox* GroupBox1; |
72 | QString currentFile; | 72 | QString currentFile; |
73 | QString date, currentFileName, tmpFileName; | 73 | QString date, currentFileName, tmpFileName; |
74 | QTimer *t_timer; | 74 | QTimer *t_timer; |
75 | bool needsStereoOut, paused; | 75 | bool needsStereoOut, paused; |
76 | bool useTmpFile, autoMute; | 76 | bool useTmpFile, autoMute; |
77 | 77 | ||
78 | bool eventFilter( QObject * , QEvent * ); | 78 | bool eventFilter( QObject * , QEvent * ); |
79 | void okRename(); | 79 | void okRename(); |
80 | void cancelRename(); | 80 | void cancelRename(); |
81 | QString getStorage(const QString &); | 81 | QString getStorage(const QString &); |
82 | bool rec(); | 82 | bool rec(); |
83 | int getCurrentSizeLimit(); | 83 | int getCurrentSizeLimit(); |
84 | long checkDiskSpace(const QString &); | 84 | long checkDiskSpace(const QString &); |
85 | void doMute(bool); | 85 | void doMute(bool); |
86 | void errorStop(); | 86 | void errorStop(); |
87 | void fillDirectoryCombo(); | 87 | void fillDirectoryCombo(); |
88 | void getInVol(); | 88 | void getInVol(); |
89 | void getOutVol(); | 89 | void getOutVol(); |
90 | void init(); | 90 | void init(); |
91 | void initConfig(); | 91 | void initConfig(); |
92 | void initConnections(); | 92 | void initConnections(); |
93 | void selectItemByName(const QString &); | 93 | void selectItemByName(const QString &); |
94 | void setRecordButton(bool); | 94 | void setRecordButton(bool); |
95 | void start(); | 95 | void start(); |
96 | void stop(); | 96 | void stop(); |
97 | void timerEvent( QTimerEvent *e ); | 97 | void timerEvent( QTimerEvent *e ); |
98 | 98 | ||
99 | private slots: | 99 | private slots: |
100 | 100 | ||
101 | void FastforwardPressed(); | 101 | void FastforwardPressed(); |
102 | void FastforwardReleased(); | 102 | void FastforwardReleased(); |
103 | void changeDirCombo(int); | 103 | void changeDirCombo(int); |
104 | void changeSizeLimitCombo(int); | 104 | void changeSizeLimitCombo(int); |
105 | void changeTimeSlider(int); | 105 | void changeTimeSlider(int); |
106 | void changebitrateCombo(int); | 106 | void changebitrateCombo(int); |
107 | void changeStereoCheck( bool); | 107 | void changeStereoCheck( bool); |
108 | 108 | ||
109 | void changedInVolume(); | 109 | void changedInVolume(); |
110 | void changedOutVolume(); | 110 | void changedOutVolume(); |
111 | void changesamplerateCombo(int); | 111 | void changesamplerateCombo(int); |
112 | void cleanUp(); | 112 | void cleanUp(); |
113 | void compressionSelected(bool); | 113 | void compressionSelected(bool); |
114 | void deleteSound(); | 114 | void deleteSound(); |
115 | void doBeam(); | 115 | void doBeam(); |
116 | void doMenuPlay(); | 116 | void doMenuPlay(); |
117 | void doMicMuting(bool); | 117 | void doMicMuting(bool); |
118 | void doPlayBtn(); | 118 | void doPlayBtn(); |
119 | void doRename(); | 119 | void doRename(); |
120 | void doVolMuting(bool); | 120 | void doVolMuting(bool); |
121 | void forwardTimerTimeout(); | 121 | void forwardTimerTimeout(); |
122 | void itClick(QListViewItem *item); | 122 | void itClick(QListViewItem *item); |
123 | void listPressed(int, QListViewItem *, const QPoint&, int); | 123 | void listPressed(int, QListViewItem *, const QPoint&, int); |
124 | void newSound(); | 124 | void newSound(); |
125 | void rewindPressed(); | 125 | void rewindPressed(); |
126 | void rewindReleased(); | 126 | void rewindReleased(); |
127 | void rewindTimerTimeout(); | 127 | void rewindTimerTimeout(); |
128 | void slotAutoMute(bool); | 128 | void slotAutoMute(bool); |
129 | void thisTab(QWidget*); | 129 | void thisTab(QWidget*); |
130 | void timeSliderPressed(); | 130 | void timeSliderPressed(); |
131 | void timeSliderReleased(); | 131 | void timeSliderReleased(); |
132 | void timerBreak(); | 132 | void timerBreak(); |
133 | void initIconView(); | ||
133 | /* void changedOutVolume(int); */ | 134 | /* void changedOutVolume(int); */ |
134 | /* void changedInVolume(int); */ | 135 | /* void changedInVolume(int); */ |
135 | 136 | ||
136 | protected: | 137 | protected: |
137 | 138 | ||
138 | WavFile *wavFile; | 139 | WavFile *wavFile; |
139 | QButtonGroup *ButtonGroup1; | 140 | QButtonGroup *ButtonGroup1; |
140 | QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox, *stereoCheckBox; | 141 | QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox, *stereoCheckBox; |
141 | QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo; | 142 | QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo; |
142 | QHBoxLayout* Layout12; | 143 | QHBoxLayout* Layout12; |
143 | QHBoxLayout* Layout13; | 144 | QHBoxLayout* Layout13; |
144 | QHBoxLayout* Layout14; | 145 | QHBoxLayout* Layout14; |
145 | QHBoxLayout* Layout16; | 146 | QHBoxLayout* Layout16; |
146 | QHBoxLayout* Layout17; | 147 | QHBoxLayout* Layout17; |
147 | QHBoxLayout* Layout19; | 148 | QHBoxLayout* Layout19; |
148 | QIconView *IconView1; | 149 | QIconView *IconView1; |
149 | QLabel *NewSoundLabel,*playLabel2; | 150 | QLabel *NewSoundLabel,*playLabel2; |
150 | QLabel *TextLabel3, *TextLabel1, *TextLabel2; | 151 | QLabel *TextLabel3, *TextLabel1, *TextLabel2; |
151 | QListView *ListView1; | 152 | QListView *ListView1; |
152 | QPushButton *Stop_PushButton, *Play_PushButton, *Rec_PushButton, *NewSoundButton, *deleteSoundButton, *toBeginningButton, *toEndButton; | 153 | QPushButton *Stop_PushButton, *Play_PushButton, *Rec_PushButton, *NewSoundButton, *deleteSoundButton, *toBeginningButton, *toEndButton; |
153 | QString recDir; | 154 | QString recDir; |
154 | QTabWidget *TabWidget; | 155 | QTabWidget *TabWidget; |
155 | QTimer *t, *rewindTimer, *forwardTimer; | 156 | QTimer *t, *rewindTimer, *forwardTimer; |
156 | QVBoxLayout* Layout15; | 157 | QVBoxLayout* Layout15; |
157 | QVBoxLayout* Layout15b; | 158 | QVBoxLayout* Layout15b; |
158 | QVBoxLayout* Layout18; | 159 | QVBoxLayout* Layout18; |
159 | QWidget *tab, *tab_2, *tab_3, *tab_4, *tab_5; | 160 | QWidget *tab, *tab_2, *tab_3, *tab_4, *tab_5; |
160 | int sliderPos, total; | 161 | int sliderPos, total; |
161 | // short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; | 162 | // short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; |
162 | // unsigned short unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; | 163 | // unsigned short unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; |
163 | QGroupBox *sampleGroup, *bitGroup, *dirGroup, *sizeGroup; | 164 | QGroupBox *sampleGroup, *bitGroup, *dirGroup, *sizeGroup; |
164 | /* short inbuffer[65536], outbuffer[65536]; */ | 165 | /* short inbuffer[65536], outbuffer[65536]; */ |
165 | /* unsigned short unsigned_inbuffer[65536], unsigned_outbuffer[65536]; */ | 166 | /* unsigned short unsigned_inbuffer[65536], unsigned_outbuffer[65536]; */ |
166 | 167 | ||
167 | 168 | ||
168 | bool doPlay(); | 169 | bool doPlay(); |
169 | bool openPlayFile(); | 170 | bool openPlayFile(); |
170 | bool setUpFile(); | 171 | bool setUpFile(); |
171 | bool setupAudio( bool b); | 172 | bool setupAudio( bool b); |
172 | void endPlaying(); | 173 | void endPlaying(); |
173 | void endRecording(); | 174 | void endRecording(); |
174 | void fileBeamFinished( Ir *ir); | 175 | void fileBeamFinished( Ir *ir); |
175 | void initIconView(); | ||
176 | void keyPressEvent( QKeyEvent *e); | 176 | void keyPressEvent( QKeyEvent *e); |
177 | void keyReleaseEvent( QKeyEvent *e); | 177 | void keyReleaseEvent( QKeyEvent *e); |
178 | void receive( const QCString &, const QByteArray & ); | 178 | void receive( const QCString &, const QByteArray & ); |
179 | void showListMenu(QListViewItem * ); | 179 | void showListMenu(QListViewItem * ); |
180 | #ifndef THREADED | 180 | #ifndef THREADED |
181 | void quickRec(); | 181 | void quickRec(); |
182 | void playIt(); | 182 | void playIt(); |
183 | #endif | 183 | #endif |
184 | 184 | ||
185 | }; | 185 | }; |
186 | 186 | ||
187 | #endif // QTREC_H | 187 | #endif // QTREC_H |