rbutil: try to detect position of tts executeables without opening the config window.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18183 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4c83ef1dbe
commit
85eb99211a
3 changed files with 41 additions and 31 deletions
|
@ -97,6 +97,43 @@ TTSExes::TTSExes(QString name) : TTSBase()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTSExes::setCfg(RbSettings* sett)
|
||||||
|
{
|
||||||
|
// call function of base class
|
||||||
|
TTSBase::setCfg(sett);
|
||||||
|
|
||||||
|
// if the config isnt OK, try to autodetect
|
||||||
|
if(!configOk())
|
||||||
|
{
|
||||||
|
QString exepath;
|
||||||
|
//try autodetect tts
|
||||||
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||||
|
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
|
qDebug() << path;
|
||||||
|
for(int i = 0; i < path.size(); i++)
|
||||||
|
{
|
||||||
|
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
executable += ".exe";
|
||||||
|
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
||||||
|
executable = ex.join("");
|
||||||
|
#endif
|
||||||
|
qDebug() << executable;
|
||||||
|
if(QFileInfo(executable).isExecutable())
|
||||||
|
{
|
||||||
|
exepath= QDir::toNativeSeparators(executable);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings->setTTSPath(m_name,exepath);
|
||||||
|
settings->sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool TTSExes::start(QString *errStr)
|
bool TTSExes::start(QString *errStr)
|
||||||
{
|
{
|
||||||
m_TTSexec = settings->ttsPath(m_name);
|
m_TTSexec = settings->ttsPath(m_name);
|
||||||
|
|
|
@ -46,7 +46,7 @@ class TTSBase : public QObject
|
||||||
virtual void showCfg(){}
|
virtual void showCfg(){}
|
||||||
virtual bool configOk() { return false; }
|
virtual bool configOk() { return false; }
|
||||||
|
|
||||||
void setCfg(RbSettings* sett) { settings = sett; }
|
virtual void setCfg(RbSettings* sett) { settings = sett; }
|
||||||
|
|
||||||
static TTSBase* getTTS(QString ttsname);
|
static TTSBase* getTTS(QString ttsname);
|
||||||
static QStringList getTTSList();
|
static QStringList getTTSList();
|
||||||
|
@ -105,6 +105,8 @@ class TTSExes : public TTSBase
|
||||||
virtual void showCfg();
|
virtual void showCfg();
|
||||||
virtual bool configOk();
|
virtual bool configOk();
|
||||||
|
|
||||||
|
virtual void setCfg(RbSettings* sett);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_TTSexec;
|
QString m_TTSexec;
|
||||||
|
|
|
@ -138,35 +138,6 @@ void TTSExesGui::showCfg(QString name)
|
||||||
// try to get config from settings
|
// try to get config from settings
|
||||||
QString exepath =settings->ttsPath(m_name);
|
QString exepath =settings->ttsPath(m_name);
|
||||||
ui.ttsoptions->setText(settings->ttsOptions(m_name));
|
ui.ttsoptions->setText(settings->ttsOptions(m_name));
|
||||||
|
|
||||||
if(exepath == "")
|
|
||||||
{
|
|
||||||
|
|
||||||
//try autodetect tts
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
|
||||||
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
|
||||||
#elif defined(Q_OS_WIN)
|
|
||||||
QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
|
|
||||||
#endif
|
|
||||||
qDebug() << path;
|
|
||||||
for(int i = 0; i < path.size(); i++)
|
|
||||||
{
|
|
||||||
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
executable += ".exe";
|
|
||||||
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
|
||||||
executable = ex.join("");
|
|
||||||
#endif
|
|
||||||
qDebug() << executable;
|
|
||||||
if(QFileInfo(executable).isExecutable())
|
|
||||||
{
|
|
||||||
exepath= QDir::toNativeSeparators(executable);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.ttspath->setText(exepath);
|
ui.ttspath->setText(exepath);
|
||||||
|
|
||||||
//show dialog
|
//show dialog
|
||||||
|
|
Loading…
Reference in a new issue