-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 115 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.h | 3 |
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 | |||
@@ -466,8 +466,6 @@ void QtRec::cleanUp() { | |||
466 | void QtRec::init() { | 466 | void 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; |
@@ -501,7 +499,7 @@ void QtRec::init() { | |||
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); |
@@ -537,7 +535,8 @@ void QtRec::init() { | |||
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); |
@@ -545,8 +544,10 @@ void QtRec::init() { | |||
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 | ||
@@ -702,15 +703,19 @@ void QtRec::initIconView() { | |||
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 | ||
716 | void QtRec::initConnections() { | 721 | void QtRec::initConnections() { |
@@ -786,7 +791,7 @@ void QtRec::initConfig() { | |||
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 { |
@@ -814,7 +819,6 @@ void QtRec::initConfig() { | |||
814 | 819 | ||
815 | void QtRec::stop() { | 820 | void 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(); |
@@ -824,6 +828,7 @@ void QtRec::stop() { | |||
824 | endRecording(); | 828 | endRecording(); |
825 | } | 829 | } |
826 | timeSlider->setValue(0); | 830 | timeSlider->setValue(0); |
831 | setButtons(); | ||
827 | } | 832 | } |
828 | 833 | ||
829 | void QtRec::doPlayBtn() { | 834 | void QtRec::doPlayBtn() { |
@@ -841,11 +846,9 @@ void QtRec::doPlayBtn() { | |||
841 | 846 | ||
842 | void QtRec::start() { //play | 847 | void 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()) |
@@ -865,7 +868,7 @@ bool QtRec::rec() { //record | |||
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()) { |
@@ -921,8 +924,7 @@ bool QtRec::rec() { //record | |||
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 |
@@ -1140,8 +1142,7 @@ bool QtRec::doPlay() { | |||
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 |
@@ -1205,9 +1206,8 @@ void QtRec::changeSizeLimitCombo(int) { | |||
1205 | } | 1206 | } |
1206 | 1207 | ||
1207 | void QtRec::newSound() { | 1208 | void QtRec::newSound() { |
1208 | if( !rec()) { | 1209 | if(!rec()) { |
1209 | endRecording(); | 1210 | stop(); |
1210 | deleteSound(); | ||
1211 | } | 1211 | } |
1212 | } | 1212 | } |
1213 | 1213 | ||
@@ -1221,6 +1221,8 @@ void QtRec::deleteSound() { | |||
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, ""); |
@@ -1254,6 +1256,7 @@ void QtRec::deleteSound() { | |||
1254 | initIconView(); | 1256 | initIconView(); |
1255 | update(); | 1257 | update(); |
1256 | setCaption( tr( "OpieRecord " )); | 1258 | setCaption( tr( "OpieRecord " )); |
1259 | } | ||
1257 | } | 1260 | } |
1258 | 1261 | ||
1259 | void QtRec::keyPressEvent( QKeyEvent *e) { | 1262 | void QtRec::keyPressEvent( QKeyEvent *e) { |
@@ -1376,10 +1379,8 @@ void QtRec::endRecording() { | |||
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 | ||
@@ -1442,10 +1443,7 @@ void QtRec::endPlaying() { | |||
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); |
@@ -1531,6 +1529,7 @@ void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { | |||
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; |
@@ -1590,6 +1589,7 @@ void QtRec::doBeam() { | |||
1590 | void QtRec::doMenuPlay() { | 1589 | void 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 | ||
1595 | void QtRec::doRename() { | 1595 | void QtRec::doRename() { |
@@ -1627,6 +1627,9 @@ void QtRec::okRename() { | |||
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); |
@@ -1938,29 +1941,6 @@ QString QtRec::getStorage(const QString &fileName) { | |||
1938 | // endmntent( mntfp ); | 1941 | // endmntent( mntfp ); |
1939 | } | 1942 | } |
1940 | 1943 | ||
1941 | void 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 | |||
1964 | void QtRec::fillDirectoryCombo() { | 1944 | void QtRec::fillDirectoryCombo() { |
1965 | if( directoryComboBox->count() > 0) | 1945 | if( directoryComboBox->count() > 0) |
1966 | directoryComboBox->clear(); | 1946 | directoryComboBox->clear(); |
@@ -2050,4 +2030,39 @@ void QtRec::changeStereoCheck(bool b) { | |||
2050 | cfg.write(); | 2030 | cfg.write(); |
2051 | } | 2031 | } |
2052 | 2032 | ||
2053 | 2033 | void 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 | |||
2061 | void 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 | |||
@@ -98,10 +98,11 @@ private: | |||
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 | ||
106 | private slots: | 107 | private slots: |
107 | void endPlaying(); | 108 | void endPlaying(); |