From b0e912c8b3d02a518fedda28c3180eb4794a7520 Mon Sep 17 00:00:00 2001 From: tpearson Date: Fri, 27 May 2011 23:37:00 +0000 Subject: TQt4 convert k9copy This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k9copy@1233843 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- libk9copy/k9mp4enc.cpp | 188 ++++++++++++++++++++++++------------------------- 1 file changed, 94 insertions(+), 94 deletions(-) (limited to 'libk9copy/k9mp4enc.cpp') diff --git a/libk9copy/k9mp4enc.cpp b/libk9copy/k9mp4enc.cpp index 7d82c4f..5d8c51c 100644 --- a/libk9copy/k9mp4enc.cpp +++ b/libk9copy/k9mp4enc.cpp @@ -12,23 +12,23 @@ #include "k9mp4enc.h" #include "k9mp4dlg.h" #include "k9config.h" -#include -#include +#include +#include #include -#include -#include +#include +#include #include #include -#include +#include #include #include #include "k9tools.h" #include "k9audiocodecs.h" #include "k9videocodecs.h" -#include +#include -k9MP4Enc::k9MP4Enc ( QObject *parent, const char *name,const QStringList& ) - : QObject ( parent, name ) +k9MP4Enc::k9MP4Enc ( TQObject *tqparent, const char *name,const TQStringList& ) + : TQObject ( tqparent, name ) { m_fourcc=m_height=m_width=m_audioBitrate=m_videoBitrate=m_filename=""; m_codec=0; //lavc_mp4; @@ -36,27 +36,27 @@ k9MP4Enc::k9MP4Enc ( QObject *parent, const char *name,const QStringList& ) m_cpt=-1; m_parts=1; - QStringList laudio; - QStringList llabels; - QStringList lvideo; + TQStringList laudio; + TQStringList llabels; + TQStringList lvideo; k9Config config; m_lstAudio=config.getCodecAudio(); m_lstCodecs=config.getCodecLabels(); m_lstVideo=config.getCodecVideo(); - timer = new QTimer ( this ); - connect ( timer, SIGNAL ( timeout() ), this, SLOT ( timerDone() ) ); - m_progress=new k9MP4Dlg ( qApp->mainWidget(),0 ); + timer = new TQTimer ( this ); + connect ( timer, TQT_SIGNAL ( timeout() ), this, TQT_SLOT ( timerDone() ) ); + m_progress=new k9MP4Dlg ( tqApp->mainWidget(),0 ); } -QString k9MP4Enc::round16 ( QString _wh ) +TQString k9MP4Enc::round16 ( TQString _wh ) { if ( _wh !="" ) { int value=_wh.toInt() /16; - return QString::number ( value*16 ); + return TQString::number ( value*16 ); } else @@ -65,18 +65,18 @@ QString k9MP4Enc::round16 ( QString _wh ) } -QString k9MP4Enc::getChapterList ( k9DVDTitle *_title ) +TQString k9MP4Enc::getChapterList ( k9DVDTitle *_title ) { - QString res=""; - QPtrList chapters=_title->getChapters(); + TQString res=""; + TQPtrList chapters=_title->getChapters(); for ( k9DVDChapter *chapter=chapters.first();chapter;chapter=chapters.next() ) { if ( chapter->getSelected() ) { - res+=res=="" ? QString::number ( chapter->getnum() ) : ","+QString::number ( chapter->getnum() ); + res+=res=="" ? TQString::number ( chapter->getnum() ) : ","+TQString::number ( chapter->getnum() ); } } - QPtrList titles=_title->getTitles(); + TQPtrList titles=_title->getTitles(); for ( k9DVDTitle *title=titles.first();title;title=titles.next() ) { @@ -85,7 +85,7 @@ QString k9MP4Enc::getChapterList ( k9DVDTitle *_title ) { if ( chapter->getSelected() ) { - res+=res=="" ? QString::number ( chapter->getnum() ) : ","+QString::number ( chapter->getnum() ); + res+=res=="" ? TQString::number ( chapter->getnum() ) : ","+TQString::number ( chapter->getnum() ); } } } @@ -121,18 +121,18 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) if ( ! k9Tools::checkProgram ( "mencoder" ) && ! m_mpeg2 ) { - KMessageBox::error ( qApp->mainWidget(),i18n ( "Unable to run %1" ).arg ( "mencoder" ) , i18n ( "Encoding error" ) ); + KMessageBox::error ( tqApp->mainWidget(),i18n ( "Unable to run %1" ).arg ( "mencoder" ) , i18n ( "Encoding error" ) ); error = TRUE; return; } - time = new QTime ( 0,0 ); + time = new TQTime ( 0,0 ); m_percent=0; m_remain="--:--:--"; m_totalSize=_title->getChaptersSize ( true ); - QString injectName; + TQString injectName; KTempFile injectFile ( locateLocal ( "tmp", "k9copy/k9v" ), "" ); injectFile.setAutoDelete ( true ); injectFile.close(); @@ -143,17 +143,17 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) int pass=0; //build the cell list for mpeg2 extraction - QMap chapterCells; - QMap::iterator ichapterCells; - QStringList chapters; + TQMap chapterCells; + TQMap::iterator ichapterCells; + TQStringList chapters; if ( m_mpeg2 && m_mpegChapters ) { m_parts=0; - chapters=QStringList::split ( ",", getChapterList ( _title ) ); + chapters=TQStringList::split ( ",", getChapterList ( _title ) ); for ( unsigned int idxChap = 0; idxChap < chapters.size(); idxChap++ ) { - QString chapter = chapters[idxChap]; - //foreach (QString chapter,chapters) { + TQString chapter = chapters[idxChap]; + //foreach (TQString chapter,chapters) { int iCell=0; k9DVDChapter *chap=_title->getChapter ( chapter.toInt()-1 ); //foreach(k9ChapterCell *cell ,chap->cells) { @@ -196,31 +196,31 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) if ( m_size=="" ) m_size="700"; if ( m_filename=="" ) - m_filename=KFileDialog::getSaveFileName ( QDir::homeDirPath(),"*.avi", 0,i18n ( "Save file to disk" ) ); + m_filename=KFileDialog::getSaveFileName ( TQDir::homeDirPath(),"*.avi", 0,i18n ( "Save file to disk" ) ); if ( m_filename =="" ) return; - QDir d=QDir::root(); + TQDir d=TQDir::root(); if ( d.exists ( m_filename ) ) d.remove ( m_filename ); - m_progress->setbitrate ( QString::number ( getBitRate ( _title ) ) ); + m_progress->setbitrate ( TQString::number ( getBitRate ( _title ) ) ); if ( !m_mpeg2 ) - m_progress->setsize ( m_size +i18n ( "MB" ) +" X " +QString::number ( m_parts ) ); + m_progress->setsize ( m_size +i18n ( "MB" ) +" X " +TQString::number ( m_parts ) ); else m_progress->setsize ( m_size +i18n ( "MB" ) +" X " ); m_process=new k9Process ( this,0 ); m_process->setUseShell ( true ); - *m_process << "k9copy" << "--play" << "--endsector" << QString::number ( endSector ) ; + *m_process << "k9copy" << "--play" << "--endsector" << TQString::number ( endSector ) ; *m_process << "--inject" << injectName; //"/tmp/kde-jmp/inject"; *m_process << "--input" << "'"+m_device+"'"; - *m_process << "--dvdtitle" << QString::number ( _title->getnumTitle() ); + *m_process << "--dvdtitle" << TQString::number ( _title->getnumTitle() ); if ( m_mpegChapters && m_mpeg2 ) { *m_process << "--chapter" << ichapterCells.key();//chapters.at(m_part-1); - //*m_process << "--cell" << QString::number(ichapterCells.value()); + //*m_process << "--cell" << TQString::number(ichapterCells.value()); } else *m_process << "--chapterlist" << getChapterList ( _title ); @@ -237,7 +237,7 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) { if ( _title->getaudioStream ( i )->getselected() ) { - *m_process << "--audiofilter" << QString::number ( _title->getaudioStream ( i )->getID() ); + *m_process << "--audiofilter" << TQString::number ( _title->getaudioStream ( i )->getID() ); break; } } @@ -245,9 +245,9 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) if ( getselectedSubp ( _title ) !=-1 ) { *m_process << "--subpicturefilter" ; - QString s=""; + TQString s=""; for ( int i=1; i<=_title->getsubPictureCount();i++ ) - s+= ( i>1?",":"" ) + QString::number ( i ); + s+= ( i>1?",":"" ) + TQString::number ( i ); *m_process << s; } @@ -262,20 +262,20 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) if ( _title->getforceFactor() ) { size = _title->getChaptersSize_mb ( true ) /_title->getfactor(); - *m_process << "--vampsfactor" << QString::number ( _title->getfactor() ) << "--ffactor"; + *m_process << "--vampsfactor" << TQString::number ( _title->getfactor() ) << "--ffactor"; } else size = _title->getChaptersSize_mb ( true ); - m_progress->setsize ( QString::number ( size ) +i18n ( "MB" ) ); - QString path=m_filename; + m_progress->setsize ( TQString::number ( size ) +i18n ( "MB" ) ); + TQString path=m_filename; if ( m_parts>1 ) { - QString ext=m_filename.section ( ".",-1 ); + TQString ext=m_filename.section ( ".",-1 ); if ( ext!="" ) ext="."+ext; path=m_filename.left ( m_filename.length()-ext.length() ); - //path=QString("%1-chapter%2-cell%3%4").arg(path).arg(ichapterCells.key()).arg(ichapterCells.value()).arg(ext); - path=QString ( "%1-chapter%2%3" ).arg ( path ).arg ( ichapterCells.key() ).arg ( ext ); + //path=TQString("%1-chapter%2-cell%3%4").tqarg(path).tqarg(ichapterCells.key()).tqarg(ichapterCells.value()).tqarg(ext); + path=TQString ( "%1-chapter%2%3" ).arg ( path ).arg ( ichapterCells.key() ).arg ( ext ); ++ichapterCells; } *m_process << "> "+path; @@ -286,13 +286,13 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) *m_process << "-passlogfile" << passLogFile.name(); bool audio=false; - QString sPass=""; - QString sCodec=""; + TQString sPass=""; + TQString sCodec=""; k9AudioCodecs *audioCodecs=new k9AudioCodecs ( 0,0 ); k9VideoCodecs *videoCodecs=new k9VideoCodecs ( 0,0 ); - QString sVOption; + TQString sVOption; m_pass=pass; switch ( pass ) { @@ -310,15 +310,15 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) sVOption=sVOption.simplifyWhiteSpace(); int pos; //*m_process << "-ovc" << sVOption; - /* int pos=sVOption.find("-vf"); + /* int pos=sVOption.tqfind("-vf"); if (pos==-1) - *m_process <<"-vf" << QString("scale=%1:%2").arg(m_width).arg(m_height); + *m_process <<"-vf" << TQString("scale=%1:%2").tqarg(m_width).tqarg(m_height); else - sVOption=sVOption.insert(pos+4,QString("scale=%1:%2,").arg(m_width).arg(m_height)); + sVOption=sVOption.insert(pos+4,TQString("scale=%1:%2,").tqarg(m_width).tqarg(m_height)); */ *m_process << sVOption; - QString sAOption=replaceParams ( audioCodecs->getOptions ( m_audioCodec ) ).simplifyWhiteSpace(); + TQString sAOption=replaceParams ( audioCodecs->getOptions ( m_audioCodec ) ).simplifyWhiteSpace(); @@ -341,11 +341,11 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) if ( _title->getaudioStream ( i )->getselected() ) { //*m_process << "-oac" << sAOption; - pos=sAOption.find ( "-af" ); + pos=sAOption.tqfind ( "-af" ); if ( pos==-1 ) - *m_process << QString ( "-af volume=%1" ).arg ( m_audioGain ); + *m_process << TQString ( "-af volume=%1" ).arg ( m_audioGain ); else - sAOption=sAOption.insert ( pos+4,QString ( "volume=%1," ).arg ( m_audioGain ) ); + sAOption=sAOption.insert ( pos+4,TQString ( "volume=%1," ).arg ( m_audioGain ) ); *m_process << sAOption; audio=true; @@ -355,20 +355,20 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) if ( getselectedSubp ( _title ) !=-1 ) { - *m_process << "-sid" << QString::number ( getselectedSubp ( _title ) ); + *m_process << "-sid" << TQString::number ( getselectedSubp ( _title ) ); } if ( !audio ) *m_process << "-nosound"; - QString path=m_filename; + TQString path=m_filename; if ( m_parts>1 ) { - QString ext=m_filename.section ( ".",-1 ); + TQString ext=m_filename.section ( ".",-1 ); if ( ext!="" ) ext="."+ext; path=m_filename.left ( m_filename.length()-ext.length() ); - path=path+QString::number ( m_part ) +ext; + path=path+TQString::number ( m_part ) +ext; } if ( pass==1 ) *m_process << "-o" << "/dev/null"; @@ -386,19 +386,19 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) //*m_process << "-of" << "avi"; } - QString s=""; + TQString s=""; for ( uint i=0; i< m_process->args().count();i++ ) { - QCString str=* ( m_process->args().at ( i ) ); - s +=QString ( str ) +" "; + TQCString str=* ( m_process->args().at ( i ) ); + s +=TQString ( str ) +" "; } qDebug ( s ); time->start(); m_timer3.start(); - connect ( m_process, SIGNAL ( receivedStdout ( KProcess *, char *, int ) ),this, SLOT ( getStdout ( KProcess *, char *, int ) ) ); - connect ( m_process, SIGNAL ( receivedStderr ( KProcess *, char *, int ) ),this, SLOT ( getStderr ( KProcess *, char *, int ) ) ); - //connect(m_process, SIGNAL(processExited(KProcess*)),this,SLOT(exited(KProcess*))); - connect ( m_progress,SIGNAL ( sigCancel() ),this,SLOT ( slotCancel() ) ); + connect ( m_process, TQT_SIGNAL ( receivedStdout ( KProcess *, char *, int ) ),this, TQT_SLOT ( getStdout ( KProcess *, char *, int ) ) ); + connect ( m_process, TQT_SIGNAL ( receivedStderr ( KProcess *, char *, int ) ),this, TQT_SLOT ( getStderr ( KProcess *, char *, int ) ) ); + //connect(m_process, TQT_SIGNAL(processExited(KProcess*)),this,TQT_SLOT(exited(KProcess*))); + connect ( m_progress,TQT_SIGNAL ( sigCancel() ),this,TQT_SLOT ( slotCancel() ) ); m_canceled=false; m_progress->show(); m_process->start ( KProcess::OwnGroup, KProcess::All ); @@ -412,12 +412,12 @@ void k9MP4Enc::execute ( k9DVDTitle *_title ) } if ( m_canceled ) { - KMessageBox::information ( qApp->mainWidget(),i18n ( "MPEG-4 Encoding cancelled" ), i18n ( "MPEG-4 Encoding" ) ); + KMessageBox::information ( tqApp->mainWidget(),i18n ( "MPEG-4 Encoding cancelled" ), i18n ( "MPEG-4 Encoding" ) ); error=true; } else if ( !m_process->normalExit() ) { - KMessageBox::error ( qApp->mainWidget(),""+i18n ( "Error while running mencoder :" ) +"
"+m_stderr, i18n ( "Encoding error" ) ); + KMessageBox::error ( tqApp->mainWidget(),""+i18n ( "Error while running mencoder :" ) +"
"+m_stderr, i18n ( "Encoding error" ) ); error=true; } if ( maxPass >0 ) @@ -436,14 +436,14 @@ void k9MP4Enc::slotCancel() } -QString k9MP4Enc::replaceParams ( QString _value ) +TQString k9MP4Enc::replaceParams ( TQString _value ) { - QString str=_value; - str.replace ( "$PASS",QString::number ( m_pass ) ); - str.replace ( "$WIDTH",m_width ); - str.replace ( "$HEIGHT",m_height ); - str.replace ( "$VIDBR",QString::number ( getBitRate ( m_title ) ) ); - str.replace ( "$AUDBR",m_audioBitrate ); + TQString str=_value; + str.tqreplace ( "$PASS",TQString::number ( m_pass ) ); + str.tqreplace ( "$WIDTH",m_width ); + str.tqreplace ( "$HEIGHT",m_height ); + str.tqreplace ( "$VIDBR",TQString::number ( getBitRate ( m_title ) ) ); + str.tqreplace ( "$AUDBR",m_audioBitrate ); return str; } @@ -462,8 +462,8 @@ int k9MP4Enc::getBitRate ( k9DVDTitle *_title ) float titleSize=_title->getChaptersSize_mb ( true ); if ( titleSize< ( float ) size ) size= ( int ) ( titleSize/m_parts ) ; - m_progress->setsize ( QString::number ( size ) +i18n ( "MB" ) +" X " +QString::number ( m_parts ) ); - QTime t1 ( 0,0 ); + m_progress->setsize ( TQString::number ( size ) +i18n ( "MB" ) +" X " +TQString::number ( m_parts ) ); + TQTime t1 ( 0,0 ); int sec=t1.secsTo ( _title->getSelectedLength() ); //int bitrate=(int)( ((size*m_parts) * 8388.608)/sec - m_audioBitrate.toInt()); int bitrate=8* ( ( ( size*m_parts*1024 )- ( m_audioBitrate.toInt() *sec/8 ) ) /sec ); @@ -475,7 +475,7 @@ int k9MP4Enc::getBitRate ( k9DVDTitle *_title ) void k9MP4Enc::getStdout ( KProcess *, char *buffer, int buflen ) { - QCString tmp ( buffer,buflen ); + TQCString tmp ( buffer,buflen ); m_cpt++; if ( m_cpt==100 ) m_cpt=0; @@ -483,19 +483,19 @@ void k9MP4Enc::getStdout ( KProcess *, char *buffer, int buflen ) if ( m_cpt!=0 ) return; - int pos=tmp.find ( "Pos:" ); + int pos=tmp.tqfind ( "Pos:" ); if ( pos!=-1 ) { - QString tmp2=tmp.mid ( pos ); + TQString tmp2=tmp.mid ( pos ); float t; int frame; int fps; sscanf ( tmp2.latin1(),"Pos: %f%*s%d",&t,&frame ); - tmp2=tmp2.mid ( tmp2.find ( "(" ) +1 ); - tmp2=tmp2.mid ( tmp2.find ( ")" ) +1 ); + tmp2=tmp2.mid ( tmp2.tqfind ( "(" ) +1 ); + tmp2=tmp2.mid ( tmp2.tqfind ( ")" ) +1 ); sscanf ( tmp2.latin1(),"%d",&fps ); - m_progress->setfps ( QString::number ( fps ) ); + m_progress->setfps ( TQString::number ( fps ) ); } @@ -503,32 +503,32 @@ void k9MP4Enc::getStdout ( KProcess *, char *buffer, int buflen ) void k9MP4Enc::getStderr ( KProcess *proc, char *buffer, int buflen ) { - //m_stderr=QString::fromLatin1(buffer,buflen); - QCString cstderr ( buffer,buflen+1 ); + //m_stderr=TQString::tqfromLatin1(buffer,buflen); + TQCString cstderr ( buffer,buflen+1 ); - if ( cstderr.find ( "FATAL:" ) !=-1 ) + if ( cstderr.tqfind ( "FATAL:" ) !=-1 ) { proc->kill(); } - int pos=cstderr.find ( "INFOPOS:" ); + int pos=cstderr.tqfind ( "INFOPOS:" ); if ( pos!=-1 ) { if ( m_timer3.elapsed() >500 ) { m_timer3.restart(); - QString tmp=cstderr.mid ( pos ); + TQString tmp=cstderr.mid ( pos ); uint32_t totalBytes,totalSize; sscanf ( tmp.latin1(),"INFOPOS: %d %d",&totalBytes,&totalSize ); if ( totalSize !=0 ) m_percent= ( float ) totalBytes / ( float ) m_totalSize; - QTime time2 ( 0,0 ); + TQTime time2 ( 0,0 ); time2=time2.addMSecs ( time->elapsed() ); if ( m_percent>0 ) { - QTime time3 ( 0,0 ); + TQTime time3 ( 0,0 ); time3=time3.addMSecs ( ( uint32_t ) ( time->elapsed() * ( 1/m_percent ) ) ); m_remain=time3.toString ( "hh:mm:ss" ); } @@ -540,7 +540,7 @@ void k9MP4Enc::getStderr ( KProcess *proc, char *buffer, int buflen ) } else { - pos=cstderr.find ( "INFOIMAGE:" ); + pos=cstderr.tqfind ( "INFOIMAGE:" ); if ( pos!=-1 ) { m_progress->setImage ( cstderr.mid ( pos+10 ) ); @@ -553,7 +553,7 @@ void k9MP4Enc::getStderr ( KProcess *proc, char *buffer, int buflen ) void k9MP4Enc::timerDone() { - QTime time2 ( 0,0 ); + TQTime time2 ( 0,0 ); time2=time2.addMSecs ( time->elapsed() ); m_progress->setremain ( time2.toString ( "hh:mm:ss" ) +" / " +m_remain ); -- cgit v1.2.3