-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 0a6e5ae..f2035ef 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -572,418 +572,418 @@ void QtRec::init() { | |||
572 | ListView1->setColumnWidth( 3, 63); | 572 | ListView1->setColumnWidth( 3, 63); |
573 | 573 | ||
574 | ListView1->setColumnWidthMode( 0, QListView::Manual); | 574 | ListView1->setColumnWidthMode( 0, QListView::Manual); |
575 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); | 575 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); |
576 | ListView1->setColumnAlignment( 2, QListView::AlignRight); | 576 | ListView1->setColumnAlignment( 2, QListView::AlignRight); |
577 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); | 577 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); |
578 | ListView1->setAllColumnsShowFocus( true ); | 578 | ListView1->setAllColumnsShowFocus( true ); |
579 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); | 579 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); |
580 | 580 | ||
581 | TabWidget->insertTab( tab, tr( "Files" ) ); | 581 | TabWidget->insertTab( tab, tr( "Files" ) ); |
582 | 582 | ||
583 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 583 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
584 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 584 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
585 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); | 585 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); |
586 | glayout3->setSpacing( 2); | 586 | glayout3->setSpacing( 2); |
587 | glayout3->setMargin( 2); | 587 | glayout3->setMargin( 2); |
588 | //////////////////////////////////// | 588 | //////////////////////////////////// |
589 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); | 589 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); |
590 | sampleGroup->setTitle( tr( "Sample Rate" ) ); | 590 | sampleGroup->setTitle( tr( "Sample Rate" ) ); |
591 | sampleGroup->setFixedSize( 95,50); | 591 | sampleGroup->setFixedSize( 95,50); |
592 | 592 | ||
593 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 593 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
594 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 594 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
595 | //#ifndef QT_QWS_EBX | 595 | //#ifndef QT_QWS_EBX |
596 | QString s; | 596 | QString s; |
597 | int z = 0; | 597 | int z = 0; |
598 | while( deviceSampleRates[z] != -1) { | 598 | while( deviceSampleRates[z] != -1) { |
599 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); | 599 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); |
600 | z++; | 600 | z++; |
601 | } | 601 | } |
602 | 602 | ||
603 | 603 | ||
604 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); | 604 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); |
605 | 605 | ||
606 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); | 606 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); |
607 | sizeGroup->setTitle( tr( "Limit Size" ) ); | 607 | sizeGroup->setTitle( tr( "Limit Size" ) ); |
608 | sizeGroup->setFixedSize( 80, 50); | 608 | sizeGroup->setFixedSize( 80, 50); |
609 | 609 | ||
610 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); | 610 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); |
611 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); | 611 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); |
612 | sizeLimitCombo->insertItem(tr("Unlimited")); | 612 | sizeLimitCombo->insertItem(tr("Unlimited")); |
613 | 613 | ||
614 | for(int i=1;i<13; i++) { | 614 | for(int i=1;i<13; i++) { |
615 | sizeLimitCombo->insertItem( QString::number( i * 5)); | 615 | sizeLimitCombo->insertItem( QString::number( i * 5)); |
616 | } | 616 | } |
617 | 617 | ||
618 | 618 | ||
619 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); | 619 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); |
620 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); | 620 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); |
621 | dirGroup->setTitle( tr( "File Directory" ) ); | 621 | dirGroup->setTitle( tr( "File Directory" ) ); |
622 | dirGroup->setFixedSize( 130, 50); | 622 | dirGroup->setFixedSize( 130, 50); |
623 | 623 | ||
624 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); | 624 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); |
625 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); | 625 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); |
626 | 626 | ||
627 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); | 627 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); |
628 | 628 | ||
629 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); | 629 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); |
630 | bitGroup->setTitle( tr( "Bit Depth" ) ); | 630 | bitGroup->setTitle( tr( "Bit Depth" ) ); |
631 | bitGroup->setFixedSize( 65, 50); | 631 | bitGroup->setFixedSize( 65, 50); |
632 | 632 | ||
633 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); | 633 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); |
634 | 634 | ||
635 | z = 0; | 635 | z = 0; |
636 | while( deviceBitRates[z] != -1) { | 636 | while( deviceBitRates[z] != -1) { |
637 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); | 637 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); |
638 | z++; | 638 | z++; |
639 | } | 639 | } |
640 | 640 | ||
641 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | 641 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); |
642 | 642 | ||
643 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); | 643 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); |
644 | 644 | ||
645 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); | 645 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); |
646 | 646 | ||
647 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); | 647 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); |
648 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); | 648 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); |
649 | 649 | ||
650 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); | 650 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); |
651 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); | 651 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); |
652 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); | 652 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); |
653 | 653 | ||
654 | tab_5 = new QWidget( TabWidget, "tab_5" ); | 654 | tab_5 = new QWidget( TabWidget, "tab_5" ); |
655 | 655 | ||
656 | QHBoxLayout *Layout19a; | 656 | QHBoxLayout *Layout19a; |
657 | Layout19a = new QHBoxLayout( tab_5); | 657 | Layout19a = new QHBoxLayout( tab_5); |
658 | Layout19a->setSpacing( 2 ); | 658 | Layout19a->setSpacing( 2 ); |
659 | Layout19a->setMargin( 0 ); | 659 | Layout19a->setMargin( 0 ); |
660 | 660 | ||
661 | Layout15 = new QVBoxLayout( this); | 661 | Layout15 = new QVBoxLayout( this); |
662 | Layout15->setSpacing( 2 ); | 662 | Layout15->setSpacing( 2 ); |
663 | Layout15->setMargin( 0 ); | 663 | Layout15->setMargin( 0 ); |
664 | 664 | ||
665 | Layout15b = new QVBoxLayout( this); | 665 | Layout15b = new QVBoxLayout( this); |
666 | Layout15b->setSpacing( 2 ); | 666 | Layout15b->setSpacing( 2 ); |
667 | Layout15b->setMargin( 0 ); | 667 | Layout15b->setMargin( 0 ); |
668 | 668 | ||
669 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); | 669 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); |
670 | TextLabel2->setText( tr( "In")); | 670 | TextLabel2->setText( tr( "In")); |
671 | TextLabel2->setFixedWidth( 35); | 671 | TextLabel2->setFixedWidth( 35); |
672 | Layout15->addWidget( TextLabel2 ); | 672 | Layout15->addWidget( TextLabel2 ); |
673 | 673 | ||
674 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); | 674 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); |
675 | TextLabel3->setText( tr( "Out" ) ); | 675 | TextLabel3->setText( tr( "Out" ) ); |
676 | Layout15b->addWidget( TextLabel3 ); | 676 | Layout15b->addWidget( TextLabel3 ); |
677 | 677 | ||
678 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); | 678 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); |
679 | InputSlider->setTickmarks( QSlider::Both); | 679 | InputSlider->setTickmarks( QSlider::Both); |
680 | Layout15->addWidget( InputSlider); | 680 | Layout15->addWidget( InputSlider); |
681 | 681 | ||
682 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); | 682 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); |
683 | OutputSlider->setTickmarks( QSlider::Both); | 683 | OutputSlider->setTickmarks( QSlider::Both); |
684 | 684 | ||
685 | Layout15b->addWidget( OutputSlider ); | 685 | Layout15b->addWidget( OutputSlider ); |
686 | 686 | ||
687 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 687 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
688 | Layout15->addWidget( outMuteCheckBox ); | 688 | Layout15->addWidget( outMuteCheckBox ); |
689 | 689 | ||
690 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 690 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
691 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); | 691 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); |
692 | Layout15b->addWidget( inMuteCheckBox ); | 692 | Layout15b->addWidget( inMuteCheckBox ); |
693 | 693 | ||
694 | 694 | ||
695 | Layout19a->addLayout( Layout15 ); | 695 | Layout19a->addLayout( Layout15 ); |
696 | Layout19a->addLayout( Layout15b ); | 696 | Layout19a->addLayout( Layout15b ); |
697 | 697 | ||
698 | fillDirectoryCombo(); | 698 | fillDirectoryCombo(); |
699 | 699 | ||
700 | TabWidget->insertTab( tab_3, tr( "Options" ) ); | 700 | TabWidget->insertTab( tab_3, tr( "Options" ) ); |
701 | 701 | ||
702 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); | 702 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); |
703 | 703 | ||
704 | 704 | ||
705 | waveform = new Waveform( this, "waveform" ); | 705 | waveform = new Waveform( this, "waveform" ); |
706 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); | 706 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); |
707 | waveform->setMinimumSize( QSize( 0, 50 ) ); | 707 | waveform->setMinimumSize( QSize( 0, 50 ) ); |
708 | 708 | ||
709 | layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); | 709 | layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); |
710 | waveform->setBackgroundColor ( black ); | 710 | waveform->setBackgroundColor ( black ); |
711 | } | 711 | } |
712 | 712 | ||
713 | void QtRec::initIconView() { | 713 | void QtRec::initIconView() { |
714 | 714 | ||
715 | ListView1->clear(); | 715 | ListView1->clear(); |
716 | Config cfg("OpieRec"); | 716 | Config cfg("OpieRec"); |
717 | cfg.setGroup("Sounds"); | 717 | cfg.setGroup("Sounds"); |
718 | QString temp; | 718 | QString temp; |
719 | QPixmap image0( ( const char** ) image0_data ); | 719 | QPixmap image0( ( const char** ) image0_data ); |
720 | 720 | ||
721 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 721 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
722 | // qDebug("init number of files %d", nFiles); | 722 | // qDebug("init number of files %d", nFiles); |
723 | 723 | ||
724 | for(int i=1;i<= nFiles;i++) { | 724 | for(int i=1;i<= nFiles;i++) { |
725 | 725 | ||
726 | QListViewItem * item; | 726 | QListViewItem * item; |
727 | QString fileS, mediaLocation, fileDate, filePath; | 727 | QString fileS, mediaLocation, fileDate, filePath; |
728 | 728 | ||
729 | temp.sprintf( "%d",i); | 729 | temp.sprintf( "%d",i); |
730 | temp = cfg.readEntry( temp,""); //reads currentFile | 730 | temp = cfg.readEntry( temp,""); //reads currentFile |
731 | filePath = cfg.readEntry( temp,""); //currentFileName | 731 | filePath = cfg.readEntry( temp,""); //currentFileName |
732 | 732 | ||
733 | QFileInfo info(filePath); | 733 | QFileInfo info(filePath); |
734 | fileDate = info.lastModified().toString(); | 734 | fileDate = info.lastModified().toString(); |
735 | 735 | ||
736 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds | 736 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds |
737 | mediaLocation = getStorage( filePath); | 737 | mediaLocation = getStorage( filePath); |
738 | if( info.exists()) { | 738 | if( info.exists()) { |
739 | item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); | 739 | item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); |
740 | item->setPixmap( 0, image0); | 740 | item->setPixmap( 0, image0); |
741 | if( currentFileName == filePath) | 741 | if( currentFileName == filePath) |
742 | ListView1->setSelected( item, true); | 742 | ListView1->setSelected( item, true); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | } | 745 | } |
746 | 746 | ||
747 | void QtRec::initConnections() { | 747 | void QtRec::initConnections() { |
748 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 748 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
749 | 749 | ||
750 | connect( toBeginningButton, SIGNAL( pressed()), | 750 | connect( toBeginningButton, SIGNAL( pressed()), |
751 | this, SLOT( rewindPressed() )); | 751 | this, SLOT( rewindPressed() )); |
752 | connect( toBeginningButton, SIGNAL( released()), | 752 | connect( toBeginningButton, SIGNAL( released()), |
753 | this, SLOT( rewindReleased() )); | 753 | this, SLOT( rewindReleased() )); |
754 | connect( toEndButton, SIGNAL( pressed()), | 754 | connect( toEndButton, SIGNAL( pressed()), |
755 | this, SLOT( FastforwardPressed() )); | 755 | this, SLOT( FastforwardPressed() )); |
756 | connect( toEndButton, SIGNAL( released()), | 756 | connect( toEndButton, SIGNAL( released()), |
757 | this, SLOT( FastforwardReleased() )); | 757 | this, SLOT( FastforwardReleased() )); |
758 | connect( deleteSoundButton, SIGNAL(released()), | 758 | connect( deleteSoundButton, SIGNAL(released()), |
759 | this, SLOT( deleteSound() )); | 759 | this, SLOT( deleteSound() )); |
760 | connect( Stop_PushButton, SIGNAL(released()), | 760 | connect( Stop_PushButton, SIGNAL(released()), |
761 | this, SLOT( doPlayBtn() )); | 761 | this, SLOT( doPlayBtn() )); |
762 | connect( Rec_PushButton, SIGNAL(released()), | 762 | connect( Rec_PushButton, SIGNAL(released()), |
763 | this, SLOT( newSound() ) ); | 763 | this, SLOT( newSound() ) ); |
764 | connect( TabWidget, SIGNAL( currentChanged( QWidget*)), | 764 | connect( TabWidget, SIGNAL( currentChanged(QWidget*)), |
765 | this, SLOT(thisTab(QWidget*) )); | 765 | this, SLOT(thisTab(QWidget*) )); |
766 | connect( OutputSlider, SIGNAL(sliderReleased()), | 766 | connect( OutputSlider, SIGNAL(sliderReleased()), |
767 | this, SLOT( changedOutVolume()) ); | 767 | this, SLOT( changedOutVolume()) ); |
768 | connect( InputSlider, SIGNAL(sliderReleased()), | 768 | connect( InputSlider, SIGNAL(sliderReleased()), |
769 | this, SLOT( changedInVolume()) ); | 769 | this, SLOT( changedInVolume()) ); |
770 | 770 | ||
771 | connect( sampleRateComboBox, SIGNAL(activated( int)), | 771 | connect( sampleRateComboBox, SIGNAL(activated(int)), |
772 | this, SLOT( changesamplerateCombo(int)) ); | 772 | this, SLOT( changesamplerateCombo(int)) ); |
773 | connect( bitRateComboBox, SIGNAL(activated( int)), | 773 | connect( bitRateComboBox, SIGNAL(activated(int)), |
774 | this, SLOT( changebitrateCombo(int)) ); | 774 | this, SLOT( changebitrateCombo(int)) ); |
775 | 775 | ||
776 | connect( directoryComboBox, SIGNAL(activated( int)), | 776 | connect( directoryComboBox, SIGNAL(activated(int)), |
777 | this, SLOT( changeDirCombo(int)) ); | 777 | this, SLOT( changeDirCombo(int)) ); |
778 | connect( sizeLimitCombo, SIGNAL(activated( int)), | 778 | connect( sizeLimitCombo, SIGNAL(activated(int)), |
779 | this, SLOT( changeSizeLimitCombo(int)) ); | 779 | this, SLOT( changeSizeLimitCombo(int)) ); |
780 | 780 | ||
781 | connect( stereoCheckBox, SIGNAL(toggled( bool)), | 781 | connect( stereoCheckBox, SIGNAL(toggled(bool)), |
782 | this, SLOT( changeStereoCheck(bool)) ); | 782 | this, SLOT( changeStereoCheck(bool)) ); |
783 | 783 | ||
784 | connect( outMuteCheckBox, SIGNAL(toggled( bool)), | 784 | connect( outMuteCheckBox, SIGNAL(toggled(bool)), |
785 | this, SLOT( doVolMuting(bool)) ); | 785 | this, SLOT( doVolMuting(bool)) ); |
786 | connect( inMuteCheckBox , SIGNAL(toggled( bool)), | 786 | connect( inMuteCheckBox , SIGNAL(toggled(bool)), |
787 | this, SLOT( doMicMuting(bool)) ); | 787 | this, SLOT( doMicMuting(bool)) ); |
788 | 788 | ||
789 | connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)), | 789 | connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), |
790 | this,SLOT( itClick(QListViewItem*))); | 790 | this,SLOT( itClick(QListViewItem*))); |
791 | connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 791 | connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
792 | this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) ); | 792 | this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); |
793 | connect( timeSlider, SIGNAL( sliderMoved( int)), | 793 | connect( timeSlider, SIGNAL( sliderMoved(int)), |
794 | this, SLOT( changeTimeSlider(int) )); | 794 | this, SLOT( changeTimeSlider(int) )); |
795 | connect( timeSlider, SIGNAL( sliderPressed( )), | 795 | connect( timeSlider, SIGNAL( sliderPressed()), |
796 | this, SLOT( timeSliderPressed() )); | 796 | this, SLOT( timeSliderPressed() )); |
797 | connect( timeSlider, SIGNAL( sliderReleased( )), | 797 | connect( timeSlider, SIGNAL( sliderReleased()), |
798 | this, SLOT( timeSliderReleased() )); | 798 | this, SLOT( timeSliderReleased() )); |
799 | connect( compressionCheckBox, SIGNAL( toggled(bool)), | 799 | connect( compressionCheckBox, SIGNAL( toggled(bool)), |
800 | this, SLOT( compressionSelected(bool))); | 800 | this, SLOT( compressionSelected(bool))); |
801 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), | 801 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), |
802 | this, SLOT( slotAutoMute(bool))); | 802 | this, SLOT( slotAutoMute(bool))); |
803 | } | 803 | } |
804 | 804 | ||
805 | void QtRec::initConfig() { | 805 | void QtRec::initConfig() { |
806 | int index, fred, i; | 806 | int index, fred, i; |
807 | Config cfg("OpieRec"); | 807 | Config cfg("OpieRec"); |
808 | cfg.setGroup("Settings"); | 808 | cfg.setGroup("Settings"); |
809 | 809 | ||
810 | index = cfg.readNumEntry("samplerate",22050); | 810 | index = cfg.readNumEntry("samplerate",22050); |
811 | bool ok; | 811 | bool ok; |
812 | 812 | ||
813 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { | 813 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { |
814 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); | 814 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); |
815 | if( index == fred) { | 815 | if( index == fred) { |
816 | filePara.sampleRate = fred; | 816 | filePara.sampleRate = fred; |
817 | sampleRateComboBox->setCurrentItem(ws); | 817 | sampleRateComboBox->setCurrentItem(ws); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | 820 | ||
821 | i = cfg.readNumEntry("bitrate",16); | 821 | i = cfg.readNumEntry("bitrate",16); |
822 | if(i == 16) | 822 | if(i == 16) |
823 | bitRateComboBox->setCurrentItem( 1); | 823 | bitRateComboBox->setCurrentItem( 1); |
824 | elseif(i == 24) | 824 | elseif(i == 24) |
825 | bitRateComboBox->setCurrentItem( 2); | 825 | bitRateComboBox->setCurrentItem( 2); |
826 | elseif(i == 32) | 826 | elseif(i == 32) |
827 | bitRateComboBox->setCurrentItem( 3); | 827 | bitRateComboBox->setCurrentItem( 3); |
828 | else | 828 | else |
829 | bitRateComboBox->setCurrentItem( 0); | 829 | bitRateComboBox->setCurrentItem( 0); |
830 | 830 | ||
831 | filePara.resolution = i; | 831 | filePara.resolution = i; |
832 | 832 | ||
833 | i = cfg.readNumEntry("sizeLimit", 5 ); | 833 | i = cfg.readNumEntry("sizeLimit", 5 ); |
834 | QString temp; | 834 | QString temp; |
835 | sizeLimitCombo->setCurrentItem((i/5)); | 835 | sizeLimitCombo->setCurrentItem((i/5)); |
836 | 836 | ||
837 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); | 837 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); |
838 | if( stereoCheckBox->isChecked()) { | 838 | if( stereoCheckBox->isChecked()) { |
839 | filePara.channels = 2; | 839 | filePara.channels = 2; |
840 | } else { | 840 | } else { |
841 | filePara.channels = 1; | 841 | filePara.channels = 1; |
842 | } | 842 | } |
843 | 843 | ||
844 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 844 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
845 | if( compressionCheckBox->isChecked()) { | 845 | if( compressionCheckBox->isChecked()) { |
846 | bitRateComboBox->setEnabled(false); | 846 | bitRateComboBox->setEnabled(false); |
847 | bitRateComboBox->setCurrentItem(0); | 847 | bitRateComboBox->setCurrentItem(0); |
848 | filePara.resolution=16; | 848 | filePara.resolution=16; |
849 | } | 849 | } |
850 | 850 | ||
851 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 851 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
852 | if( autoMuteCheckBox->isChecked()) | 852 | if( autoMuteCheckBox->isChecked()) |
853 | slotAutoMute(true); | 853 | slotAutoMute(true); |
854 | else | 854 | else |
855 | slotAutoMute(false); | 855 | slotAutoMute(false); |
856 | 856 | ||
857 | Config cofg( "qpe"); | 857 | Config cofg( "qpe"); |
858 | cofg.setGroup( "Volume"); | 858 | cofg.setGroup( "Volume"); |
859 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); | 859 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); |
860 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); | 860 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); |
861 | } | 861 | } |
862 | 862 | ||
863 | void QtRec::stop() { | 863 | void QtRec::stop() { |
864 | qWarning("STOP"); | 864 | qWarning("STOP"); |
865 | setRecordButton(false); | 865 | setRecordButton(false); |
866 | 866 | ||
867 | if( !recording) | 867 | if( !recording) |
868 | endPlaying(); | 868 | endPlaying(); |
869 | else | 869 | else |
870 | endRecording(); | 870 | endRecording(); |
871 | timeSlider->setValue(0); | 871 | timeSlider->setValue(0); |
872 | } | 872 | } |
873 | 873 | ||
874 | void QtRec::doPlayBtn() { | 874 | void QtRec::doPlayBtn() { |
875 | 875 | ||
876 | if(!stopped) { | 876 | if(!stopped) { |
877 | playLabel2->setText(tr("Play")); | 877 | playLabel2->setText(tr("Play")); |
878 | stop(); | 878 | stop(); |
879 | } else { | 879 | } else { |
880 | if(ListView1->currentItem() == 0) return; | 880 | if(ListView1->currentItem() == 0) return; |
881 | playLabel2->setText(tr("Stop")); | 881 | playLabel2->setText(tr("Stop")); |
882 | currentFile = ListView1->currentItem()->text(0); | 882 | currentFile = ListView1->currentItem()->text(0); |
883 | start(); | 883 | start(); |
884 | } | 884 | } |
885 | } | 885 | } |
886 | 886 | ||
887 | void QtRec::start() { //play | 887 | void QtRec::start() { //play |
888 | if( stopped) { | 888 | if( stopped) { |
889 | QPixmap image3( ( const char** ) image3_data ); | 889 | QPixmap image3( ( const char** ) image3_data ); |
890 | Stop_PushButton->setPixmap( image3 ); | 890 | Stop_PushButton->setPixmap( image3 ); |
891 | Stop_PushButton->setDown( true); | 891 | Stop_PushButton->setDown( true); |
892 | stopped = false; | 892 | stopped = false; |
893 | paused = false; | 893 | paused = false; |
894 | secCount = 1; | 894 | secCount = 1; |
895 | 895 | ||
896 | if( openPlayFile()) | 896 | if( openPlayFile()) |
897 | if( setupAudio( false)) //recording is false | 897 | if( setupAudio( false)) //recording is false |
898 | doPlay(); | 898 | doPlay(); |
899 | } | 899 | } |
900 | } | 900 | } |
901 | 901 | ||
902 | bool QtRec::rec() { //record | 902 | bool QtRec::rec() { //record |
903 | QString timeString; | 903 | QString timeString; |
904 | timeString.sprintf("%.0f", 0.0); | 904 | timeString.sprintf("%.0f", 0.0); |
905 | timeLabel->setText( timeString+ " seconds"); | 905 | timeLabel->setText( timeString+ " seconds"); |
906 | if(!stopped) { | 906 | if(!stopped) { |
907 | monitoring = true; | 907 | monitoring = true; |
908 | return false; | 908 | return false; |
909 | } else { | 909 | } else { |
910 | secCount = 1; | 910 | secCount = 1; |
911 | playLabel2->setText(tr("Stop")); | 911 | playLabel2->setText(tr("Stop")); |
912 | monitoring = false; | 912 | monitoring = false; |
913 | setRecordButton( true); | 913 | setRecordButton( true); |
914 | 914 | ||
915 | if( setupAudio( true)) | 915 | if( setupAudio( true)) |
916 | if(setUpFile()) { | 916 | if(setUpFile()) { |
917 | int fileSize = 0; | 917 | int fileSize = 0; |
918 | Config cfg("OpieRec"); | 918 | Config cfg("OpieRec"); |
919 | cfg.setGroup("Settings"); | 919 | cfg.setGroup("Settings"); |
920 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", | 920 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", |
921 | // soundDevice->getDeviceBits(), | 921 | // soundDevice->getDeviceBits(), |
922 | // soundDevice->getDeviceRate(), | 922 | // soundDevice->getDeviceRate(), |
923 | // soundDevice->getDeviceChannels()); | 923 | // soundDevice->getDeviceChannels()); |
924 | 924 | ||
925 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 925 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
926 | // qDebug("sample rate is %d", filePara.sampleRate); | 926 | // qDebug("sample rate is %d", filePara.sampleRate); |
927 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 927 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
928 | 928 | ||
929 | // qDebug("size limit %d sec", filePara.SecondsToRecord); | 929 | // qDebug("size limit %d sec", filePara.SecondsToRecord); |
930 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 930 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
931 | 931 | ||
932 | if( filePara.SecondsToRecord == 0) { | 932 | if( filePara.SecondsToRecord == 0) { |
933 | fileSize = diskSize; | 933 | fileSize = diskSize; |
934 | } else if( filePara.format == WAVE_FORMAT_PCM) { | 934 | } else if( filePara.format == WAVE_FORMAT_PCM) { |
935 | // qDebug("WAVE_FORMAT_PCM"); | 935 | // qDebug("WAVE_FORMAT_PCM"); |
936 | fileSize = (filePara.SecondsToRecord ) * filePara.channels | 936 | fileSize = (filePara.SecondsToRecord ) * filePara.channels |
937 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; | 937 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; |
938 | } else { | 938 | } else { |
939 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 939 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
940 | fileSize = ((filePara.SecondsToRecord) * filePara.channels | 940 | fileSize = ((filePara.SecondsToRecord) * filePara.channels |
941 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; | 941 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; |
942 | } | 942 | } |
943 | 943 | ||
944 | filePara.samplesToRecord = fileSize; | 944 | filePara.samplesToRecord = fileSize; |
945 | qDebug("filesize should be %d, bits %d, rate %d", | 945 | qDebug("filesize should be %d, bits %d, rate %d", |
946 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); | 946 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); |
947 | if( paused) { | 947 | if( paused) { |
948 | paused = false; | 948 | paused = false; |
949 | } | 949 | } |
950 | // else { | 950 | // else { |
951 | qDebug("Setting timeslider %d", filePara.samplesToRecord); | 951 | qDebug("Setting timeslider %d", filePara.samplesToRecord); |
952 | // if(fileSize != 0) | 952 | // if(fileSize != 0) |
953 | timeSlider->setRange(0, filePara.samplesToRecord); | 953 | timeSlider->setRange(0, filePara.samplesToRecord); |
954 | // } | 954 | // } |
955 | 955 | ||
956 | if( diskSize < fileSize/1024) { | 956 | if( diskSize < fileSize/1024) { |
957 | QMessageBox::warning(this, | 957 | QMessageBox::warning(this, |
958 | tr("Low Disk Space"), | 958 | tr("Low Disk Space"), |
959 | tr("You are running low of\nrecording space\n" | 959 | tr("You are running low of\nrecording space\n" |
960 | "or a card isn't being recognized")); | 960 | "or a card isn't being recognized")); |
961 | stopped = true; //we need to be stopped | 961 | stopped = true; //we need to be stopped |
962 | stop(); | 962 | stop(); |
963 | } else { | 963 | } else { |
964 | QString msg; | 964 | QString msg; |
965 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 965 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
966 | #ifdef DEV_VERSION | 966 | #ifdef DEV_VERSION |
967 | setCaption( msg); | 967 | setCaption( msg); |
968 | #endif | 968 | #endif |
969 | filePara.fileName=currentFile.latin1(); | 969 | filePara.fileName=currentFile.latin1(); |
970 | qDebug("Start recording thread"); | 970 | qDebug("Start recording thread"); |
971 | stopped = false; | 971 | stopped = false; |
972 | 972 | ||
973 | #ifdef THREADED | 973 | #ifdef THREADED |
974 | pthread_t thread1; | 974 | pthread_t thread1; |
975 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 975 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
976 | #endif | 976 | #endif |
977 | toBeginningButton->setEnabled( false); | 977 | toBeginningButton->setEnabled( false); |
978 | toEndButton->setEnabled( false); | 978 | toEndButton->setEnabled( false); |
979 | 979 | ||
980 | startTimer(1000); | 980 | startTimer(1000); |
981 | #ifndef THREADED | 981 | #ifndef THREADED |
982 | quickRec(); | 982 | quickRec(); |
983 | #endif | 983 | #endif |
984 | } | 984 | } |
985 | } //end setUpFile | 985 | } //end setUpFile |
986 | } //end setupAudio | 986 | } //end setupAudio |
987 | return true; | 987 | return true; |
988 | } | 988 | } |
989 | /* | 989 | /* |
@@ -1467,385 +1467,385 @@ void QtRec::endRecording() { | |||
1467 | if( wavFile->track.isOpen()) { | 1467 | if( wavFile->track.isOpen()) { |
1468 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); | 1468 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); |
1469 | // soundDevice->sd=-1; | 1469 | // soundDevice->sd=-1; |
1470 | filePara.numberSamples = 0; | 1470 | filePara.numberSamples = 0; |
1471 | // filePara.sd=-1; | 1471 | // filePara.sd=-1; |
1472 | wavFile->closeFile(); | 1472 | wavFile->closeFile(); |
1473 | filePara.fd=0; | 1473 | filePara.fd=0; |
1474 | 1474 | ||
1475 | if( wavFile->isTempFile()) { | 1475 | if( wavFile->isTempFile()) { |
1476 | // move tmp file to regular file | 1476 | // move tmp file to regular file |
1477 | QString cmd; | 1477 | QString cmd; |
1478 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); | 1478 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); |
1479 | // qDebug("moving tmp file to "+currentFileName); | 1479 | // qDebug("moving tmp file to "+currentFileName); |
1480 | system( cmd.latin1()); | 1480 | system( cmd.latin1()); |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | qDebug("Just moved " + wavFile->currentFileName); | 1483 | qDebug("Just moved " + wavFile->currentFileName); |
1484 | Config cfg("OpieRec"); | 1484 | Config cfg("OpieRec"); |
1485 | cfg.setGroup("Sounds"); | 1485 | cfg.setGroup("Sounds"); |
1486 | 1486 | ||
1487 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1487 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1488 | 1488 | ||
1489 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); | 1489 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); |
1490 | currentFile = currentFile.left( currentFile.length() - 4); | 1490 | currentFile = currentFile.left( currentFile.length() - 4); |
1491 | 1491 | ||
1492 | cfg.writeEntry( "NumberofFiles", nFiles + 1); | 1492 | cfg.writeEntry( "NumberofFiles", nFiles + 1); |
1493 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); | 1493 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); |
1494 | cfg.writeEntry( currentFile, wavFile->currentFileName); | 1494 | cfg.writeEntry( currentFile, wavFile->currentFileName); |
1495 | 1495 | ||
1496 | QString time; | 1496 | QString time; |
1497 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1497 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1498 | cfg.writeEntry( wavFile->currentFileName, time ); | 1498 | cfg.writeEntry( wavFile->currentFileName, time ); |
1499 | // qDebug("writing config numberOfRecordedSeconds "+time); | 1499 | // qDebug("writing config numberOfRecordedSeconds "+time); |
1500 | 1500 | ||
1501 | cfg.write(); | 1501 | cfg.write(); |
1502 | qDebug("finished recording"); | 1502 | qDebug("finished recording"); |
1503 | timeLabel->setText(""); | 1503 | timeLabel->setText(""); |
1504 | } | 1504 | } |
1505 | 1505 | ||
1506 | if(soundDevice) delete soundDevice; | 1506 | if(soundDevice) delete soundDevice; |
1507 | 1507 | ||
1508 | timeSlider->setValue(0); | 1508 | timeSlider->setValue(0); |
1509 | initIconView(); | 1509 | initIconView(); |
1510 | selectItemByName( currentFile); | 1510 | selectItemByName( currentFile); |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | void QtRec::endPlaying() { | 1513 | void QtRec::endPlaying() { |
1514 | monitoring = false; | 1514 | monitoring = false; |
1515 | recording = false; | 1515 | recording = false; |
1516 | playing = false; | 1516 | playing = false; |
1517 | stopped = true; | 1517 | stopped = true; |
1518 | waveform->reset(); | 1518 | waveform->reset(); |
1519 | // errorStop(); | 1519 | // errorStop(); |
1520 | // qDebug("end playing"); | 1520 | // qDebug("end playing"); |
1521 | setRecordButton( false); | 1521 | setRecordButton( false); |
1522 | 1522 | ||
1523 | toBeginningButton->setEnabled( true); | 1523 | toBeginningButton->setEnabled( true); |
1524 | toEndButton->setEnabled( true); | 1524 | toEndButton->setEnabled( true); |
1525 | 1525 | ||
1526 | if(autoMute) | 1526 | if(autoMute) |
1527 | doMute( true); | 1527 | doMute( true); |
1528 | 1528 | ||
1529 | soundDevice->closeDevice( false); | 1529 | soundDevice->closeDevice( false); |
1530 | soundDevice->sd = -1; | 1530 | soundDevice->sd = -1; |
1531 | // if(soundDevice) delete soundDevice; | 1531 | // if(soundDevice) delete soundDevice; |
1532 | // qDebug("file and sound device closed"); | 1532 | // qDebug("file and sound device closed"); |
1533 | timeLabel->setText(""); | 1533 | timeLabel->setText(""); |
1534 | total = 0; | 1534 | total = 0; |
1535 | filePara.numberSamples = 0; | 1535 | filePara.numberSamples = 0; |
1536 | filePara.sd = -1; | 1536 | filePara.sd = -1; |
1537 | // wavFile->closeFile(); | 1537 | // wavFile->closeFile(); |
1538 | filePara.fd = 0; | 1538 | filePara.fd = 0; |
1539 | // if(wavFile) delete wavFile; //this crashes | 1539 | // if(wavFile) delete wavFile; //this crashes |
1540 | 1540 | ||
1541 | // qDebug("track closed"); | 1541 | // qDebug("track closed"); |
1542 | killTimers(); | 1542 | killTimers(); |
1543 | qWarning("reset slider"); | 1543 | qWarning("reset slider"); |
1544 | timeSlider->setValue(0); | 1544 | timeSlider->setValue(0); |
1545 | 1545 | ||
1546 | if(soundDevice) delete soundDevice; | 1546 | if(soundDevice) delete soundDevice; |
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | bool QtRec::openPlayFile() { | 1550 | bool QtRec::openPlayFile() { |
1551 | 1551 | ||
1552 | qApp->processEvents(); | 1552 | qApp->processEvents(); |
1553 | if( currentFile.isEmpty()) { | 1553 | if( currentFile.isEmpty()) { |
1554 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); | 1554 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); |
1555 | endPlaying(); | 1555 | endPlaying(); |
1556 | return false; | 1556 | return false; |
1557 | } | 1557 | } |
1558 | QString currentFileName; | 1558 | QString currentFileName; |
1559 | Config cfg("OpieRec"); | 1559 | Config cfg("OpieRec"); |
1560 | cfg.setGroup("Sounds"); | 1560 | cfg.setGroup("Sounds"); |
1561 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); | 1561 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); |
1562 | for(int i=0;i<nFiles+1;i++) { //look for file | 1562 | for(int i=0;i<nFiles+1;i++) { //look for file |
1563 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { | 1563 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { |
1564 | currentFileName = cfg.readEntry( currentFile, "" ); | 1564 | currentFileName = cfg.readEntry( currentFile, "" ); |
1565 | qDebug("opening for play: " + currentFileName); | 1565 | qDebug("opening for play: " + currentFileName); |
1566 | } | 1566 | } |
1567 | } | 1567 | } |
1568 | wavFile = new WavFile(this, | 1568 | wavFile = new WavFile(this, |
1569 | currentFileName, | 1569 | currentFileName, |
1570 | false); | 1570 | false); |
1571 | filePara.fd = wavFile->wavHandle(); | 1571 | filePara.fd = wavFile->wavHandle(); |
1572 | if(filePara.fd == -1) { | 1572 | if(filePara.fd == -1) { |
1573 | // if(!track.open(IO_ReadOnly)) { | 1573 | // if(!track.open(IO_ReadOnly)) { |
1574 | QString errorMsg = (QString)strerror(errno); | 1574 | QString errorMsg = (QString)strerror(errno); |
1575 | monitoring = false; | 1575 | monitoring = false; |
1576 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1576 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
1577 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") | 1577 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") |
1578 | + errorMsg + "\n" + currentFile); | 1578 | + errorMsg + "\n" + currentFile); |
1579 | return false; | 1579 | return false; |
1580 | } else { | 1580 | } else { |
1581 | 1581 | ||
1582 | filePara.numberSamples = wavFile->getNumberSamples(); | 1582 | filePara.numberSamples = wavFile->getNumberSamples(); |
1583 | filePara.format = wavFile->getFormat(); | 1583 | filePara.format = wavFile->getFormat(); |
1584 | filePara.sampleRate = wavFile->getSampleRate(); | 1584 | filePara.sampleRate = wavFile->getSampleRate(); |
1585 | filePara.resolution = wavFile->getResolution(); | 1585 | filePara.resolution = wavFile->getResolution(); |
1586 | filePara.channels = wavFile->getChannels(); | 1586 | filePara.channels = wavFile->getChannels(); |
1587 | timeSlider->setPageStep(1); | 1587 | timeSlider->setPageStep(1); |
1588 | monitoring = true; | 1588 | monitoring = true; |
1589 | 1589 | ||
1590 | qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); | 1590 | qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); |
1591 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); | 1591 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); |
1592 | 1592 | ||
1593 | qWarning("seconds %d", sec); | 1593 | qWarning("seconds %d", sec); |
1594 | 1594 | ||
1595 | timeSlider->setRange(0, filePara.numberSamples ); | 1595 | timeSlider->setRange(0, filePara.numberSamples ); |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | return true; | 1598 | return true; |
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { | 1601 | void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { |
1602 | if(item == NULL ) | 1602 | if(item == NULL ) |
1603 | return; | 1603 | return; |
1604 | switch (mouse) { | 1604 | switch (mouse) { |
1605 | case 1: { | 1605 | case 1: { |
1606 | if( renameBox != 0 ) //tricky | 1606 | if( renameBox != 0 ) //tricky |
1607 | cancelRename(); | 1607 | cancelRename(); |
1608 | 1608 | ||
1609 | currentFile = item->text(0); | 1609 | currentFile = item->text(0); |
1610 | setCaption( "OpieRecord " + currentFile); | 1610 | setCaption( "OpieRecord " + currentFile); |
1611 | } | 1611 | } |
1612 | break; | 1612 | break; |
1613 | case 2: | 1613 | case 2: |
1614 | showListMenu(item); | 1614 | showListMenu(item); |
1615 | ListView1->clearSelection(); | 1615 | ListView1->clearSelection(); |
1616 | break; | 1616 | break; |
1617 | }; | 1617 | }; |
1618 | } | 1618 | } |
1619 | 1619 | ||
1620 | void QtRec::showListMenu(QListViewItem * item) { | 1620 | void QtRec::showListMenu(QListViewItem * item) { |
1621 | if(item == NULL) | 1621 | if(item == NULL) |
1622 | return; | 1622 | return; |
1623 | QPopupMenu *m = new QPopupMenu(this); | 1623 | QPopupMenu *m = new QPopupMenu(this); |
1624 | m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); | 1624 | m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); |
1625 | if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); | 1625 | if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); |
1626 | m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); | 1626 | m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); |
1627 | // #if defined (QTOPIA_INTERNAL_FSLP) | 1627 | // #if defined (QTOPIA_INTERNAL_FSLP) |
1628 | // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 1628 | // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1629 | // #endif | 1629 | // #endif |
1630 | m->insertSeparator(); | 1630 | m->insertSeparator(); |
1631 | m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); | 1631 | m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); |
1632 | m->exec( QCursor::pos() ); | 1632 | m->exec( QCursor::pos() ); |
1633 | qApp->processEvents(); | 1633 | qApp->processEvents(); |
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | void QtRec::fileBeamFinished( Ir *ir) { | 1636 | void QtRec::fileBeamFinished( Ir *ir) { |
1637 | if(ir) | 1637 | if(ir) |
1638 | QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); | 1638 | QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1639 | 1639 | ||
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | void QtRec::doBeam() { | 1642 | void QtRec::doBeam() { |
1643 | qApp->processEvents(); | 1643 | qApp->processEvents(); |
1644 | if( ListView1->currentItem() == NULL) | 1644 | if( ListView1->currentItem() == NULL) |
1645 | return; | 1645 | return; |
1646 | Ir ir; | 1646 | Ir ir; |
1647 | if( ir.supported()) { | 1647 | if( ir.supported()) { |
1648 | QString file = ListView1->currentItem()->text(0); | 1648 | QString file = ListView1->currentItem()->text(0); |
1649 | Config cfg("OpieRec"); | 1649 | Config cfg("OpieRec"); |
1650 | cfg.setGroup("Sounds"); | 1650 | cfg.setGroup("Sounds"); |
1651 | 1651 | ||
1652 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1652 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
1653 | 1653 | ||
1654 | for(int i=0;i<nFiles+1;i++) { | 1654 | for(int i=0;i<nFiles+1;i++) { |
1655 | if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { | 1655 | if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { |
1656 | QString filePath = cfg.readEntry(file,""); | 1656 | QString filePath = cfg.readEntry(file,""); |
1657 | Ir *file = new Ir(this, "IR"); | 1657 | Ir *file = new Ir(this, "IR"); |
1658 | connect( file, SIGNAL( done(Ir*)), | 1658 | connect( file, SIGNAL( done(Ir*)), |
1659 | this, SLOT( fileBeamFinished( Ir * ))); | 1659 | this, SLOT( fileBeamFinished(Ir*))); |
1660 | file->send( filePath, "OPieRec audio file\n" + filePath ); | 1660 | file->send( filePath, "OPieRec audio file\n" + filePath ); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | } | 1664 | } |
1665 | 1665 | ||
1666 | void QtRec::doMenuPlay() { | 1666 | void QtRec::doMenuPlay() { |
1667 | qApp->processEvents(); | 1667 | qApp->processEvents(); |
1668 | currentFile = ListView1->currentItem()->text(0); | 1668 | currentFile = ListView1->currentItem()->text(0); |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | void QtRec::doRename() { | 1671 | void QtRec::doRename() { |
1672 | QRect r = ListView1->itemRect( ListView1->currentItem( )); | 1672 | QRect r = ListView1->itemRect( ListView1->currentItem( )); |
1673 | r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); | 1673 | r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); |
1674 | r.setX( ListView1->contentsX() ); | 1674 | r.setX( ListView1->contentsX() ); |
1675 | if ( r.width() > ListView1->visibleWidth() ) | 1675 | if ( r.width() > ListView1->visibleWidth() ) |
1676 | r.setWidth( ListView1->visibleWidth() ); | 1676 | r.setWidth( ListView1->visibleWidth() ); |
1677 | 1677 | ||
1678 | renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); | 1678 | renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); |
1679 | renameBox->setFrame(true); | 1679 | renameBox->setFrame(true); |
1680 | 1680 | ||
1681 | renameBox->setText( ListView1->currentItem()->text(0) ); | 1681 | renameBox->setText( ListView1->currentItem()->text(0) ); |
1682 | 1682 | ||
1683 | renameBox->selectAll(); | 1683 | renameBox->selectAll(); |
1684 | renameBox->installEventFilter( this ); | 1684 | renameBox->installEventFilter( this ); |
1685 | ListView1->addChild( renameBox, r.x(), r.y() ); | 1685 | ListView1->addChild( renameBox, r.x(), r.y() ); |
1686 | renameBox->resize( r.size() ); | 1686 | renameBox->resize( r.size() ); |
1687 | ListView1->viewport()->setFocusProxy( renameBox ); | 1687 | ListView1->viewport()->setFocusProxy( renameBox ); |
1688 | renameBox->setFocus(); | 1688 | renameBox->setFocus(); |
1689 | renameBox->show(); | 1689 | renameBox->show(); |
1690 | 1690 | ||
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | void QtRec::okRename() { | 1693 | void QtRec::okRename() { |
1694 | qDebug(renameBox->text()); | 1694 | qDebug(renameBox->text()); |
1695 | QString filename = renameBox->text(); | 1695 | QString filename = renameBox->text(); |
1696 | cancelRename(); | 1696 | cancelRename(); |
1697 | 1697 | ||
1698 | if( ListView1->currentItem() == NULL) | 1698 | if( ListView1->currentItem() == NULL) |
1699 | return; | 1699 | return; |
1700 | 1700 | ||
1701 | Config cfg("OpieRec"); | 1701 | Config cfg("OpieRec"); |
1702 | cfg.setGroup("Sounds"); | 1702 | cfg.setGroup("Sounds"); |
1703 | 1703 | ||
1704 | QString file = ListView1->currentItem()->text(0); | 1704 | QString file = ListView1->currentItem()->text(0); |
1705 | 1705 | ||
1706 | qDebug("filename is " + filename); | 1706 | qDebug("filename is " + filename); |
1707 | 1707 | ||
1708 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1708 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
1709 | 1709 | ||
1710 | for(int i=0;i<nFiles+1;i++) { //look for file | 1710 | for(int i=0;i<nFiles+1;i++) { //look for file |
1711 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { | 1711 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { |
1712 | 1712 | ||
1713 | QString filePath = cfg.readEntry(file,""); | 1713 | QString filePath = cfg.readEntry(file,""); |
1714 | 1714 | ||
1715 | cfg.writeEntry( QString::number(i), filename ); | 1715 | cfg.writeEntry( QString::number(i), filename ); |
1716 | cfg.writeEntry( filename, filePath ); | 1716 | cfg.writeEntry( filename, filePath ); |
1717 | cfg.removeEntry( file); | 1717 | cfg.removeEntry( file); |
1718 | cfg.write(); | 1718 | cfg.write(); |
1719 | } | 1719 | } |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | ListView1->takeItem( ListView1->currentItem() ); | 1722 | ListView1->takeItem( ListView1->currentItem() ); |
1723 | delete ListView1->currentItem(); | 1723 | delete ListView1->currentItem(); |
1724 | ListView1->clear(); | 1724 | ListView1->clear(); |
1725 | initIconView(); | 1725 | initIconView(); |
1726 | update(); | 1726 | update(); |
1727 | } | 1727 | } |
1728 | 1728 | ||
1729 | void QtRec::cancelRename() { | 1729 | void QtRec::cancelRename() { |
1730 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; | 1730 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; |
1731 | delete renameBox; | 1731 | delete renameBox; |
1732 | renameBox = 0; | 1732 | renameBox = 0; |
1733 | if ( resetFocus ) { | 1733 | if ( resetFocus ) { |
1734 | ListView1->viewport()->setFocusProxy( ListView1 ); | 1734 | ListView1->viewport()->setFocusProxy( ListView1 ); |
1735 | ListView1->setFocus(); | 1735 | ListView1->setFocus(); |
1736 | } | 1736 | } |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | bool QtRec::eventFilter( QObject * o, QEvent * e ) { | 1739 | bool QtRec::eventFilter( QObject * o, QEvent * e ) { |
1740 | if ( o->inherits( "QLineEdit" ) ) { | 1740 | if ( o->inherits( "QLineEdit" ) ) { |
1741 | if ( e->type() == QEvent::KeyPress ) { | 1741 | if ( e->type() == QEvent::KeyPress ) { |
1742 | QKeyEvent *ke = (QKeyEvent*)e; | 1742 | QKeyEvent *ke = (QKeyEvent*)e; |
1743 | if ( ke->key() == Key_Return || | 1743 | if ( ke->key() == Key_Return || |
1744 | ke->key() == Key_Enter ) { | 1744 | ke->key() == Key_Enter ) { |
1745 | okRename(); | 1745 | okRename(); |
1746 | return true; | 1746 | return true; |
1747 | } else if ( ke->key() == Key_Escape ) { | 1747 | } else if ( ke->key() == Key_Escape ) { |
1748 | cancelRename(); | 1748 | cancelRename(); |
1749 | return true; | 1749 | return true; |
1750 | } | 1750 | } |
1751 | } else if ( e->type() == QEvent::FocusOut ) { | 1751 | } else if ( e->type() == QEvent::FocusOut ) { |
1752 | cancelRename(); | 1752 | cancelRename(); |
1753 | return true; | 1753 | return true; |
1754 | } | 1754 | } |
1755 | } | 1755 | } |
1756 | return QWidget::eventFilter( o, e ); | 1756 | return QWidget::eventFilter( o, e ); |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | 1759 | ||
1760 | int QtRec::getCurrentSizeLimit() { | 1760 | int QtRec::getCurrentSizeLimit() { |
1761 | return sizeLimitCombo->currentItem() * 5; | 1761 | return sizeLimitCombo->currentItem() * 5; |
1762 | } | 1762 | } |
1763 | 1763 | ||
1764 | void QtRec::timerBreak() { | 1764 | void QtRec::timerBreak() { |
1765 | endPlaying(); | 1765 | endPlaying(); |
1766 | } | 1766 | } |
1767 | 1767 | ||
1768 | void QtRec::doVolMuting(bool b) { | 1768 | void QtRec::doVolMuting(bool b) { |
1769 | Config cfg( "qpe" ); | 1769 | Config cfg( "qpe" ); |
1770 | cfg. setGroup( "Volume" ); | 1770 | cfg. setGroup( "Volume" ); |
1771 | cfg.writeEntry( "Mute",b); | 1771 | cfg.writeEntry( "Mute",b); |
1772 | cfg.write(); | 1772 | cfg.write(); |
1773 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; | 1773 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; |
1774 | } | 1774 | } |
1775 | 1775 | ||
1776 | void QtRec::doMicMuting(bool b) { | 1776 | void QtRec::doMicMuting(bool b) { |
1777 | // qDebug("mic mute"); | 1777 | // qDebug("mic mute"); |
1778 | Config cfg( "qpe" ); | 1778 | Config cfg( "qpe" ); |
1779 | cfg. setGroup( "Volume" ); | 1779 | cfg. setGroup( "Volume" ); |
1780 | cfg.writeEntry( "MicMute",b); | 1780 | cfg.writeEntry( "MicMute",b); |
1781 | cfg.write(); | 1781 | cfg.write(); |
1782 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; | 1782 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | void QtRec::compressionSelected(bool b) { | 1785 | void QtRec::compressionSelected(bool b) { |
1786 | Config cfg("OpieRec"); | 1786 | Config cfg("OpieRec"); |
1787 | cfg.setGroup("Settings"); | 1787 | cfg.setGroup("Settings"); |
1788 | cfg.writeEntry("wavCompression", b); | 1788 | cfg.writeEntry("wavCompression", b); |
1789 | cfg.writeEntry("bitrate", 16); | 1789 | cfg.writeEntry("bitrate", 16); |
1790 | filePara.resolution = 16; | 1790 | filePara.resolution = 16; |
1791 | cfg.write(); | 1791 | cfg.write(); |
1792 | 1792 | ||
1793 | if(b) { | 1793 | if(b) { |
1794 | bitRateComboBox->setEnabled( false); | 1794 | bitRateComboBox->setEnabled( false); |
1795 | bitRateComboBox->setCurrentItem( 0); | 1795 | bitRateComboBox->setCurrentItem( 0); |
1796 | filePara.resolution = 16; | 1796 | filePara.resolution = 16; |
1797 | } else{ | 1797 | } else{ |
1798 | bitRateComboBox->setEnabled( true); | 1798 | bitRateComboBox->setEnabled( true); |
1799 | } | 1799 | } |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | long QtRec::checkDiskSpace(const QString &path) { | 1802 | long QtRec::checkDiskSpace(const QString &path) { |
1803 | 1803 | ||
1804 | struct statfs fs; | 1804 | struct statfs fs; |
1805 | 1805 | ||
1806 | if ( !statfs( path.latin1(), &fs ) ) { | 1806 | if ( !statfs( path.latin1(), &fs ) ) { |
1807 | 1807 | ||
1808 | int blkSize = fs.f_bsize; | 1808 | int blkSize = fs.f_bsize; |
1809 | int availBlks = fs.f_bavail; | 1809 | int availBlks = fs.f_bavail; |
1810 | 1810 | ||
1811 | long mult = blkSize / 1024; | 1811 | long mult = blkSize / 1024; |
1812 | long div = 1024 / blkSize; | 1812 | long div = 1024 / blkSize; |
1813 | 1813 | ||
1814 | if ( !mult ) mult = 1; | 1814 | if ( !mult ) mult = 1; |
1815 | if ( !div ) div = 1; | 1815 | if ( !div ) div = 1; |
1816 | 1816 | ||
1817 | return availBlks * mult / div; | 1817 | return availBlks * mult / div; |
1818 | } | 1818 | } |
1819 | return -1; | 1819 | return -1; |
1820 | } | 1820 | } |
1821 | 1821 | ||
1822 | // short f_fstyp; /* File system type */ | 1822 | // short f_fstyp; /* File system type */ |
1823 | // long f_bsize; /* Block size */ | 1823 | // long f_bsize; /* Block size */ |
1824 | // long f_frsize; /* Fragment size */ | 1824 | // long f_frsize; /* Fragment size */ |
1825 | // long f_blocks; /* Total number of blocks*/ | 1825 | // long f_blocks; /* Total number of blocks*/ |
1826 | // long f_bfree; /* Count of free blocks */ | 1826 | // long f_bfree; /* Count of free blocks */ |
1827 | // long f_files; /* Total number of file nodes */ | 1827 | // long f_files; /* Total number of file nodes */ |
1828 | // long f_ffree; /* Count of free file nodes */ | 1828 | // long f_ffree; /* Count of free file nodes */ |
1829 | // char f_fname[6]; /* Volumename */ | 1829 | // char f_fname[6]; /* Volumename */ |
1830 | // char f_fpack[6]; /* Pack name */ | 1830 | // char f_fpack[6]; /* Pack name */ |
1831 | 1831 | ||
1832 | void QtRec::receive( const QCString &msg, const QByteArray & ) { | 1832 | void QtRec::receive( const QCString &msg, const QByteArray & ) { |
1833 | qDebug("Voicerecord received message "+msg); | 1833 | qDebug("Voicerecord received message "+msg); |
1834 | 1834 | ||
1835 | } | 1835 | } |
1836 | 1836 | ||
1837 | 1837 | ||
1838 | ///////////////////////////// timerEvent | 1838 | ///////////////////////////// timerEvent |
1839 | void QtRec::timerEvent( QTimerEvent * ) { | 1839 | void QtRec::timerEvent( QTimerEvent * ) { |
1840 | 1840 | ||
1841 | // if(!recording) | 1841 | // if(!recording) |
1842 | // timeSlider->setValue( secCount); | 1842 | // timeSlider->setValue( secCount); |
1843 | // else | 1843 | // else |
1844 | // timeSlider->setValue( filePara.numberOfRecordedSeconds); | 1844 | // timeSlider->setValue( filePara.numberOfRecordedSeconds); |
1845 | 1845 | ||
1846 | if( stopped && playing) { | 1846 | if( stopped && playing) { |
1847 | stop(); | 1847 | stop(); |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | if( stopped && recording ){ | 1850 | if( stopped && recording ){ |
1851 | stop(); | 1851 | stop(); |