author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/multimedia/opierec/qtrec.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/multimedia/opierec/qtrec.cpp') (more/less context) (ignore whitespace changes)
-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 | |||
@@ -668,226 +668,226 @@ void QtRec::init() { | |||
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; |
@@ -1563,193 +1563,193 @@ bool QtRec::openPlayFile() { | |||
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 | } |