1
0
Fork 0
forked from len0rd/rockbox

Improve visual feedback when testing TTS.

Disable the "Test TTS" button during a running test and on invalid TTS
configuration.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29581 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2011-03-13 14:57:58 +00:00
parent 1177651d56
commit 92183d2dd0

View file

@ -396,11 +396,13 @@ void Config::updateTtsState(int index)
{ {
ui.configTTSstatus->setText(tr("Configuration OK")); ui.configTTSstatus->setText(tr("Configuration OK"));
ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png"))); ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
ui.testTTS->setEnabled(true);
} }
else else
{ {
ui.configTTSstatus->setText(tr("Configuration INVALID")); ui.configTTSstatus->setText(tr("Configuration INVALID"));
ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png"))); ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
ui.testTTS->setEnabled(false);
} }
delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject, delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
@ -718,8 +720,9 @@ void Config::configTts()
EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(ui.comboTts->itemData(index).toString())); EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(ui.comboTts->itemData(index).toString()));
gui.exec(); gui.exec();
updateTtsState(ui.comboTts->currentIndex()); updateTtsState(ui.comboTts->currentIndex());
delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject, delete tts; /* Config objects are never deleted (in fact, they are
since that would delete the TTSBase instance on application exit*/ leaked..), so we can't rely on QObject, since that would
delete the TTSBase instance on application exit */
} }
void Config::testTts() void Config::testTts()
@ -733,26 +736,28 @@ void Config::testTts()
tr("TTS configuration invalid. \n Please configure TTS engine.")); tr("TTS configuration invalid. \n Please configure TTS engine."));
return; return;
} }
ui.testTTS->setEnabled(false);
if(!tts->start(&errstr)) if(!tts->start(&errstr))
{ {
QMessageBox::warning(this,tr("Could not start TTS engine."), QMessageBox::warning(this,tr("Could not start TTS engine."),
tr("Could not start TTS engine.\n") + errstr tr("Could not start TTS engine.\n") + errstr
+ tr("\nPlease configure TTS engine.")); + tr("\nPlease configure TTS engine."));
ui.testTTS->setEnabled(true);
return; return;
} }
QTemporaryFile file(this); QTemporaryFile file(this);
file.open(); file.open();
QString filename = file.fileName(); QString filename = file.fileName();
file.close(); file.close();
if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError) if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError)
{ {
tts->stop(); tts->stop();
QMessageBox::warning(this,tr("Could not voice test string."), QMessageBox::warning(this,tr("Could not voice test string."),
tr("Could not voice test string.\n") + errstr tr("Could not voice test string.\n") + errstr
+ tr("\nPlease configure TTS engine.")); + tr("\nPlease configure TTS engine."));
ui.testTTS->setEnabled(false);
return; return;
} }
tts->stop(); tts->stop();
@ -766,9 +771,10 @@ void Config::testTts()
#else #else
QSound::play(filename); QSound::play(filename);
#endif #endif
ui.testTTS->setEnabled(true);
delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject, delete tts; /* Config objects are never deleted (in fact, they are
since that would delete the TTSBase instance on application exit*/ leaked..), so we can't rely on QObject, since that would
delete the TTSBase instance on application exit */
} }
void Config::configEnc() void Config::configEnc()