summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2008-08-02 16:40:16 +0000
committerDominik Wenger <domonoky@googlemail.com>2008-08-02 16:40:16 +0000
commit85eb99211ad1c9a71364a5de17eafc0644a03c67 (patch)
tree0e0f265af4a2d90cc0d7a4c2e1bd3f44ba5e201b /rbutil
parent4c83ef1dbebacc84d03d343bb542cd1ce53bbac5 (diff)
downloadrockbox-85eb99211ad1c9a71364a5de17eafc0644a03c67.tar.gz
rockbox-85eb99211ad1c9a71364a5de17eafc0644a03c67.tar.bz2
rockbox-85eb99211ad1c9a71364a5de17eafc0644a03c67.zip
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
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/tts.cpp37
-rw-r--r--rbutil/rbutilqt/tts.h4
-rw-r--r--rbutil/rbutilqt/ttsgui.cpp31
3 files changed, 41 insertions, 31 deletions
diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp
index d6049f8aec..fd0097c617 100644
--- a/rbutil/rbutilqt/tts.cpp
+++ b/rbutil/rbutilqt/tts.cpp
@@ -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)
{
m_TTSexec = settings->ttsPath(m_name);
diff --git a/rbutil/rbutilqt/tts.h b/rbutil/rbutilqt/tts.h
index e25949de55..f73114b8c1 100644
--- a/rbutil/rbutilqt/tts.h
+++ b/rbutil/rbutilqt/tts.h
@@ -46,7 +46,7 @@ class TTSBase : public QObject
virtual void showCfg(){}
virtual bool configOk() { return false; }
- void setCfg(RbSettings* sett) { settings = sett; }
+ virtual void setCfg(RbSettings* sett) { settings = sett; }
static TTSBase* getTTS(QString ttsname);
static QStringList getTTSList();
@@ -105,6 +105,8 @@ class TTSExes : public TTSBase
virtual void showCfg();
virtual bool configOk();
+ virtual void setCfg(RbSettings* sett);
+
private:
QString m_name;
QString m_TTSexec;
diff --git a/rbutil/rbutilqt/ttsgui.cpp b/rbutil/rbutilqt/ttsgui.cpp
index 385dfa12e7..0a59b25d86 100644
--- a/rbutil/rbutilqt/ttsgui.cpp
+++ b/rbutil/rbutilqt/ttsgui.cpp
@@ -137,36 +137,7 @@ void TTSExesGui::showCfg(QString name)
m_name = name;
// try to get config from settings
QString exepath =settings->ttsPath(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.ttsoptions->setText(settings->ttsOptions(m_name));
ui.ttspath->setText(exepath);
//show dialog