rbutil: improve talkfile generation. remove the options to keep and overwrite the wavfiles.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17637 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Wenger 2008-05-27 20:02:25 +00:00
parent 819a39a22e
commit ae4b677736
5 changed files with 47 additions and 55 deletions

View file

@ -182,7 +182,7 @@ bool EncRbSpeex::start()
bool EncRbSpeex::encode(QString input,QString output) bool EncRbSpeex::encode(QString input,QString output)
{ {
//qDebug() << "encoding qDebug() << "encoding " << input << " to "<< output;
char errstr[512]; char errstr[512];
FILE *fin,*fout; FILE *fin,*fout;

View file

@ -15,7 +15,7 @@
<property name="windowTitle" > <property name="windowTitle" >
<string>Install Talk Files</string> <string>Install Talk Files</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" name="gridLayout_2" >
<item rowspan="6" row="0" column="0" > <item rowspan="6" row="0" column="0" >
<widget class="QLabel" name="label" > <widget class="QLabel" name="label" >
<property name="text" > <property name="text" >
@ -45,7 +45,8 @@
<string>&amp;Browse</string> <string>&amp;Browse</string>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset resource="rbutilqt.qrc" >:/icons/system-search.png</iconset> <iconset resource="rbutilqt.qrc" >
<normaloff>:/icons/system-search.png</normaloff>:/icons/system-search.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -87,7 +88,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -103,28 +104,8 @@
<property name="title" > <property name="title" >
<string>Generation options</string> <string>Generation options</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" name="gridLayout" >
<item row="2" column="0" > <item row="2" column="0" colspan="2" >
<widget class="QCheckBox" name="OverwriteWav" >
<property name="text" >
<string>Overwrite Wavefiles</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="RemoveWav" >
<property name="text" >
<string>Remove Wavefiles</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QCheckBox" name="recursive" > <widget class="QCheckBox" name="recursive" >
<property name="text" > <property name="text" >
<string>Run recursive</string> <string>Run recursive</string>
@ -134,7 +115,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" > <item row="3" column="0" colspan="2" >
<widget class="QCheckBox" name="StripExtensions" > <widget class="QCheckBox" name="StripExtensions" >
<property name="text" > <property name="text" >
<string>Strip Extensions</string> <string>Strip Extensions</string>
@ -144,7 +125,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" > <item row="4" column="0" colspan="2" >
<widget class="QCheckBox" name="OverwriteTalk" > <widget class="QCheckBox" name="OverwriteTalk" >
<property name="text" > <property name="text" >
<string>Overwrite Talkfiles</string> <string>Overwrite Talkfiles</string>
@ -154,7 +135,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0" colspan="2" >
<widget class="QCheckBox" name="talkFolders" > <widget class="QCheckBox" name="talkFolders" >
<property name="text" > <property name="text" >
<string>Generate .talk files for Folders</string> <string>Generate .talk files for Folders</string>
@ -164,7 +145,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" > <item row="0" column="0" colspan="2" >
<widget class="QCheckBox" name="talkFiles" > <widget class="QCheckBox" name="talkFiles" >
<property name="text" > <property name="text" >
<string>Generate .talk files for Files</string> <string>Generate .talk files for Files</string>
@ -178,6 +159,13 @@
</widget> </widget>
</item> </item>
</layout> </layout>
<zorder>recursive</zorder>
<zorder>StripExtensions</zorder>
<zorder>OverwriteTalk</zorder>
<zorder>talkFolders</zorder>
<zorder>talkFiles</zorder>
<zorder>label_3</zorder>
<zorder>fileFilter</zorder>
</widget> </widget>
</item> </item>
<item row="4" column="2" > <item row="4" column="2" >
@ -185,7 +173,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -198,7 +186,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -214,7 +202,8 @@
<string>&amp;Install</string> <string>&amp;Install</string>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset> <iconset resource="rbutilqt.qrc" >
<normaloff>:/icons/go-next.png</normaloff>:/icons/go-next.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -224,7 +213,8 @@
<string>&amp;Cancel</string> <string>&amp;Cancel</string>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset> <iconset resource="rbutilqt.qrc" >
<normaloff>:/icons/process-stop.png</normaloff>:/icons/process-stop.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -238,8 +228,6 @@
<tabstop>change</tabstop> <tabstop>change</tabstop>
<tabstop>talkFiles</tabstop> <tabstop>talkFiles</tabstop>
<tabstop>talkFolders</tabstop> <tabstop>talkFolders</tabstop>
<tabstop>OverwriteWav</tabstop>
<tabstop>RemoveWav</tabstop>
<tabstop>recursive</tabstop> <tabstop>recursive</tabstop>
<tabstop>StripExtensions</tabstop> <tabstop>StripExtensions</tabstop>
<tabstop>OverwriteTalk</tabstop> <tabstop>OverwriteTalk</tabstop>

View file

@ -31,8 +31,6 @@ InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder())); connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
connect(ui.change,SIGNAL(clicked()),this,SLOT(change())); connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
ui.OverwriteWav->setChecked(true);
ui.RemoveWav->setChecked(true);
ui.recursive->setChecked(true); ui.recursive->setChecked(true);
ui.OverwriteTalk->setChecked(true); ui.OverwriteTalk->setChecked(true);
ui.StripExtensions->setChecked(true); ui.StripExtensions->setChecked(true);
@ -99,8 +97,8 @@ void InstallTalkWindow::accept()
talkcreator->setMountPoint(settings->mountpoint()); talkcreator->setMountPoint(settings->mountpoint());
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked()); talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked()); talkcreator->setOverwriteWav(true);
talkcreator->setRemoveWav(ui.RemoveWav->isChecked()); talkcreator->setRemoveWav(true);
talkcreator->setRecursive(ui.recursive->isChecked()); talkcreator->setRecursive(ui.recursive->isChecked());
talkcreator->setStripExtensions(ui.StripExtensions->isChecked()); talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
talkcreator->setTalkFolders(ui.talkFolders->isChecked()); talkcreator->setTalkFolders(ui.talkFolders->isChecked());

