summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2007-01-08 19:18:26 (UTC)
committer llornkcor <llornkcor>2007-01-08 19:18:26 (UTC)
commit5e9659c695af1d1afb20a377775f1349b83eca53 (patch) (unidiff)
tree8904471e0508b91d1f04d4e2ddd2a81963d934be
parentc880d9e087019f27f19c80b13fe2c7a5a4b37e3d (diff)
downloadopie-5e9659c695af1d1afb20a377775f1349b83eca53.zip
opie-5e9659c695af1d1afb20a377775f1349b83eca53.tar.gz
opie-5e9659c695af1d1afb20a377775f1349b83eca53.tar.bz2
patch from paul
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp115
-rw-r--r--noncore/multimedia/opierec/qtrec.h3
2 files changed, 67 insertions, 51 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 75413be..d8b8ce3 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -405,209 +405,210 @@ void playIt()
405// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 405// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
406// fflush(stdout); 406// fflush(stdout);
407 } 407 }
408 } 408 }
409} 409}
410 410
411 411
412QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 412QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
413 : QWidget( parent, name, fl ) 413 : QWidget( parent, name, fl )
414{ 414{
415 if ( !name ) 415 if ( !name )
416 setName( "OpieRec" ); 416 setName( "OpieRec" );
417 init(); 417 init();
418 initConfig(); 418 initConfig();
419 initConnections(); 419 initConnections();
420 renameBox = 0; 420 renameBox = 0;
421 421
422// open sound device to get volumes 422// open sound device to get volumes
423 Config hwcfg("OpieRec"); 423 Config hwcfg("OpieRec");
424 hwcfg.setGroup("Hardware"); 424 hwcfg.setGroup("Hardware");
425 425
426 426
427 soundDevice = new Device( this, false); //open play 427 soundDevice = new Device( this, false); //open play
428 428
429 getInVol(); 429 getInVol();
430 getOutVol(); 430 getOutVol();
431 431
432 soundDevice->closeDevice( true); 432 soundDevice->closeDevice( true);
433 soundDevice->sd = -1; 433 soundDevice->sd = -1;
434 soundDevice = 0; 434 soundDevice = 0;
435 wavFile = 0; 435 wavFile = 0;
436// if( soundDevice) delete soundDevice; 436// if( soundDevice) delete soundDevice;
437 QTimer::singleShot(100,this, SLOT(initIconView())); 437 QTimer::singleShot(100,this, SLOT(initIconView()));
438 438
439 if( autoMute) 439 if( autoMute)
440 doMute( true); 440 doMute( true);
441 // ListView1->setFocus(); 441 // ListView1->setFocus();
442 playing = false; 442 playing = false;
443} 443}
444 444
445QtRec::~QtRec() { 445QtRec::~QtRec() {
446// if( soundDevice) delete soundDevice; 446// if( soundDevice) delete soundDevice;
447 447
448} 448}
449 449
450void QtRec::cleanUp() { 450void QtRec::cleanUp() {
451 451
452 if( !stopped) { 452 if( !stopped) {
453 stopped = true; 453 stopped = true;
454 endRecording(); 454 endRecording();
455 } 455 }
456 456
457 ListView1->clear(); 457 ListView1->clear();
458 458
459 if( autoMute) 459 if( autoMute)
460 doMute(false); 460 doMute(false);
461 461
462// if( wavFile) delete wavFile; 462// if( wavFile) delete wavFile;
463// if(soundDevice) delete soundDevice; 463// if(soundDevice) delete soundDevice;
464} 464}
465 465
466void QtRec::init() { 466void QtRec::init() {
467 467
468 needsStereoOut = false; 468 needsStereoOut = false;
469 QPixmap image3( ( const char** ) image3_data );
470 QPixmap image4( ( const char** ) image4_data );
471 QPixmap image6( ( const char** ) image6_data ); 469 QPixmap image6( ( const char** ) image6_data );
472 470
473 stopped = true; 471 stopped = true;
474 setCaption( tr( "OpieRecord " )); 472 setCaption( tr( "OpieRecord " ));
475 QGridLayout *layout = new QGridLayout( this ); 473 QGridLayout *layout = new QGridLayout( this );
476 layout->setSpacing( 2); 474 layout->setSpacing( 2);
477 layout->setMargin( 2); 475 layout->setMargin( 2);
478 476
479 TabWidget = new QTabWidget( this, "TabWidget" ); 477 TabWidget = new QTabWidget( this, "TabWidget" );
480 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); 478 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8);
481// TabWidget->setTabShape(QTabWidget::Triangular); 479// TabWidget->setTabShape(QTabWidget::Triangular);
482 480
483 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 481 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
484 tab = new QWidget( TabWidget, "tab" ); 482 tab = new QWidget( TabWidget, "tab" );
485 483
486 QGridLayout *layout1 = new QGridLayout( tab); 484 QGridLayout *layout1 = new QGridLayout( tab);
487 layout1->setSpacing( 2); 485 layout1->setSpacing( 2);
488 layout1->setMargin( 2); 486 layout1->setMargin( 2);
489 487
490 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 488 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
491 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 489 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
492 490
493 // timeLabel = new QLabel( tab, "TimeLabel" ); 491 // timeLabel = new QLabel( tab, "TimeLabel" );
494 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); 492 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3);
495 493
496 // playLabel2 = new QLabel(tab, "PlayLabel2" ); 494 // playLabel2 = new QLabel(tab, "PlayLabel2" );
497 // playLabel2->setText(tr("Play") ); 495 // playLabel2->setText(tr("Play") );
498 // playLabel2->setFixedHeight( 18); 496 // playLabel2->setFixedHeight( 18);
499 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 497 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
500 498
501 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 499 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
502 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 500 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
503 Stop_PushButton->setFixedSize( 22, 22); 501 Stop_PushButton->setFixedSize( 22, 22);
504 Stop_PushButton->setPixmap( image4 ); 502 Stop_PushButton->setPixmap( Opie::Core::OResource::loadPixmap("play2", Opie::Core::OResource::SmallIcon) );
505 503
506 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 504 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
507 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 505 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
508 toBeginningButton->setFixedSize( 22, 22); 506 toBeginningButton->setFixedSize( 22, 22);
509 toBeginningButton->setPixmap( Opie::Core::OResource::loadPixmap("fastback", Opie::Core::OResource::SmallIcon) ); 507 toBeginningButton->setPixmap( Opie::Core::OResource::loadPixmap("fastback", Opie::Core::OResource::SmallIcon) );
510 508
511 toEndButton = new QPushButton( tab, "End_PushButton" ); 509 toEndButton = new QPushButton( tab, "End_PushButton" );
512 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 510 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
513 toEndButton->setFixedSize( 22, 22); 511 toEndButton->setFixedSize( 22, 22);
514 toEndButton->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ) ); 512 toEndButton->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ) );
515 513
516 // QLabel *recLabel2; 514 // QLabel *recLabel2;
517 // recLabel2 = new QLabel( tab, "recLabel2" ); 515 // recLabel2 = new QLabel( tab, "recLabel2" );
518 // recLabel2->setText(tr("Rec")); 516 // recLabel2->setText(tr("Rec"));
519 // recLabel2->setFixedHeight( 18); 517 // recLabel2->setFixedHeight( 18);
520 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 518 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
521 519
522 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 520 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
523 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 521 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
524 Rec_PushButton->setFixedSize( 22, 22); 522 Rec_PushButton->setFixedSize( 22, 22);
525 Rec_PushButton->setPixmap( image6 ); 523 Rec_PushButton->setPixmap( image6 );
526 524
527 t = new QTimer( this ); 525 t = new QTimer( this );
528 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 526 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) );
529 527
530 rewindTimer = new QTimer( this ); 528 rewindTimer = new QTimer( this );
531 connect( rewindTimer, SIGNAL( timeout() ), 529 connect( rewindTimer, SIGNAL( timeout() ),
532 this, SLOT( rewindTimerTimeout() ) ); 530 this, SLOT( rewindTimerTimeout() ) );
533 531
534 forwardTimer = new QTimer( this ); 532 forwardTimer = new QTimer( this );
535 connect( forwardTimer, SIGNAL( timeout() ), 533 connect( forwardTimer, SIGNAL( timeout() ),
536 this, SLOT( forwardTimerTimeout() ) ); 534 this, SLOT( forwardTimerTimeout() ) );
537 535
538 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 536 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
539 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); 537 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8);
540 deleteSoundButton->setText( tr( "Del" ) ); 538 deleteSoundButton->setFixedSize( 22, 22);
539 deleteSoundButton->setPixmap( Opie::Core::OResource::loadPixmap( "editdelete", Opie::Core::OResource::SmallIcon ) );
541 540
542 ListView1 = new QListView( tab, "IconView1" ); 541 ListView1 = new QListView( tab, "IconView1" );
543 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); 542 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8);
544 543
545 ListView1->addColumn( tr( "Name" ) ); 544 ListView1->addColumn( tr( "Name" ) );
546 ListView1->setSorting( 1, false); 545 ListView1->setSorting( 1, false);
547 ListView1->addColumn( tr( "Time" ) ); //in seconds 546 ListView1->addColumn( tr( "Time" ) ); //in seconds
547 ListView1->addColumn( tr( "Size" ) );
548 ListView1->setColumnWidthMode(0, QListView::Maximum); 548 ListView1->setColumnWidthMode(0, QListView::Maximum);
549 ListView1->setColumnAlignment( 1, QListView::AlignCenter); 549 ListView1->setColumnAlignment( 1, QListView::AlignRight);
550 ListView1->setColumnAlignment( 2, QListView::AlignRight);
550 ListView1->setAllColumnsShowFocus( true ); 551 ListView1->setAllColumnsShowFocus( true );
551 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); 552 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold);
552 553
553 TabWidget->insertTab( tab, tr( "Files" ) ); 554 TabWidget->insertTab( tab, tr( "Files" ) );
554 555
555 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 556 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
556 tab_3 = new QWidget( TabWidget, "tab_3" ); 557 tab_3 = new QWidget( TabWidget, "tab_3" );
557 QGridLayout *glayout3 = new QGridLayout( tab_3 ); 558 QGridLayout *glayout3 = new QGridLayout( tab_3 );
558 glayout3->setSpacing( 2); 559 glayout3->setSpacing( 2);
559 glayout3->setMargin( 2); 560 glayout3->setMargin( 2);
560 //////////////////////////////////// 561 ////////////////////////////////////
561 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 562 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
562 sampleGroup->setTitle( tr( "Sample Rate" ) ); 563 sampleGroup->setTitle( tr( "Sample Rate" ) );
563 sampleGroup->setFixedSize( 95,50); 564 sampleGroup->setFixedSize( 95,50);
564 565
565 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); 566 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
566 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); 567 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
567 QString s; 568 QString s;
568 int z = 0; 569 int z = 0;
569 while( deviceSampleRates[z] != -1) { 570 while( deviceSampleRates[z] != -1) {
570 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); 571 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10));
571 z++; 572 z++;
572 } 573 }
573 574
574 575
575 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); 576 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
576 577
577 sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); 578 sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
578 sizeGroup->setTitle( tr( "Limit Size" ) ); 579 sizeGroup->setTitle( tr( "Limit Size" ) );
579 sizeGroup->setFixedSize( 80, 50); 580 sizeGroup->setFixedSize( 80, 50);
580 581
581 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); 582 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
582 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); 583 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) );
583 sizeLimitCombo->insertItem(tr("Unlimited")); 584 sizeLimitCombo->insertItem(tr("Unlimited"));
584 585
585 for(int i=1;i<13; i++) { 586 for(int i=1;i<13; i++) {
586 sizeLimitCombo->insertItem( QString::number( i * 5)); 587 sizeLimitCombo->insertItem( QString::number( i * 5));
587 } 588 }
588 589
589 590
590 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); 591 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1);
591 dirGroup = new QGroupBox( tab_3, "dirGroup" ); 592 dirGroup = new QGroupBox( tab_3, "dirGroup" );
592 dirGroup->setTitle( tr( "File Directory" ) ); 593 dirGroup->setTitle( tr( "File Directory" ) );
593 dirGroup->setFixedSize( 130, 50); 594 dirGroup->setFixedSize( 130, 50);
594 595
595 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); 596 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" );
596 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); 597 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) );
597 598
598 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); 599 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0);
599 600
600 bitGroup = new QGroupBox( tab_3, "bitGroup" ); 601 bitGroup = new QGroupBox( tab_3, "bitGroup" );
601 bitGroup->setTitle( tr( "Bit Depth" ) ); 602 bitGroup->setTitle( tr( "Bit Depth" ) );
602 bitGroup->setFixedSize( 65, 50); 603 bitGroup->setFixedSize( 65, 50);
603 604
604 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); 605 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
605 606
606 z = 0; 607 z = 0;
607 while( deviceBitRates[z] != -1) { 608 while( deviceBitRates[z] != -1) {
608 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); 609 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
609 z++; 610 z++;
610 } 611 }
611 612
612 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); 613 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
613 614
@@ -641,349 +642,350 @@ void QtRec::init() {
641 TextLabel2->setText( tr( "In")); 642 TextLabel2->setText( tr( "In"));
642 TextLabel2->setFixedWidth( 35); 643 TextLabel2->setFixedWidth( 35);
643 Layout15->addWidget( TextLabel2 ); 644 Layout15->addWidget( TextLabel2 );
644 645
645 TextLabel3 = new QLabel( tab_5, "OutputLabel" ); 646 TextLabel3 = new QLabel( tab_5, "OutputLabel" );
646 TextLabel3->setText( tr( "Out" ) ); 647 TextLabel3->setText( tr( "Out" ) );
647 Layout15b->addWidget( TextLabel3 ); 648 Layout15b->addWidget( TextLabel3 );
648 649
649 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 650 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
650 InputSlider->setTickmarks( QSlider::Both); 651 InputSlider->setTickmarks( QSlider::Both);
651 Layout15->addWidget( InputSlider); 652 Layout15->addWidget( InputSlider);
652 653
653 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 654 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
654 OutputSlider->setTickmarks( QSlider::Both); 655 OutputSlider->setTickmarks( QSlider::Both);
655 656
656 Layout15b->addWidget( OutputSlider ); 657 Layout15b->addWidget( OutputSlider );
657 658
658 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 659 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
659 Layout15->addWidget( outMuteCheckBox ); 660 Layout15->addWidget( outMuteCheckBox );
660 661
661 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 662 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
662 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 663 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
663 Layout15b->addWidget( inMuteCheckBox ); 664 Layout15b->addWidget( inMuteCheckBox );
664 665
665 666
666 Layout19a->addLayout( Layout15 ); 667 Layout19a->addLayout( Layout15 );
667 Layout19a->addLayout( Layout15b ); 668 Layout19a->addLayout( Layout15b );
668 669
669 fillDirectoryCombo(); 670 fillDirectoryCombo();
670 671
671 TabWidget->insertTab( tab_3, tr( "Options" ) ); 672 TabWidget->insertTab( tab_3, tr( "Options" ) );
672 673
673 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 674 TabWidget->insertTab( tab_5, tr( "Volume" ) );
674 675
675 waveform = new Waveform( this, "waveform" ); 676 waveform = new Waveform( this, "waveform" );
676 waveform->setMinimumSize( QSize( 0, 50 ) ); 677 waveform->setMinimumSize( QSize( 0, 50 ) );
677 678
678 layout->addMultiCellWidget( waveform, 8, 8, 0, 8); 679 layout->addMultiCellWidget( waveform, 8, 8, 0, 8);
679 waveform->setBackgroundColor ( black ); 680 waveform->setBackgroundColor ( black );
680} 681}
681 682
682void QtRec::initIconView() { 683void QtRec::initIconView() {
683 ListView1->clear(); 684 ListView1->clear();
684 Config cfg("OpieRec"); 685 Config cfg("OpieRec");
685 cfg.setGroup("Sounds"); 686 cfg.setGroup("Sounds");
686 QString temp; 687 QString temp;
687 QPixmap image0( ( const char** ) image0_data ); 688 QPixmap image0( ( const char** ) image0_data );
688 689
689 int nFiles = cfg.readNumEntry("NumberofFiles",0); 690 int nFiles = cfg.readNumEntry("NumberofFiles",0);
690// owarn << "init number of files " << nFiles << "" << oendl; 691// owarn << "init number of files " << nFiles << "" << oendl;
691 692
692 for(int i = 1; i <= nFiles; i++) { 693 for(int i = 1; i <= nFiles; i++) {
693 694
694 QListViewItem * item; 695 QListViewItem * item;
695 QString fileS, mediaLocation, fileDate, filePath; 696 QString fileS, mediaLocation, fileDate, filePath;
696 697
697 temp.sprintf( "%d",i); 698 temp.sprintf( "%d",i);
698 temp = cfg.readEntry( temp,""); //reads currentFile 699 temp = cfg.readEntry( temp,""); //reads currentFile
699 filePath = cfg.readEntry( temp,""); //currentFileName 700 filePath = cfg.readEntry( temp,""); //currentFileName
700 701
701 QFileInfo info(filePath); 702 QFileInfo info(filePath);
702 fileDate = info.lastModified().toString(); 703 fileDate = info.lastModified().toString();
703 704
704 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 705 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
706 QString sizeStr;
707 fileSize(info.size(), sizeStr);
705 mediaLocation = getStorage( filePath); 708 mediaLocation = getStorage( filePath);
706 if( info.exists()) { 709 if( info.exists()) {
707 // owarn << "new item " << temp << oendl; 710 // owarn << "new item " << temp << oendl;
708 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); 711 item = new QListViewItem( ListView1, temp, fileS, sizeStr );
709 item->setPixmap( 0, image0); 712 item->setPixmap( 0, image0);
710 if( currentFileName == filePath) 713 if( currentFileName == filePath)
711 ListView1->setSelected( item, true); 714 ListView1->setSelected( item, true);
712 } 715 }
713 } 716 }
717
718 setButtons();
714} 719}
715 720
716void QtRec::initConnections() { 721void QtRec::initConnections() {
717 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp())); 722 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp()));
718 723
719 connect(toBeginningButton,SIGNAL(pressed()),this,SLOT(rewindPressed())); 724 connect(toBeginningButton,SIGNAL(pressed()),this,SLOT(rewindPressed()));
720 connect(toBeginningButton,SIGNAL(released()),this,SLOT(rewindReleased())); 725 connect(toBeginningButton,SIGNAL(released()),this,SLOT(rewindReleased()));
721 connect(toEndButton,SIGNAL(pressed()),this,SLOT(FastforwardPressed())); 726 connect(toEndButton,SIGNAL(pressed()),this,SLOT(FastforwardPressed()));
722 connect(toEndButton,SIGNAL(released()),this,SLOT(FastforwardReleased())); 727 connect(toEndButton,SIGNAL(released()),this,SLOT(FastforwardReleased()));
723 728
724 connect(deleteSoundButton,SIGNAL(released()),this,SLOT(deleteSound())); 729 connect(deleteSoundButton,SIGNAL(released()),this,SLOT(deleteSound()));
725 730
726 connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); 731 connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn()));
727 // connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); 732 // connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn()));
728 733
729 // connect(Rec_PushButton,SIGNAL(released()),this,SIGNAL(startRecording())); 734 // connect(Rec_PushButton,SIGNAL(released()),this,SIGNAL(startRecording()));
730 connect(Rec_PushButton,SIGNAL(released()),this,SLOT(newSound())); 735 connect(Rec_PushButton,SIGNAL(released()),this,SLOT(newSound()));
731 736
732 connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(thisTab(QWidget*))); 737 connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(thisTab(QWidget*)));
733 738
734 connect(OutputSlider,SIGNAL(sliderReleased()),this,SLOT(changedOutVolume())); 739 connect(OutputSlider,SIGNAL(sliderReleased()),this,SLOT(changedOutVolume()));
735 connect(InputSlider,SIGNAL(sliderReleased()),this,SLOT(changedInVolume())); 740 connect(InputSlider,SIGNAL(sliderReleased()),this,SLOT(changedInVolume()));
736 741
737 connect(sampleRateComboBox,SIGNAL(activated(int)),this,SLOT(changesamplerateCombo(int))); 742 connect(sampleRateComboBox,SIGNAL(activated(int)),this,SLOT(changesamplerateCombo(int)));
738 connect(bitRateComboBox,SIGNAL(activated(int)),this,SLOT(changebitrateCombo(int))); 743 connect(bitRateComboBox,SIGNAL(activated(int)),this,SLOT(changebitrateCombo(int)));
739 connect(directoryComboBox,SIGNAL(activated(int)),this,SLOT(changeDirCombo(int))); 744 connect(directoryComboBox,SIGNAL(activated(int)),this,SLOT(changeDirCombo(int)));
740 connect(sizeLimitCombo,SIGNAL(activated(int)),this,SLOT(changeSizeLimitCombo(int))); 745 connect(sizeLimitCombo,SIGNAL(activated(int)),this,SLOT(changeSizeLimitCombo(int)));
741 746
742 connect(stereoCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeStereoCheck(bool))); 747 connect(stereoCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeStereoCheck(bool)));
743 connect(outMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doVolMuting(bool))); 748 connect(outMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doVolMuting(bool)));
744 connect(inMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doMicMuting(bool))); 749 connect(inMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doMicMuting(bool)));
745 750
746 connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itClick(QListViewItem*))); 751 connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itClick(QListViewItem*)));
747 connect(ListView1,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(listPressed(int,QListViewItem*,const QPoint&,int))); 752 connect(ListView1,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(listPressed(int,QListViewItem*,const QPoint&,int)));
748 753
749 connect(timeSlider,SIGNAL(sliderMoved(int)),this,SLOT(changeTimeSlider(int))); 754 connect(timeSlider,SIGNAL(sliderMoved(int)),this,SLOT(changeTimeSlider(int)));
750 connect(timeSlider,SIGNAL(sliderPressed()),this,SLOT(timeSliderPressed())); 755 connect(timeSlider,SIGNAL(sliderPressed()),this,SLOT(timeSliderPressed()));
751 connect(timeSlider,SIGNAL(sliderReleased()),this,SLOT(timeSliderReleased())); 756 connect(timeSlider,SIGNAL(sliderReleased()),this,SLOT(timeSliderReleased()));
752 757
753 connect(compressionCheckBox,SIGNAL(toggled(bool)),this,SLOT(compressionSelected(bool))); 758 connect(compressionCheckBox,SIGNAL(toggled(bool)),this,SLOT(compressionSelected(bool)));
754 connect(autoMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(slotAutoMute(bool))); 759 connect(autoMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(slotAutoMute(bool)));
755} 760}
756 761
757void QtRec::initConfig() { 762void QtRec::initConfig() {
758 int index, fred, i; 763 int index, fred, i;
759 Config cfg("OpieRec"); 764 Config cfg("OpieRec");
760 cfg.setGroup("Settings"); 765 cfg.setGroup("Settings");
761 766
762 index = cfg.readNumEntry("samplerate",22050); 767 index = cfg.readNumEntry("samplerate",22050);
763 bool ok; 768 bool ok;
764 769
765 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 770 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
766 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 771 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
767 if( index == fred) { 772 if( index == fred) {
768 filePara.sampleRate = fred; 773 filePara.sampleRate = fred;
769 sampleRateComboBox->setCurrentItem(ws); 774 sampleRateComboBox->setCurrentItem(ws);
770 } 775 }
771 } 776 }
772 777
773 i = cfg.readNumEntry("bitrate",16); 778 i = cfg.readNumEntry("bitrate",16);
774 if(i == 16) 779 if(i == 16)
775 bitRateComboBox->setCurrentItem( 1); 780 bitRateComboBox->setCurrentItem( 1);
776 else if(i == 24) 781 else if(i == 24)
777 bitRateComboBox->setCurrentItem( 2); 782 bitRateComboBox->setCurrentItem( 2);
778 else if(i == 32) 783 else if(i == 32)
779 bitRateComboBox->setCurrentItem( 3); 784 bitRateComboBox->setCurrentItem( 3);
780 else 785 else
781 bitRateComboBox->setCurrentItem( 0); 786 bitRateComboBox->setCurrentItem( 0);
782 787
783 filePara.resolution = i; 788 filePara.resolution = i;
784 789
785 i = cfg.readNumEntry("sizeLimit", 5 ); 790 i = cfg.readNumEntry("sizeLimit", 5 );
786 QString temp; 791 QString temp;
787 sizeLimitCombo->setCurrentItem((i/5)); 792 sizeLimitCombo->setCurrentItem((i/5));
788 793
789 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); 794 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 0));
790 if( stereoCheckBox->isChecked()) { 795 if( stereoCheckBox->isChecked()) {
791 filePara.channels = 2; 796 filePara.channels = 2;
792 } else { 797 } else {
793 filePara.channels = 1; 798 filePara.channels = 1;
794 } 799 }
795 800
796 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 801 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
797 if( compressionCheckBox->isChecked()) { 802 if( compressionCheckBox->isChecked()) {
798 bitRateComboBox->setCurrentItem(1); 803 bitRateComboBox->setCurrentItem(1);
799 bitRateComboBox->setEnabled(false); 804 bitRateComboBox->setEnabled(false);
800 filePara.resolution=16; 805 filePara.resolution=16;
801 } 806 }
802 807
803 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); 808 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
804 if( autoMuteCheckBox->isChecked()) 809 if( autoMuteCheckBox->isChecked())
805 slotAutoMute(true); 810 slotAutoMute(true);
806 else 811 else
807 slotAutoMute(false); 812 slotAutoMute(false);
808 813
809 Config cofg( "qpe"); 814 Config cofg( "qpe");
810 cofg.setGroup( "Volume"); 815 cofg.setGroup( "Volume");
811 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 816 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
812 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 817 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
813} 818}
814 819
815void QtRec::stop() { 820void QtRec::stop() {
816 // owarn << "STOP" << oendl; 821 // owarn << "STOP" << oendl;
817 setRecordButton(false);
818 822
819 if( !recording) { 823 if( !recording) {
820 emit stopPlaying(); 824 emit stopPlaying();
821 endPlaying(); 825 endPlaying();
822 } else { 826 } else {
823 emit stopRecording(); 827 emit stopRecording();
824 endRecording(); 828 endRecording();
825 } 829 }
826 timeSlider->setValue(0); 830 timeSlider->setValue(0);
831 setButtons();
827} 832}
828 833
829void QtRec::doPlayBtn() { 834void QtRec::doPlayBtn() {
830 835
831 if(!stopped) { 836 if(!stopped) {
832 // playLabel2->setText(tr("Play")); 837 // playLabel2->setText(tr("Play"));
833 stop(); 838 stop();
834 } else { 839 } else {
835 if(ListView1->currentItem() == 0) return; 840 if(ListView1->currentItem() == 0) return;
836 // playLabel2->setText(tr("Stop")); 841 // playLabel2->setText(tr("Stop"));
837 currentFile = ListView1->currentItem()->text(0); 842 currentFile = ListView1->currentItem()->text(0);
838 start(); 843 start();
839 } 844 }
840} 845}
841 846
842void QtRec::start() { //play 847void QtRec::start() { //play
843 if( stopped) { 848 if( stopped) {
844 QPixmap image3( ( const char** ) image3_data );
845 Stop_PushButton->setPixmap( image3 );
846 Stop_PushButton->setDown( true);
847 stopped = false; 849 stopped = false;
848 paused = false; 850 paused = false;
851 setButtons();
849 secCount = 1; 852 secCount = 1;
850 853
851 if( openPlayFile()) 854 if( openPlayFile())
852 if( setupAudio( false)) //recording is false 855 if( setupAudio( false)) //recording is false
853 doPlay(); 856 doPlay();
854 } 857 }
855} 858}
856 859
857bool QtRec::rec() { //record 860bool QtRec::rec() { //record
858 QString timeString; 861 QString timeString;
859 timeString.sprintf("%.0f", 0.0); 862 timeString.sprintf("%.0f", 0.0);
860 // timeLabel->setText( timeString+ " seconds"); 863 // timeLabel->setText( timeString+ " seconds");
861 if(!stopped) { 864 if(!stopped) {
862 monitoring = true; 865 monitoring = true;
863 return false; 866 return false;
864 } else { 867 } else {
865 secCount = 1; 868 secCount = 1;
866 // playLabel2->setText(tr("Stop")); 869 // playLabel2->setText(tr("Stop"));
867 monitoring = false; 870 monitoring = false;
868 setRecordButton( true); 871 setButtons();
869 872
870 if( setupAudio( true)) 873 if( setupAudio( true))
871 if(setUpFile()) { 874 if(setUpFile()) {
872 int fileSize = 0; 875 int fileSize = 0;
873 Config cfg("OpieRec"); 876 Config cfg("OpieRec");
874 cfg.setGroup("Settings"); 877 cfg.setGroup("Settings");
875 filePara.SecondsToRecord = getCurrentSizeLimit(); 878 filePara.SecondsToRecord = getCurrentSizeLimit();
876 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 879 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
877 880
878 if( filePara.SecondsToRecord == 0) { 881 if( filePara.SecondsToRecord == 0) {
879 fileSize = diskSize; 882 fileSize = diskSize;
880 } else if( filePara.format == WAVE_FORMAT_PCM) { 883 } else if( filePara.format == WAVE_FORMAT_PCM) {
881// odebug << "WAVE_FORMAT_PCM" << oendl; 884// odebug << "WAVE_FORMAT_PCM" << oendl;
882 fileSize = (filePara.SecondsToRecord ) * filePara.channels 885 fileSize = (filePara.SecondsToRecord ) * filePara.channels
883 * filePara.sampleRate * ( filePara.resolution / 8) + 1000; 886 * filePara.sampleRate * ( filePara.resolution / 8) + 1000;
884 } else { 887 } else {
885// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; 888// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
886 fileSize = ((filePara.SecondsToRecord) * filePara.channels 889 fileSize = ((filePara.SecondsToRecord) * filePara.channels
887 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; 890 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
888 } 891 }
889 892
890 filePara.samplesToRecord = fileSize; 893 filePara.samplesToRecord = fileSize;
891 odebug << "filesize should be " << filePara.samplesToRecord 894 odebug << "filesize should be " << filePara.samplesToRecord
892 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate; 895 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate;
893 if( paused) { 896 if( paused) {
894 paused = false; 897 paused = false;
895 } 898 }
896 // else { 899 // else {
897 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; 900 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
898 // if(fileSize != 0) 901 // if(fileSize != 0)
899 timeSlider->setRange(0, filePara.samplesToRecord); 902 timeSlider->setRange(0, filePara.samplesToRecord);
900 // } 903 // }
901 904
902 if( diskSize < fileSize/1024) { 905 if( diskSize < fileSize/1024) {
903 QMessageBox::warning(this, 906 QMessageBox::warning(this,
904 tr("Low Disk Space"), 907 tr("Low Disk Space"),
905 tr("You are running low of\nrecording space\n" 908 tr("You are running low of\nrecording space\n"
906 "or a card isn't being recognized")); 909 "or a card isn't being recognized"));
907 stopped = true; //we need to be stopped 910 stopped = true; //we need to be stopped
908 stop(); 911 stop();
909 } else { 912 } else {
910 QString msg; 913 QString msg;
911 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 914 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
912#ifdef DEV_VERSION 915#ifdef DEV_VERSION
913 setCaption( msg); 916 setCaption( msg);
914#endif 917#endif
915 filePara.fileName=currentFile.latin1(); 918 filePara.fileName=currentFile.latin1();
916 odebug << "Start recording" << oendl; 919 odebug << "Start recording" << oendl;
917 stopped = false; 920 stopped = false;
918 921
919#ifdef THREADED 922#ifdef THREADED
920 odebug << "Start recording thread" << oendl; 923 odebug << "Start recording thread" << oendl;
921 pthread_t thread1; 924 pthread_t thread1;
922 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 925 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
923#endif 926#endif
924 toBeginningButton->setEnabled( false); 927 setButtons();
925 toEndButton->setEnabled( false);
926 928
927 startTimer(1000); 929 startTimer(1000);
928#ifndef THREADED 930#ifndef THREADED
929 quickRec(); 931 quickRec();
930#endif 932#endif
931 } 933 }
932 } //end setUpFile 934 } //end setUpFile
933 } //end setupAudio 935 } //end setupAudio
934 return true; 936 return true;
935} 937}
936/* 938/*
937 This happens when a tab is selected*/ 939 This happens when a tab is selected*/
938void QtRec::thisTab(QWidget* widg) { 940void QtRec::thisTab(QWidget* widg) {
939 if(widg != NULL) { 941 if(widg != NULL) {
940 int index = TabWidget->currentPageIndex(); 942 int index = TabWidget->currentPageIndex();
941 943
942 if(index == 0) { //file page 944 if(index == 0) { //file page
943 } 945 }
944 946
945 if(index == 1) { //control page 947 if(index == 1) { //control page
946 fillDirectoryCombo(); 948 fillDirectoryCombo();
947// soundDevice->getOutVol(); 949// soundDevice->getOutVol();
948// soundDevice->getInVol(); 950// soundDevice->getInVol();
949 } 951 }
950 952
951 if( index==2) { //help page 953 if( index==2) { //help page
952 } 954 }
953 955
954 qApp->processEvents(); 956 qApp->processEvents();
955 update(); 957 update();
956 } 958 }
957} 959}
958 960
959void QtRec::getOutVol( ) { 961void QtRec::getOutVol( ) {
960 filePara.outVol = soundDevice->getOutVolume(); 962 filePara.outVol = soundDevice->getOutVolume();
961// odebug << "out vol " << filePara.outVol << "" << oendl; 963// odebug << "out vol " << filePara.outVol << "" << oendl;
962 OutputSlider->setValue( -filePara.outVol); 964 OutputSlider->setValue( -filePara.outVol);
963} 965}
964 966
965void QtRec::getInVol() { 967void QtRec::getInVol() {
966 filePara.inVol = soundDevice->getInVolume(); 968 filePara.inVol = soundDevice->getInVolume();
967// odebug << "in vol " << filePara.inVol << "" << oendl; 969// odebug << "in vol " << filePara.inVol << "" << oendl;
968 InputSlider->setValue( -filePara.inVol); 970 InputSlider->setValue( -filePara.inVol);
969} 971}
970 972
971void QtRec::changedOutVolume() { 973void QtRec::changedOutVolume() {
972 soundDevice->changedOutVolume( -OutputSlider->value()); 974 soundDevice->changedOutVolume( -OutputSlider->value());
973} 975}
974 976
975void QtRec::changedInVolume( ) { 977void QtRec::changedInVolume( ) {
976 soundDevice->changedInVolume( -InputSlider->value()); 978 soundDevice->changedInVolume( -InputSlider->value());
977} 979}
978 980
979 981
980bool QtRec::setupAudio( bool b) { 982bool QtRec::setupAudio( bool b) {
981 bool ok; 983 bool ok;
982 int sampleformat, stereo, flags; 984 int sampleformat, stereo, flags;
983 QString dspString, mixerString; 985 QString dspString, mixerString;
984 986
985 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 987 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
986 988
987 if( !b) { 989 if( !b) {
988// we want to play 990// we want to play
989#ifdef PDAUDIO //ALSA 991#ifdef PDAUDIO //ALSA
@@ -1079,615 +1081,616 @@ bool QtRec::setupAudio( bool b) {
1079 update(); 1081 update();
1080 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); 1082 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) );
1081 return false; 1083 return false;
1082 } 1084 }
1083 if(autoMute) 1085 if(autoMute)
1084 doMute(false); 1086 doMute(false);
1085 1087
1086 return true; 1088 return true;
1087} 1089}
1088 1090
1089 1091
1090bool QtRec::setUpFile() { //setup file for recording 1092bool QtRec::setUpFile() { //setup file for recording
1091 wavFile = new WavFile( this, (const QString &)"", 1093 wavFile = new WavFile( this, (const QString &)"",
1092 true, 1094 true,
1093 filePara.sampleRate, 1095 filePara.sampleRate,
1094 filePara.channels, 1096 filePara.channels,
1095 filePara.resolution, 1097 filePara.resolution,
1096 filePara.format); 1098 filePara.format);
1097 1099
1098 filePara.fd = wavFile->wavHandle(); 1100 filePara.fd = wavFile->wavHandle();
1099 if(filePara.fd == -1) { 1101 if(filePara.fd == -1) {
1100 return false; 1102 return false;
1101 } else { 1103 } else {
1102 } 1104 }
1103 return true; 1105 return true;
1104} 1106}
1105 1107
1106/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> 1108/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
1107bool QtRec::doPlay() { 1109bool QtRec::doPlay() {
1108 1110
1109 if( !paused) { 1111 if( !paused) {
1110 total = 0; 1112 total = 0;
1111 filePara.numberOfRecordedSeconds = 0; 1113 filePara.numberOfRecordedSeconds = 0;
1112 } else { 1114 } else {
1113 paused = false; 1115 paused = false;
1114 secCount = (int)filePara.numberOfRecordedSeconds; 1116 secCount = (int)filePara.numberOfRecordedSeconds;
1115 } 1117 }
1116 playing = true; 1118 playing = true;
1117 stopped = false; 1119 stopped = false;
1118 recording = false; 1120 recording = false;
1119 1121
1120 QString num; 1122 QString num;
1121 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; 1123 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
1122 1124
1123// timeSlider->setRange( 0, filePara.numberSamples); 1125// timeSlider->setRange( 0, filePara.numberSamples);
1124 1126
1125 timeString.sprintf("%f", filePara.numberOfRecordedSeconds); 1127 timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
1126 // timeLabel->setText( timeString+ tr(" seconds")); 1128 // timeLabel->setText( timeString+ tr(" seconds"));
1127 1129
1128 QString msg; 1130 QString msg;
1129 msg.sprintf("%d, %d, %d", 1131 msg.sprintf("%d, %d, %d",
1130 filePara.sampleRate, 1132 filePara.sampleRate,
1131 filePara.channels, 1133 filePara.channels,
1132 filePara.resolution); 1134 filePara.resolution);
1133#ifdef DEV_VERSION 1135#ifdef DEV_VERSION
1134 setCaption( msg); 1136 setCaption( msg);
1135#endif 1137#endif
1136 1138
1137 startTimer( 1000); 1139 startTimer( 1000);
1138#ifdef THREADED 1140#ifdef THREADED
1139 pthread_t thread2; 1141 pthread_t thread2;
1140 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1142 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1141#endif 1143#endif
1142 1144
1143 toBeginningButton->setEnabled( false); 1145 setButtons();
1144 toEndButton->setEnabled( false);
1145#ifndef THREADED 1146#ifndef THREADED
1146 playIt(); 1147 playIt();
1147#endif 1148#endif
1148 return true; 1149 return true;
1149} 1150}
1150 1151
1151 1152
1152void QtRec::changebitrateCombo(int i) { 1153void QtRec::changebitrateCombo(int i) {
1153 Config cfg("OpieRec"); 1154 Config cfg("OpieRec");
1154 cfg.setGroup("Settings"); 1155 cfg.setGroup("Settings");
1155 int bits = 0; 1156 int bits = 0;
1156 if( i == 1) { bits = 16; } 1157 if( i == 1) { bits = 16; }
1157 else if( i == 2) { bits = 24; } 1158 else if( i == 2) { bits = 24; }
1158 else if( i == 3) { bits = 32; } 1159 else if( i == 3) { bits = 32; }
1159 else { bits=8; } 1160 else { bits=8; }
1160 cfg.writeEntry("bitrate", bits); 1161 cfg.writeEntry("bitrate", bits);
1161 filePara.resolution = bits; 1162 filePara.resolution = bits;
1162 cfg.write(); 1163 cfg.write();
1163} 1164}
1164 1165
1165void QtRec::changesamplerateCombo(int i) { 1166void QtRec::changesamplerateCombo(int i) {
1166 Config cfg("OpieRec"); 1167 Config cfg("OpieRec");
1167 cfg.setGroup("Settings"); 1168 cfg.setGroup("Settings");
1168 int rate=0; 1169 int rate=0;
1169 bool ok; 1170 bool ok;
1170 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1171 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1171 cfg.writeEntry( "samplerate",rate); 1172 cfg.writeEntry( "samplerate",rate);
1172 filePara.sampleRate=rate; 1173 filePara.sampleRate=rate;
1173 odebug << "Change sample rate " << rate << "" << oendl; 1174 odebug << "Change sample rate " << rate << "" << oendl;
1174 cfg.write(); 1175 cfg.write();
1175} 1176}
1176 1177
1177 1178
1178void QtRec::changeDirCombo(int index) { 1179void QtRec::changeDirCombo(int index) {
1179 Config cfg("OpieRec"); 1180 Config cfg("OpieRec");
1180 cfg.setGroup("Settings"); 1181 cfg.setGroup("Settings");
1181 QString sName = directoryComboBox->text(index); 1182 QString sName = directoryComboBox->text(index);
1182 1183
1183 StorageInfo storageInfo; 1184 StorageInfo storageInfo;
1184 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1185 const QList<FileSystem> &fs = storageInfo.fileSystems();
1185 QListIterator<FileSystem> it ( fs ); 1186 QListIterator<FileSystem> it ( fs );
1186 QString storage; 1187 QString storage;
1187 for( ; it.current(); ++it ){ 1188 for( ; it.current(); ++it ){
1188 if( sName == (*it)->name()+" "+ (*it)->path() || 1189 if( sName == (*it)->name()+" "+ (*it)->path() ||
1189 (*it)->name() == sName ) { 1190 (*it)->name() == sName ) {
1190 const QString path = (*it)->path(); 1191 const QString path = (*it)->path();
1191 recDir = path; 1192 recDir = path;
1192 cfg.writeEntry("directory", recDir); 1193 cfg.writeEntry("directory", recDir);
1193 odebug << "new rec dir "+recDir << oendl; 1194 odebug << "new rec dir "+recDir << oendl;
1194 } 1195 }
1195 } 1196 }
1196 cfg.write(); 1197 cfg.write();
1197} 1198}
1198 1199
1199 1200
1200void QtRec::changeSizeLimitCombo(int) { 1201void QtRec::changeSizeLimitCombo(int) {
1201 Config cfg("OpieRec"); 1202 Config cfg("OpieRec");
1202 cfg.setGroup("Settings"); 1203 cfg.setGroup("Settings");
1203 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); 1204 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
1204 cfg.write(); 1205 cfg.write();
1205} 1206}
1206 1207
1207void QtRec::newSound() { 1208void QtRec::newSound() {
1208 if( !rec()) { 1209 if(!rec()) {
1209 endRecording(); 1210 stop();
1210 deleteSound();
1211 } 1211 }
1212} 1212}
1213 1213
1214void QtRec::itClick(QListViewItem *item) { 1214void QtRec::itClick(QListViewItem *item) {
1215 currentFile = item->text(0); 1215 currentFile = item->text(0);
1216 setCaption("OpieRecord "+currentFile); 1216 setCaption("OpieRecord "+currentFile);
1217} 1217}
1218 1218
1219void QtRec::deleteSound() { 1219void QtRec::deleteSound() {
1220 Config cfg("OpieRec"); 1220 Config cfg("OpieRec");
1221 cfg.setGroup("Sounds"); 1221 cfg.setGroup("Sounds");
1222 if( ListView1->currentItem() == NULL) 1222 if( ListView1->currentItem() == NULL)
1223 return; 1223 return;
1224
1225 if (QMessageBox::information(this, tr("Delete"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) {
1224 QString file = ListView1->currentItem()->text(0); 1226 QString file = ListView1->currentItem()->text(0);
1225 QString fileName; 1227 QString fileName;
1226 fileName = cfg.readEntry( file, ""); 1228 fileName = cfg.readEntry( file, "");
1227 QFile f( fileName); 1229 QFile f( fileName);
1228 if( f.exists()) 1230 if( f.exists())
1229 if( !f.remove()) 1231 if( !f.remove())
1230 QMessageBox::message( tr("Error"), tr("Could not remove file.")); 1232 QMessageBox::message( tr("Error"), tr("Could not remove file."));
1231 1233
1232 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1234 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1233 bool found = false; 1235 bool found = false;
1234 for(int i=0;i<nFiles+1;i++) { 1236 for(int i=0;i<nFiles+1;i++) {
1235 1237
1236 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { 1238 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
1237 found = true; 1239 found = true;
1238 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1240 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1239 } 1241 }
1240 if(found) 1242 if(found)
1241 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1243 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1242 } 1244 }
1243 1245
1244 cfg.removeEntry( cfg.readEntry( file)); 1246 cfg.removeEntry( cfg.readEntry( file));
1245 cfg.removeEntry( file); 1247 cfg.removeEntry( file);
1246 cfg.writeEntry( "NumberofFiles", nFiles-1); 1248 cfg.writeEntry( "NumberofFiles", nFiles-1);
1247 cfg.write(); 1249 cfg.write();
1248 1250
1249 ListView1->takeItem( ListView1->currentItem() ); 1251 ListView1->takeItem( ListView1->currentItem() );
1250 delete ListView1->currentItem(); 1252 delete ListView1->currentItem();
1251 1253
1252 ListView1->clear(); 1254 ListView1->clear();
1253 ListView1->setSelected( ListView1->firstChild(), true); 1255 ListView1->setSelected( ListView1->firstChild(), true);
1254 initIconView(); 1256 initIconView();
1255 update(); 1257 update();
1256 setCaption( tr( "OpieRecord " )); 1258 setCaption( tr( "OpieRecord " ));
1259 }
1257} 1260}
1258 1261
1259void QtRec::keyPressEvent( QKeyEvent *e) { 1262void QtRec::keyPressEvent( QKeyEvent *e) {
1260 1263
1261 switch ( e->key() ) { 1264 switch ( e->key() ) {
1262 // case Key_F1: 1265 // case Key_F1:
1263 // if(stopped && !recording) 1266 // if(stopped && !recording)
1264 // newSound(); 1267 // newSound();
1265 // else 1268 // else
1266 // stop(); 1269 // stop();
1267 // break; 1270 // break;
1268 // case Key_F2: { 1271 // case Key_F2: {
1269 // if( !e->isAutoRepeat()) 1272 // if( !e->isAutoRepeat())
1270 // rewindPressed(); 1273 // rewindPressed();
1271 // } 1274 // }
1272 // break; 1275 // break;
1273 // case Key_F3: { 1276 // case Key_F3: {
1274 // if( !e->isAutoRepeat()) 1277 // if( !e->isAutoRepeat())
1275 // FastforwardPressed(); 1278 // FastforwardPressed();
1276 // } 1279 // }
1277 // break; 1280 // break;
1278 1281
1279 ////////////////////////////// Zaurus keys 1282 ////////////////////////////// Zaurus keys
1280 case Key_F9: //activity 1283 case Key_F9: //activity
1281 break; 1284 break;
1282 case Key_F10: //contacts 1285 case Key_F10: //contacts
1283 break; 1286 break;
1284 case Key_F11: //menu 1287 case Key_F11: //menu
1285 break; 1288 break;
1286 case Key_F12: //home 1289 case Key_F12: //home
1287 break; 1290 break;
1288 case Key_F13: //mail 1291 case Key_F13: //mail
1289 break; 1292 break;
1290 case Key_Space: 1293 case Key_Space:
1291 break; 1294 break;
1292 case Key_Delete: 1295 case Key_Delete:
1293 break; 1296 break;
1294 case Key_Up: 1297 case Key_Up:
1295 // stop(); 1298 // stop();
1296 break; 1299 break;
1297 case Key_Down: 1300 case Key_Down:
1298 // newSound(); 1301 // newSound();
1299 break; 1302 break;
1300 case Key_Left: { 1303 case Key_Left: {
1301 odebug << "rewinding" << oendl; 1304 odebug << "rewinding" << oendl;
1302 if( !e->isAutoRepeat()) 1305 if( !e->isAutoRepeat())
1303 rewindPressed(); 1306 rewindPressed();
1304 } 1307 }
1305 break; 1308 break;
1306 case Key_Right: { 1309 case Key_Right: {
1307 if( !e->isAutoRepeat()) 1310 if( !e->isAutoRepeat())
1308 FastforwardPressed(); 1311 FastforwardPressed();
1309 } 1312 }
1310 break; 1313 break;
1311 } 1314 }
1312} 1315}
1313 1316
1314void QtRec::keyReleaseEvent( QKeyEvent *e) { 1317void QtRec::keyReleaseEvent( QKeyEvent *e) {
1315 switch ( e->key() ) { 1318 switch ( e->key() ) {
1316 // case Key_F1: 1319 // case Key_F1:
1317 // if(stopped && !recording) 1320 // if(stopped && !recording)
1318 // newSound(); 1321 // newSound();
1319 // else 1322 // else
1320 // stop(); 1323 // stop();
1321 // break; 1324 // break;
1322 // case Key_F2: 1325 // case Key_F2:
1323 // rewindReleased(); 1326 // rewindReleased();
1324 // break; 1327 // break;
1325 // case Key_F3: 1328 // case Key_F3:
1326 // FastforwardReleased(); 1329 // FastforwardReleased();
1327 // break; 1330 // break;
1328 1331
1329 ////////////////////////////// Zaurus keys 1332 ////////////////////////////// Zaurus keys
1330 case Key_F9: //activity 1333 case Key_F9: //activity
1331 break; 1334 break;
1332 case Key_F10: //contacts 1335 case Key_F10: //contacts
1333 break; 1336 break;
1334 case Key_F11: //menu 1337 case Key_F11: //menu
1335 break; 1338 break;
1336 case Key_F12: //home 1339 case Key_F12: //home
1337 if(stopped) 1340 if(stopped)
1338 doPlayBtn(); 1341 doPlayBtn();
1339 else 1342 else
1340 stop(); 1343 stop();
1341 break; 1344 break;
1342 case Key_F13: //mail 1345 case Key_F13: //mail
1343 break; 1346 break;
1344 case Key_Space: 1347 case Key_Space:
1345 if(stopped && !recording) 1348 if(stopped && !recording)
1346 newSound(); 1349 newSound();
1347 else 1350 else
1348 stop(); 1351 stop();
1349 break; 1352 break;
1350 case Key_Delete: 1353 case Key_Delete:
1351 deleteSound(); 1354 deleteSound();
1352 break; 1355 break;
1353 case Key_Up: 1356 case Key_Up:
1354 // stop(); 1357 // stop();
1355 odebug << "Up" << oendl; 1358 odebug << "Up" << oendl;
1356 break; 1359 break;
1357 case Key_Down: 1360 case Key_Down:
1358 // start(); 1361 // start();
1359 // odebug << "Down" << oendl; 1362 // odebug << "Down" << oendl;
1360 // newSound(); 1363 // newSound();
1361 break; 1364 break;
1362 case Key_Left: 1365 case Key_Left:
1363 odebug << "Left" << oendl; 1366 odebug << "Left" << oendl;
1364 rewindReleased(); 1367 rewindReleased();
1365 break; 1368 break;
1366 case Key_Right: 1369 case Key_Right:
1367 odebug << "Right" << oendl; 1370 odebug << "Right" << oendl;
1368 FastforwardReleased(); 1371 FastforwardReleased();
1369 break; 1372 break;
1370 } 1373 }
1371} 1374}
1372 1375
1373void QtRec::endRecording() { 1376void QtRec::endRecording() {
1374 1377
1375 monitoring = false; 1378 monitoring = false;
1376 recording = false; 1379 recording = false;
1377 stopped = true; 1380 stopped = true;
1378 waveform->reset(); 1381 waveform->reset();
1379 setRecordButton( false);
1380 1382
1381 toBeginningButton->setEnabled( true); 1383 setButtons();
1382 toEndButton->setEnabled( true);
1383 1384
1384 killTimers(); 1385 killTimers();
1385 1386
1386 if(autoMute) 1387 if(autoMute)
1387 doMute( true); 1388 doMute( true);
1388 1389
1389 soundDevice->closeDevice( true); 1390 soundDevice->closeDevice( true);
1390 1391
1391 if( wavFile->track.isOpen()) { 1392 if( wavFile->track.isOpen()) {
1392 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1393 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1393 filePara.numberSamples = 0; 1394 filePara.numberSamples = 0;
1394 wavFile->closeFile(); 1395 wavFile->closeFile();
1395 filePara.fd=0; 1396 filePara.fd=0;
1396 1397
1397 if( wavFile->isTempFile()) { 1398 if( wavFile->isTempFile()) {
1398// move tmp file to regular file 1399// move tmp file to regular file
1399 QString cmd; 1400 QString cmd;
1400 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1401 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1401 odebug << "moving tmp file to "+currentFileName << oendl; 1402 odebug << "moving tmp file to "+currentFileName << oendl;
1402 system( cmd.latin1()); 1403 system( cmd.latin1());
1403 } 1404 }
1404 1405
1405 odebug << "Just moved " + wavFile->currentFileName << oendl; 1406 odebug << "Just moved " + wavFile->currentFileName << oendl;
1406 Config cfg("OpieRec"); 1407 Config cfg("OpieRec");
1407 cfg.setGroup("Sounds"); 1408 cfg.setGroup("Sounds");
1408 1409
1409 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1410 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1410 1411
1411 currentFile = QFileInfo( wavFile->currentFileName).fileName(); 1412 currentFile = QFileInfo( wavFile->currentFileName).fileName();
1412 currentFile = currentFile.left( currentFile.length() - 4); 1413 currentFile = currentFile.left( currentFile.length() - 4);
1413 1414
1414 cfg.writeEntry( "NumberofFiles", nFiles + 1); 1415 cfg.writeEntry( "NumberofFiles", nFiles + 1);
1415 cfg.writeEntry( QString::number( nFiles + 1), currentFile); 1416 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1416 cfg.writeEntry( currentFile, wavFile->currentFileName); 1417 cfg.writeEntry( currentFile, wavFile->currentFileName);
1417 1418
1418 QString time; 1419 QString time;
1419 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1420 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1420 cfg.writeEntry( wavFile->currentFileName, time ); 1421 cfg.writeEntry( wavFile->currentFileName, time );
1421 odebug << "writing config numberOfRecordedSeconds "+time << oendl; 1422 odebug << "writing config numberOfRecordedSeconds "+time << oendl;
1422 1423
1423 cfg.write(); 1424 cfg.write();
1424 odebug << "finished recording" << oendl; 1425 odebug << "finished recording" << oendl;
1425 // timeLabel->setText(""); 1426 // timeLabel->setText("");
1426 } 1427 }
1427 1428
1428// if(soundDevice) delete soundDevice; 1429// if(soundDevice) delete soundDevice;
1429 1430
1430 timeSlider->setValue(0); 1431 timeSlider->setValue(0);
1431 initIconView(); 1432 initIconView();
1432 selectItemByName( currentFile); 1433 selectItemByName( currentFile);
1433 setCaption( tr( "OpieRecord " )); 1434 setCaption( tr( "OpieRecord " ));
1434 1435
1435} 1436}
1436 1437
1437void QtRec::endPlaying() { 1438void QtRec::endPlaying() {
1438 monitoring = false; 1439 monitoring = false;
1439 recording = false; 1440 recording = false;
1440 playing = false; 1441 playing = false;
1441 stopped = true; 1442 stopped = true;
1442 waveform->reset(); 1443 waveform->reset();
1443// errorStop(); 1444// errorStop();
1444 odebug << "end playing" << oendl; 1445 odebug << "end playing" << oendl;
1445 setRecordButton( false); 1446 setButtons();
1446
1447 toBeginningButton->setEnabled( true);
1448 toEndButton->setEnabled( true);
1449 1447
1450 if(autoMute) 1448 if(autoMute)
1451 doMute( true); 1449 doMute( true);
1452 1450
1453 soundDevice->closeDevice( false); 1451 soundDevice->closeDevice( false);
1454 soundDevice->sd = -1; 1452 soundDevice->sd = -1;
1455 // if(soundDevice) delete soundDevice; 1453 // if(soundDevice) delete soundDevice;
1456 odebug << "file and sound device closed" << oendl; 1454 odebug << "file and sound device closed" << oendl;
1457 // timeLabel->setText(""); 1455 // timeLabel->setText("");
1458 total = 0; 1456 total = 0;
1459 filePara.numberSamples = 0; 1457 filePara.numberSamples = 0;
1460 filePara.sd = -1; 1458 filePara.sd = -1;
1461// wavFile->closeFile(); 1459// wavFile->closeFile();
1462 filePara.fd = 0; 1460 filePara.fd = 0;
1463// if(wavFile) delete wavFile; //this crashes 1461// if(wavFile) delete wavFile; //this crashes
1464 1462
1465 odebug << "track closed" << oendl; 1463 odebug << "track closed" << oendl;
1466 killTimers(); 1464 killTimers();
1467 // owarn << "reset slider" << oendl; 1465 // owarn << "reset slider" << oendl;
1468 timeSlider->setValue(0); 1466 timeSlider->setValue(0);
1469 1467
1470// if(soundDevice) delete soundDevice; 1468// if(soundDevice) delete soundDevice;
1471 1469
1472} 1470}
1473 1471
1474bool QtRec::openPlayFile() { 1472bool QtRec::openPlayFile() {
1475 qWarning("opening file"); 1473 qWarning("opening file");
1476 qApp->processEvents(); 1474 qApp->processEvents();
1477 if( currentFile.isEmpty()) { 1475 if( currentFile.isEmpty()) {
1478 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1476 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1479 endPlaying(); 1477 endPlaying();
1480 return false; 1478 return false;
1481 } 1479 }
1482 QString currentFileName; 1480 QString currentFileName;
1483 Config cfg("OpieRec"); 1481 Config cfg("OpieRec");
1484 cfg.setGroup("Sounds"); 1482 cfg.setGroup("Sounds");
1485 int nFiles = cfg.readNumEntry( "NumberofFiles", 0); 1483 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1486 for(int i=0;i<nFiles+1;i++) { //look for file 1484 for(int i=0;i<nFiles+1;i++) { //look for file
1487 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1485 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1488 currentFileName = cfg.readEntry( currentFile, "" ); 1486 currentFileName = cfg.readEntry( currentFile, "" );
1489 odebug << "opening for play: " + currentFileName << oendl; 1487 odebug << "opening for play: " + currentFileName << oendl;
1490 } 1488 }
1491 } 1489 }
1492 wavFile = new WavFile(this, 1490 wavFile = new WavFile(this,
1493 currentFileName, 1491 currentFileName,
1494 false); 1492 false);
1495 filePara.fd = wavFile->wavHandle(); 1493 filePara.fd = wavFile->wavHandle();
1496 if(filePara.fd == -1) { 1494 if(filePara.fd == -1) {
1497 // if(!track.open(IO_ReadOnly)) { 1495 // if(!track.open(IO_ReadOnly)) {
1498 QString errorMsg = (QString)strerror(errno); 1496 QString errorMsg = (QString)strerror(errno);
1499 monitoring = false; 1497 monitoring = false;
1500 setCaption( tr( "OpieRecord " )); 1498 setCaption( tr( "OpieRecord " ));
1501 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") 1499 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n")
1502 + errorMsg + "\n" + currentFile); 1500 + errorMsg + "\n" + currentFile);
1503 return false; 1501 return false;
1504 } else { 1502 } else {
1505 1503
1506 filePara.numberSamples = wavFile->getNumberSamples(); 1504 filePara.numberSamples = wavFile->getNumberSamples();
1507 filePara.format = wavFile->getFormat(); 1505 filePara.format = wavFile->getFormat();
1508 filePara.sampleRate = wavFile->getSampleRate(); 1506 filePara.sampleRate = wavFile->getSampleRate();
1509 filePara.resolution = wavFile->getResolution(); 1507 filePara.resolution = wavFile->getResolution();
1510 filePara.channels = wavFile->getChannels(); 1508 filePara.channels = wavFile->getChannels();
1511 timeSlider->setPageStep(1); 1509 timeSlider->setPageStep(1);
1512 monitoring = true; 1510 monitoring = true;
1513 1511
1514 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; 1512 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
1515 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); 1513 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
1516 1514
1517 // owarn << "seconds " << sec << "" << oendl; 1515 // owarn << "seconds " << sec << "" << oendl;
1518 1516
1519 timeSlider->setRange(0, filePara.numberSamples ); 1517 timeSlider->setRange(0, filePara.numberSamples );
1520 } 1518 }
1521 1519
1522 return true; 1520 return true;
1523} 1521}
1524 1522
1525void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { 1523void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1526 if(item == NULL ) 1524 if(item == NULL )
1527 return; 1525 return;
1528 switch (mouse) { 1526 switch (mouse) {
1529 case 1: { 1527 case 1: {
1530 if( renameBox != 0 ) //tricky 1528 if( renameBox != 0 ) //tricky
1531 cancelRename(); 1529 cancelRename();
1532 1530
1533 currentFile = item->text(0); 1531 currentFile = item->text(0);
1532 setButtons();
1534 // setCaption( "OpieRecord " + currentFile); 1533 // setCaption( "OpieRecord " + currentFile);
1535 } 1534 }
1536 break; 1535 break;
1537 case 2: 1536 case 2:
1538 showListMenu(item); 1537 showListMenu(item);
1539 ListView1->clearSelection(); 1538 ListView1->clearSelection();
1540 break; 1539 break;
1541 }; 1540 };
1542} 1541}
1543 1542
1544void QtRec::showListMenu(QListViewItem * item) { 1543void QtRec::showListMenu(QListViewItem * item) {
1545 if(item == NULL) 1544 if(item == NULL)
1546 return; 1545 return;
1547 QPopupMenu *m = new QPopupMenu(this); 1546 QPopupMenu *m = new QPopupMenu(this);
1548 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); 1547 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() ));
1549 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); 1548 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() ));
1550 m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); 1549 m->insertItem( tr( "Rename" ), this, SLOT( doRename() ));
1551 // #if defined (QTOPIA_INTERNAL_FSLP) 1550 // #if defined (QTOPIA_INTERNAL_FSLP)
1552 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1551 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1553 // #endif 1552 // #endif
1554 m->insertSeparator(); 1553 m->insertSeparator();
1555 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); 1554 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) );
1556 m->exec( QCursor::pos() ); 1555 m->exec( QCursor::pos() );
1557 qApp->processEvents(); 1556 qApp->processEvents();
1558} 1557}
1559 1558
1560void QtRec::fileBeamFinished( Ir *ir) { 1559void QtRec::fileBeamFinished( Ir *ir) {
1561 if(ir) 1560 if(ir)
1562 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); 1561 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") );
1563 1562
1564} 1563}
1565 1564
1566void QtRec::doBeam() { 1565void QtRec::doBeam() {
1567 qApp->processEvents(); 1566 qApp->processEvents();
1568 if( ListView1->currentItem() == NULL) 1567 if( ListView1->currentItem() == NULL)
1569 return; 1568 return;
1570 Ir ir; 1569 Ir ir;
1571 if( ir.supported()) { 1570 if( ir.supported()) {
1572 QString file = ListView1->currentItem()->text(0); 1571 QString file = ListView1->currentItem()->text(0);
1573 Config cfg("OpieRec"); 1572 Config cfg("OpieRec");
1574 cfg.setGroup("Sounds"); 1573 cfg.setGroup("Sounds");
1575 1574
1576 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1575 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1577 1576
1578 for(int i=0;i<nFiles+1;i++) { 1577 for(int i=0;i<nFiles+1;i++) {
1579 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { 1578 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) {
1580 QString filePath = cfg.readEntry(file,""); 1579 QString filePath = cfg.readEntry(file,"");
1581 Ir *file = new Ir(this, "IR"); 1580 Ir *file = new Ir(this, "IR");
1582 connect( file, SIGNAL( done(Ir*)), 1581 connect( file, SIGNAL( done(Ir*)),
1583 this, SLOT( fileBeamFinished(Ir*))); 1582 this, SLOT( fileBeamFinished(Ir*)));
1584 file->send( filePath, "OPieRec audio file\n" + filePath ); 1583 file->send( filePath, "OPieRec audio file\n" + filePath );
1585 } 1584 }
1586 } 1585 }
1587 } 1586 }
1588} 1587}
1589 1588
1590void QtRec::doMenuPlay() { 1589void QtRec::doMenuPlay() {
1591 qApp->processEvents(); 1590 qApp->processEvents();
1592 currentFile = ListView1->currentItem()->text(0); 1591 currentFile = ListView1->currentItem()->text(0);
1592 doPlayBtn();
1593} 1593}
1594 1594
1595void QtRec::doRename() { 1595void QtRec::doRename() {
1596 QRect r = ListView1->itemRect( ListView1->currentItem( )); 1596 QRect r = ListView1->itemRect( ListView1->currentItem( ));
1597 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); 1597 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() );
1598 r.setX( ListView1->contentsX() ); 1598 r.setX( ListView1->contentsX() );
1599 if ( r.width() > ListView1->visibleWidth() ) 1599 if ( r.width() > ListView1->visibleWidth() )
1600 r.setWidth( ListView1->visibleWidth() ); 1600 r.setWidth( ListView1->visibleWidth() );
1601 1601
1602 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); 1602 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" );
1603 renameBox->setFrame(true); 1603 renameBox->setFrame(true);
1604 1604
1605 renameBox->setText( ListView1->currentItem()->text(0) ); 1605 renameBox->setText( ListView1->currentItem()->text(0) );
1606 1606
1607 renameBox->selectAll(); 1607 renameBox->selectAll();
1608 renameBox->installEventFilter( this ); 1608 renameBox->installEventFilter( this );
1609 ListView1->addChild( renameBox, r.x(), r.y() ); 1609 ListView1->addChild( renameBox, r.x(), r.y() );
1610 renameBox->resize( r.size() ); 1610 renameBox->resize( r.size() );
1611 ListView1->viewport()->setFocusProxy( renameBox ); 1611 ListView1->viewport()->setFocusProxy( renameBox );
1612 renameBox->setFocus(); 1612 renameBox->setFocus();
1613 renameBox->show(); 1613 renameBox->show();
1614 1614
1615} 1615}
1616 1616
1617void QtRec::okRename() { 1617void QtRec::okRename() {
1618 odebug << renameBox->text() << oendl; 1618 odebug << renameBox->text() << oendl;
1619 QString filename = renameBox->text(); 1619 QString filename = renameBox->text();
1620 cancelRename(); 1620 cancelRename();
1621 1621
1622 if( ListView1->currentItem() == NULL) 1622 if( ListView1->currentItem() == NULL)
1623 return; 1623 return;
1624 1624
1625 Config cfg("OpieRec"); 1625 Config cfg("OpieRec");
1626 cfg.setGroup("Sounds"); 1626 cfg.setGroup("Sounds");
1627 1627
1628 QString file = ListView1->currentItem()->text(0); 1628 QString file = ListView1->currentItem()->text(0);
1629 1629
1630 if(file == filename)
1631 return;
1632
1630 odebug << "filename is " + filename << oendl; 1633 odebug << "filename is " + filename << oendl;
1631 1634
1632 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1635 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1633 1636
1634 for(int i=0;i<nFiles+1;i++) { //look for file 1637 for(int i=0;i<nFiles+1;i++) { //look for file
1635 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1638 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1636 1639
1637 QString filePath = cfg.readEntry(file,""); 1640 QString filePath = cfg.readEntry(file,"");
1638 1641
1639 cfg.writeEntry( QString::number(i), filename ); 1642 cfg.writeEntry( QString::number(i), filename );
1640 cfg.writeEntry( filename, filePath ); 1643 cfg.writeEntry( filename, filePath );
1641 cfg.removeEntry( file); 1644 cfg.removeEntry( file);
1642 cfg.write(); 1645 cfg.write();
1643 } 1646 }
1644 } 1647 }
1645 1648
1646 ListView1->takeItem( ListView1->currentItem() ); 1649 ListView1->takeItem( ListView1->currentItem() );
1647 delete ListView1->currentItem(); 1650 delete ListView1->currentItem();
1648 ListView1->clear(); 1651 ListView1->clear();
1649 initIconView(); 1652 initIconView();
1650 update(); 1653 update();
1651} 1654}
1652 1655
1653void QtRec::cancelRename() { 1656void QtRec::cancelRename() {
1654 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1657 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
1655 delete renameBox; 1658 delete renameBox;
1656 renameBox = 0; 1659 renameBox = 0;
1657 if ( resetFocus ) { 1660 if ( resetFocus ) {
1658 ListView1->viewport()->setFocusProxy( ListView1 ); 1661 ListView1->viewport()->setFocusProxy( ListView1 );
1659 ListView1->setFocus(); 1662 ListView1->setFocus();
1660 } 1663 }
1661} 1664}
1662 1665
1663bool QtRec::eventFilter( QObject * o, QEvent * e ) { 1666bool QtRec::eventFilter( QObject * o, QEvent * e ) {
1664 if ( o->inherits( "QLineEdit" ) ) { 1667 if ( o->inherits( "QLineEdit" ) ) {
1665 if ( e->type() == QEvent::KeyPress ) { 1668 if ( e->type() == QEvent::KeyPress ) {
1666 QKeyEvent *ke = (QKeyEvent*)e; 1669 QKeyEvent *ke = (QKeyEvent*)e;
1667 if ( ke->key() == Key_Return || 1670 if ( ke->key() == Key_Return ||
1668 ke->key() == Key_Enter ) { 1671 ke->key() == Key_Enter ) {
1669 okRename(); 1672 okRename();
1670 return true; 1673 return true;
1671 } else if ( ke->key() == Key_Escape ) { 1674 } else if ( ke->key() == Key_Escape ) {
1672 cancelRename(); 1675 cancelRename();
1673 return true; 1676 return true;
1674 } 1677 }
1675 } else if ( e->type() == QEvent::FocusOut ) { 1678 } else if ( e->type() == QEvent::FocusOut ) {
1676 cancelRename(); 1679 cancelRename();
1677 return true; 1680 return true;
1678 } 1681 }
1679 } 1682 }
1680 return QWidget::eventFilter( o, e ); 1683 return QWidget::eventFilter( o, e );
1681} 1684}
1682 1685
1683 1686
1684int QtRec::getCurrentSizeLimit() { 1687int QtRec::getCurrentSizeLimit() {
1685 return sizeLimitCombo->currentItem() * 5; 1688 return sizeLimitCombo->currentItem() * 5;
1686} 1689}
1687 1690
1688void QtRec::timerBreak() { 1691void QtRec::timerBreak() {
1689 endPlaying(); 1692 endPlaying();
1690} 1693}
1691 1694
1692void QtRec::doVolMuting(bool b) { 1695void QtRec::doVolMuting(bool b) {
1693 Config cfg( "qpe" ); 1696 Config cfg( "qpe" );
@@ -1877,177 +1880,189 @@ void QtRec::FastforwardPressed() {
1877 1880
1878 paused = true; 1881 paused = true;
1879 stopped = true; 1882 stopped = true;
1880 forwardTimer->start(50, false); 1883 forwardTimer->start(50, false);
1881} 1884}
1882 1885
1883 1886
1884void QtRec::forwardTimerTimeout() { 1887void QtRec::forwardTimerTimeout() {
1885 int sliderValue = timeSlider->value(); 1888 int sliderValue = timeSlider->value();
1886 sliderValue = sliderValue + ( filePara.numberSamples / 100); 1889 sliderValue = sliderValue + ( filePara.numberSamples / 100);
1887 1890
1888 // if(toEndButton->isDown()) 1891 // if(toEndButton->isDown())
1889 timeSlider->setValue( sliderValue); 1892 timeSlider->setValue( sliderValue);
1890 1893
1891 QString timeString; 1894 QString timeString;
1892 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1895 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1893 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1896 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1894 // timeLabel->setText( timeString+ tr(" seconds")); 1897 // timeLabel->setText( timeString+ tr(" seconds"));
1895} 1898}
1896 1899
1897void QtRec::FastforwardReleased() { 1900void QtRec::FastforwardReleased() {
1898 forwardTimer->stop(); 1901 forwardTimer->stop();
1899 if( wavFile->track.isOpen()) { 1902 if( wavFile->track.isOpen()) {
1900 sliderPos=timeSlider->value(); 1903 sliderPos=timeSlider->value();
1901 stopped = false; 1904 stopped = false;
1902 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1905 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1903 total = newPos * 4; 1906 total = newPos * 4;
1904 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1907 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1905 startTimer( 1000); 1908 startTimer( 1000);
1906 doPlay(); 1909 doPlay();
1907 } 1910 }
1908} 1911}
1909 1912
1910 1913
1911QString QtRec::getStorage(const QString &fileName) { 1914QString QtRec::getStorage(const QString &fileName) {
1912 1915
1913 StorageInfo storageInfo; 1916 StorageInfo storageInfo;
1914 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1917 const QList<FileSystem> &fs = storageInfo.fileSystems();
1915 QListIterator<FileSystem> it ( fs ); 1918 QListIterator<FileSystem> it ( fs );
1916 QString storage; 1919 QString storage;
1917 for( ; it.current(); ++it ){ 1920 for( ; it.current(); ++it ){
1918 const QString name = ( *it)->name(); 1921 const QString name = ( *it)->name();
1919 const QString path = ( *it)->path(); 1922 const QString path = ( *it)->path();
1920 const QString disk = ( *it)->disk(); 1923 const QString disk = ( *it)->disk();
1921 if( fileName.find( path,0,true) != -1) 1924 if( fileName.find( path,0,true) != -1)
1922 storage = name; 1925 storage = name;
1923 // const QString options = (*it)->options(); 1926 // const QString options = (*it)->options();
1924 // if( name.find( tr("Internal"),0,true) == -1) { 1927 // if( name.find( tr("Internal"),0,true) == -1) {
1925 // storageComboBox->insertItem( name +" -> "+disk); 1928 // storageComboBox->insertItem( name +" -> "+disk);
1926 // odebug << name << oendl; 1929 // odebug << name << oendl;
1927 } 1930 }
1928 return storage; 1931 return storage;
1929 // struct mntent *me; 1932 // struct mntent *me;
1930 // // if(fileName == "/etc/mtab") { 1933 // // if(fileName == "/etc/mtab") {
1931 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 1934 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
1932 // if ( mntfp ) { 1935 // if ( mntfp ) {
1933 // while ( (me = getmntent( mntfp )) != 0 ) { 1936 // while ( (me = getmntent( mntfp )) != 0 ) {
1934 // QString filesystemType = me->mnt_type; 1937 // QString filesystemType = me->mnt_type;
1935 1938
1936 // } 1939 // }
1937 // } 1940 // }
1938 // endmntent( mntfp ); 1941 // endmntent( mntfp );
1939} 1942}
1940 1943
1941void QtRec::setRecordButton(bool b) {
1942
1943 if(b) { //about to record or play
1944
1945 Rec_PushButton->setDown( true);
1946 QPixmap image3( ( const char** ) image3_data );
1947 Stop_PushButton->setPixmap( image3 );
1948 if(Stop_PushButton->isDown())
1949 Stop_PushButton->setDown( true);
1950 // playLabel2->setText( tr("Stop") );
1951
1952 } else { //about to stop
1953
1954 QPixmap image4( ( const char** ) image4_data );
1955 Stop_PushButton->setPixmap( image4);
1956 if(Stop_PushButton->isDown())
1957 Stop_PushButton->setDown( false);
1958 // playLabel2->setText( tr("Play") );
1959 if(Rec_PushButton->isDown())
1960 Rec_PushButton->setDown( false);
1961 }
1962}
1963
1964void QtRec::fillDirectoryCombo() { 1944void QtRec::fillDirectoryCombo() {
1965 if( directoryComboBox->count() > 0) 1945 if( directoryComboBox->count() > 0)
1966 directoryComboBox->clear(); 1946 directoryComboBox->clear();
1967 int index = 0; 1947 int index = 0;
1968 Config cfg("OpieRec"); 1948 Config cfg("OpieRec");
1969 cfg.setGroup("Settings"); 1949 cfg.setGroup("Settings");
1970 QString dir = cfg.readEntry("directory", "/"); 1950 QString dir = cfg.readEntry("directory", "/");
1971 StorageInfo storageInfo; 1951 StorageInfo storageInfo;
1972 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1952 const QList<FileSystem> &fs = storageInfo.fileSystems();
1973 QListIterator<FileSystem> it ( fs ); 1953 QListIterator<FileSystem> it ( fs );
1974 QString storage; 1954 QString storage;
1975 for( ; it.current(); ++it ){ 1955 for( ; it.current(); ++it ){
1976 const QString name = ( *it)->name(); 1956 const QString name = ( *it)->name();
1977 const QString path = ( *it)->path(); 1957 const QString path = ( *it)->path();
1978 // directoryComboBox->insertItem(name+" "+path); 1958 // directoryComboBox->insertItem(name+" "+path);
1979 directoryComboBox->insertItem(name); 1959 directoryComboBox->insertItem(name);
1980 if( path == dir) 1960 if( path == dir)
1981 directoryComboBox->setCurrentItem( index); 1961 directoryComboBox->setCurrentItem( index);
1982 index++; 1962 index++;
1983 } 1963 }
1984} 1964}
1985 1965
1986void QtRec::errorStop() { 1966void QtRec::errorStop() {
1987 stopped = true; 1967 stopped = true;
1988 wavFile->closeFile(); 1968 wavFile->closeFile();
1989 killTimers(); 1969 killTimers();
1990} 1970}
1991 1971
1992void QtRec::doMute(bool b) { 1972void QtRec::doMute(bool b) {
1993 doVolMuting( b); 1973 doVolMuting( b);
1994 doMicMuting( b); 1974 doMicMuting( b);
1995} 1975}
1996 1976
1997void QtRec::slotAutoMute(bool b) { 1977void QtRec::slotAutoMute(bool b) {
1998 autoMute = b; 1978 autoMute = b;
1999 Config cfg("OpieRec"); 1979 Config cfg("OpieRec");
2000 cfg.setGroup("Settings"); 1980 cfg.setGroup("Settings");
2001 cfg.writeEntry("useAutoMute",b); 1981 cfg.writeEntry("useAutoMute",b);
2002 doMute( b); 1982 doMute( b);
2003 outMuteCheckBox->setChecked( b); 1983 outMuteCheckBox->setChecked( b);
2004 inMuteCheckBox->setChecked( b); 1984 inMuteCheckBox->setChecked( b);
2005} 1985}
2006 1986
2007void QtRec::selectItemByName(const QString & name) { 1987void QtRec::selectItemByName(const QString & name) {
2008 QListViewItemIterator it( ListView1 ); 1988 QListViewItemIterator it( ListView1 );
2009 for ( ; it.current(); ++it ) 1989 for ( ; it.current(); ++it )
2010 if( name == it.current()->text(0)) 1990 if( name == it.current()->text(0))
2011 ListView1->setCurrentItem(it.current()); 1991 ListView1->setCurrentItem(it.current());
2012} 1992}
2013 1993
2014 1994
2015// long findPeak(long input ) { 1995// long findPeak(long input ) {
2016 1996
2017// // halfLife = time in seconds for output to decay to half value after an impulse 1997// // halfLife = time in seconds for output to decay to half value after an impulse
2018// static float output = 0.0; 1998// static float output = 0.0;
2019// float halfLife = .0025; 1999// float halfLife = .0025;
2020// float vsf = .0025; 2000// float vsf = .0025;
2021// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); 2001// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate ));
2022// if( input < 0.0 ) 2002// if( input < 0.0 )
2023// input = -input; // Absolute value. 2003// input = -input; // Absolute value.
2024// if ( input >= output ) { 2004// if ( input >= output ) {
2025// // When we hit a peak, ride the peak to the top. 2005// // When we hit a peak, ride the peak to the top.
2026// output = input; 2006// output = input;
2027// } else { 2007// } else {
2028// // Exponential decay of output when signal is low. 2008// // Exponential decay of output when signal is low.
2029// output = output * scalar; 2009// output = output * scalar;
2030// // 2010// //
2031// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow 2011// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow
2032// // which can cause a severe performance degradation due to a flood 2012// // which can cause a severe performance degradation due to a flood
2033// // of interrupts. 2013// // of interrupts.
2034// // 2014// //
2035// if( output < vsf ) output = 0.0; 2015// if( output < vsf ) output = 0.0;
2036// } 2016// }
2037 2017
2038// return (long) output; 2018// return (long) output;
2039// } 2019// }
2040 2020
2041void QtRec::changeStereoCheck(bool b) { 2021void QtRec::changeStereoCheck(bool b) {
2042 Config cfg("OpieRec"); 2022 Config cfg("OpieRec");
2043 cfg.setGroup("Settings"); 2023 cfg.setGroup("Settings");
2044 int ch = 0; 2024 int ch = 0;
2045 if ( !b) { ch = 1;} 2025 if ( !b) { ch = 1;}
2046 else { ch = 2;} 2026 else { ch = 2;}
2047 cfg.writeEntry("stereo", b); 2027 cfg.writeEntry("stereo", b);
2048 filePara.channels = ch; 2028 filePara.channels = ch;
2049 2029
2050 cfg.write(); 2030 cfg.write();
2051} 2031}
2052 2032
2053 2033void QtRec::setButtons() {
2034 if(stopped) {
2035 Stop_PushButton->setPixmap( Opie::Core::OResource::loadPixmap("play2", Opie::Core::OResource::SmallIcon) );
2036 if(ListView1->currentItem()) {
2037 Stop_PushButton->setEnabled(true);
2038 toBeginningButton->setEnabled(true);
2039 toEndButton->setEnabled(true);
2040 deleteSoundButton->setEnabled(true);
2041 timeSlider->setEnabled(true);
2042 }
2043 else {
2044 Stop_PushButton->setEnabled(false);
2045 toBeginningButton->setEnabled(false);
2046 toEndButton->setEnabled(false);
2047 deleteSoundButton->setEnabled(false);
2048 timeSlider->setEnabled(false);
2049 }
2050 }
2051 else {
2052 timeSlider->setEnabled(true);
2053 Stop_PushButton->setPixmap( Opie::Core::OResource::loadPixmap("stop", Opie::Core::OResource::SmallIcon) );
2054 Stop_PushButton->setEnabled(true);
2055 toBeginningButton->setEnabled(false);
2056 toEndButton->setEnabled(false);
2057 deleteSoundButton->setEnabled(false);
2058 }
2059}
2060
2061void QtRec::fileSize(unsigned long size, QString &str) {
2062 if( size > 1048576 )
2063 str.sprintf( "%.0fM", size / 1048576.0 );
2064 else if( size > 1024 )
2065 str.sprintf( "%.0fk", size / 1024.0 );
2066 else
2067 str.sprintf( "%d", size );
2068}
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h
index 6e81af6..b463597 100644
--- a/noncore/multimedia/opierec/qtrec.h
+++ b/noncore/multimedia/opierec/qtrec.h
@@ -37,132 +37,133 @@ class QSlider;
37class QTabWidget; 37class QTabWidget;
38class QTimer; 38class QTimer;
39class QVBoxLayout; 39class QVBoxLayout;
40class QLineEdit; 40class 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
53class QtRec : public QWidget 53class QtRec : public QWidget
54{ 54{
55 Q_OBJECT 55 Q_OBJECT
56 56
57public: 57public:
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
63signals: 63signals:
64 void stopRecording(); 64 void stopRecording();
65 void startRecording(); 65 void startRecording();
66 void stopPlaying(); 66 void stopPlaying();
67 void startPlaying(); 67 void startPlaying();
68 68
69public slots: 69public slots:
70 70
71private: 71private:
72// int fragment; 72// int fragment;
73 int fd1; 73 int fd1;
74 int secCount; 74 int secCount;
75 QString timeString; 75 QString timeString;
76 76
77 QLineEdit *renameBox; 77 QLineEdit *renameBox;
78 QGroupBox* GroupBox1; 78 QGroupBox* GroupBox1;
79 QString currentFile; 79 QString currentFile;
80 QString date, currentFileName, tmpFileName; 80 QString date, currentFileName, tmpFileName;
81 QTimer *t_timer; 81 QTimer *t_timer;
82 bool needsStereoOut, paused; 82 bool needsStereoOut, paused;
83 bool useTmpFile, autoMute; 83 bool useTmpFile, autoMute;
84 84
85 bool eventFilter( QObject * , QEvent * ); 85 bool eventFilter( QObject * , QEvent * );
86 void okRename(); 86 void okRename();
87 void cancelRename(); 87 void cancelRename();
88 QString getStorage(const QString &); 88 QString getStorage(const QString &);
89 bool rec(); 89 bool rec();
90 int getCurrentSizeLimit(); 90 int getCurrentSizeLimit();
91 long checkDiskSpace(const QString &); 91 long checkDiskSpace(const QString &);
92 void doMute(bool); 92 void doMute(bool);
93 void errorStop(); 93 void errorStop();
94 void fillDirectoryCombo(); 94 void fillDirectoryCombo();
95 void getInVol(); 95 void getInVol();
96 void getOutVol(); 96 void getOutVol();
97 void init(); 97 void init();
98 void initConfig(); 98 void initConfig();
99 void initConnections(); 99 void initConnections();
100 void selectItemByName(const QString &); 100 void selectItemByName(const QString &);
101 void setRecordButton(bool);
102 void start(); 101 void start();
103 void stop(); 102 void stop();
104 void timerEvent( QTimerEvent *e ); 103 void timerEvent( QTimerEvent *e );
104 void setButtons();
105 void QtRec::fileSize(unsigned long size, QString &str);
105 106
106private slots: 107private slots:
107 void endPlaying(); 108 void endPlaying();
108 void endRecording(); 109 void endRecording();
109 110
110 void FastforwardPressed(); 111 void FastforwardPressed();
111 void FastforwardReleased(); 112 void FastforwardReleased();
112 113
113 void changeDirCombo(int); 114 void changeDirCombo(int);
114 void changeSizeLimitCombo(int); 115 void changeSizeLimitCombo(int);
115 void changeTimeSlider(int); 116 void changeTimeSlider(int);
116 void changebitrateCombo(int); 117 void changebitrateCombo(int);
117 void changeStereoCheck( bool); 118 void changeStereoCheck( bool);
118 119
119 void changedInVolume(); 120 void changedInVolume();
120 void changedOutVolume(); 121 void changedOutVolume();
121 void changesamplerateCombo(int); 122 void changesamplerateCombo(int);
122 123
123 void cleanUp(); 124 void cleanUp();
124 void compressionSelected(bool); 125 void compressionSelected(bool);
125 void deleteSound(); 126 void deleteSound();
126 void doBeam(); 127 void doBeam();
127 void doMenuPlay(); 128 void doMenuPlay();
128 void doMicMuting(bool); 129 void doMicMuting(bool);
129 void doPlayBtn(); 130 void doPlayBtn();
130 void doRename(); 131 void doRename();
131 void doVolMuting(bool); 132 void doVolMuting(bool);
132 void forwardTimerTimeout(); 133 void forwardTimerTimeout();
133 void itClick(QListViewItem *item); 134 void itClick(QListViewItem *item);
134 void listPressed(int, QListViewItem *, const QPoint&, int); 135 void listPressed(int, QListViewItem *, const QPoint&, int);
135 void newSound(); 136 void newSound();
136 void rewindPressed(); 137 void rewindPressed();
137 void rewindReleased(); 138 void rewindReleased();
138 void rewindTimerTimeout(); 139 void rewindTimerTimeout();
139 void slotAutoMute(bool); 140 void slotAutoMute(bool);
140 void thisTab(QWidget*); 141 void thisTab(QWidget*);
141 void timeSliderPressed(); 142 void timeSliderPressed();
142 void timeSliderReleased(); 143 void timeSliderReleased();
143 void timerBreak(); 144 void timerBreak();
144 void initIconView(); 145 void initIconView();
145/* void changedOutVolume(int); */ 146/* void changedOutVolume(int); */
146/* void changedInVolume(int); */ 147/* void changedInVolume(int); */
147 148
148protected: 149protected:
149 150
150 WavFile *wavFile; 151 WavFile *wavFile;
151 QButtonGroup *ButtonGroup1; 152 QButtonGroup *ButtonGroup1;
152 QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox, *stereoCheckBox; 153 QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox, *stereoCheckBox;
153 QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo; 154 QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo;
154 QHBoxLayout* Layout12; 155 QHBoxLayout* Layout12;
155 QHBoxLayout* Layout13; 156 QHBoxLayout* Layout13;
156 QHBoxLayout* Layout14; 157 QHBoxLayout* Layout14;
157 QHBoxLayout* Layout16; 158 QHBoxLayout* Layout16;
158 QHBoxLayout* Layout17; 159 QHBoxLayout* Layout17;
159 QHBoxLayout* Layout19; 160 QHBoxLayout* Layout19;
160 QIconView *IconView1; 161 QIconView *IconView1;
161 QLabel *NewSoundLabel,*playLabel2; 162 QLabel *NewSoundLabel,*playLabel2;
162 QLabel *TextLabel3, *TextLabel1, *TextLabel2; 163 QLabel *TextLabel3, *TextLabel1, *TextLabel2;
163 QListView *ListView1; 164 QListView *ListView1;
164 QPushButton *Stop_PushButton, *Play_PushButton, *Rec_PushButton, *NewSoundButton, *deleteSoundButton, *toBeginningButton, *toEndButton; 165 QPushButton *Stop_PushButton, *Play_PushButton, *Rec_PushButton, *NewSoundButton, *deleteSoundButton, *toBeginningButton, *toEndButton;
165 QString recDir; 166 QString recDir;
166 QTabWidget *TabWidget; 167 QTabWidget *TabWidget;
167 QTimer *t, *rewindTimer, *forwardTimer; 168 QTimer *t, *rewindTimer, *forwardTimer;
168 QVBoxLayout* Layout15; 169 QVBoxLayout* Layout15;