View file

@ -172,7 +172,7 @@ void RbUtilQt::downloadDone(bool error)
QMessageBox::critical(this, tr("Configuration error"), QMessageBox::critical(this, tr("Configuration error"),
tr("Your configuration is invalid. This is most likely due " tr("Your configuration is invalid. This is most likely due "
"to a new installation of Rockbox Utility or a changed device " "to a new installation of Rockbox Utility or a changed device "
"path. The configuation dialog will now open to allow you " "path. The configuration dialog will now open to allow you "
"correcting the problem.")); "correcting the problem."));
configDialog(); configDialog();
} }

View file

@ -83,11 +83,12 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
QString toSpeak; QString toSpeak;
QString filename; QString filename;
QString wavfilename; QString wavfilename;
QString filepath;
QString path = fileInf.filePath(); QString path = fileInf.filePath();
qDebug() << path; qDebug() << path;
if( path.endsWith("..") || path.endsWith(".talk") ) if( path.endsWith("..") || path.endsWith(".") || path.endsWith(".talk") )
{ {
it.next(); it.next();
continue; continue;
@ -102,13 +103,12 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
it.next(); it.next();
continue; continue;
} }
int index1 = path.lastIndexOf("/");
int index2 = path.lastIndexOf("/",index1-1);
toSpeak = path.mid(index2+1,(index1-index2)-1); toSpeak = fileInf.fileName();
filename = path.left(index1) + "/_dirname.talk"; filepath = fileInf.filePath() + "/";
qDebug() << "toSpeak: " << toSpeak << "filename: " << filename; filename = "_dirname.talk";
qDebug() << "toSpeak: " << toSpeak << "filename: " << filename << " path: " <<filepath;
} }
else // if it is a file else // if it is a file
{ {
@ -118,15 +118,21 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
it.next(); it.next();
continue; continue;
} }
// create toSpeak string
if(m_stripExtensions) if(m_stripExtensions)
toSpeak = fileInf.baseName(); toSpeak = fileInf.baseName();
else else
toSpeak = fileInf.fileName(); toSpeak = fileInf.fileName();
filename = fileInf.absoluteFilePath() + ".talk"; // create filename and path
} filepath = fileInf.absolutePath();
wavfilename = filename + ".wav"; filename = fileInf.fileName() + ".talk";
QFileInfo filenameInf(filename); }
wavfilename = QDir::tempPath()+ "/"+ filename + ".wav";
QFileInfo filenameInf(filepath+filename);
QFileInfo wavfilenameInf(wavfilename); QFileInfo wavfilenameInf(wavfilename);
//! the actual generation of the .talk files //! the actual generation of the .talk files
@ -147,7 +153,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
m_logger->addItem(tr("Encoding of %1").arg(toSpeak),LOGINFO); m_logger->addItem(tr("Encoding of %1").arg(toSpeak),LOGINFO);
if(!m_enc->encode(wavfilename,filename)) if(!m_enc->encode(wavfilename,filepath+filename))
{ {
m_logger->addItem(tr("Encoding of %1 failed").arg(wavfilename),LOGERROR); m_logger->addItem(tr("Encoding of %1 failed").arg(wavfilename),LOGERROR);
m_logger->abort(); m_logger->abort();
@ -171,7 +177,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
installlog.setValue(wavfilename.remove(0,m_mountpoint.length()),now); installlog.setValue(wavfilename.remove(0,m_mountpoint.length()),now);
//! add the .talk file to the install log //! add the .talk file to the install log
installlog.setValue(filename.remove(0,m_mountpoint.length()),now); installlog.setValue(QString(filepath+filename).remove(0,m_mountpoint.length()),now);
it.next(); it.next();
} }