summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/encodersgui.cpp
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2008-01-29 21:54:43 +0000
committerDominik Wenger <domonoky@googlemail.com>2008-01-29 21:54:43 +0000
commit0c66bdb2b01794448b7676a1b2b5ee5fd8c83371 (patch)
tree847eba2bd686d6639a002d602a102f36207c554e /rbutil/rbutilqt/encodersgui.cpp
parent51f937c2e445eaef345d3a9d15782436bb5e5c27 (diff)
rbutil: fix a bug in the new settings object. Seperate the config gui from tts and encoders. (in preparation for cli interface).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16183 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/encodersgui.cpp')
-rw-r--r--rbutil/rbutilqt/encodersgui.cpp170
1 files changed, 170 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/encodersgui.cpp b/rbutil/rbutilqt/encodersgui.cpp
new file mode 100644
index 0000000000..76d0acf5c8
--- /dev/null
+++ b/rbutil/rbutilqt/encodersgui.cpp
@@ -0,0 +1,170 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: encodersgui.cpp 15212 2007-10-19 21:49:07Z domonoky $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "encodersgui.h"
+
+#include "rbsettings.h"
+#include "browsedirtree.h"
+
+EncExesGui::EncExesGui(QDialog* parent) : QDialog(parent)
+{
+ ui.setupUi(this);
+ this->hide();
+ connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
+ connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
+}
+
+void EncExesGui::showCfg(QString name)
+{
+ m_name = name;
+ // try to get config from settings
+ QString exepath =settings->encoderPath(m_name);
+ ui.encoderoptions->setText(settings->encoderOptions(m_name));
+
+ if(exepath == "")
+ {
+
+ // try to autodetect encoder
+#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
+ if(QFileInfo(executable).isExecutable())
+ {
+ qDebug() << "found:" << executable;
+ exepath = QDir::toNativeSeparators(executable);
+ break;
+ }
+ }
+ }
+
+ ui.encoderpath->setText(exepath);
+
+ //show dialog
+ this->exec();
+
+}
+
+void EncExesGui::accept(void)
+{
+ //save settings in user config
+ settings->setEncoderPath(m_name,ui.encoderpath->text());
+ settings->setEncoderOptions(m_name,ui.encoderoptions->text());
+
+ // sync settings
+ settings->sync();
+ this->close();
+}
+
+void EncExesGui::reject(void)
+{
+ this->close();
+}
+
+void EncExesGui::reset()
+{
+ ui.encoderpath->setText("");
+ ui.encoderoptions->setText("");
+}
+
+void EncExesGui::browse()
+{
+ BrowseDirtree browser(this);
+ browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+
+ if(QFileInfo(ui.encoderpath->text()).isDir())
+ {
+ browser.setDir(ui.encoderpath->text());
+ }
+ if(browser.exec() == QDialog::Accepted)
+ {
+ qDebug() << browser.getSelected();
+ QString exe = browser.getSelected();
+ if(!QFileInfo(exe).isExecutable())
+ return;
+ ui.encoderpath->setText(exe);
+ }
+}
+
+
+EncRbSpeexGui::EncRbSpeexGui(QDialog* parent) : QDialog(parent)
+{
+ ui.setupUi(this);
+ this->hide();
+ connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
+
+}
+
+void EncRbSpeexGui::showCfg(float defQ,float defV,float defC, bool defB)
+{
+ defaultQuality =defQ;
+ defaultVolume = defV;
+ defaultComplexity = defC;
+ defaultBand =defB;
+
+ //fill in the usersettings
+ ui.volume->setValue(settings->encoderVolume("rbspeex"));
+ ui.quality->setValue(settings->encoderQuality("rbspeex"));
+ ui.complexity->setValue(settings->encoderComplexity("rbspeex"));
+
+ if(settings->encoderNarrowband("rbspeex"))
+ ui.narrowband->setCheckState(Qt::Checked);
+ else
+ ui.narrowband->setCheckState(Qt::Unchecked);
+
+ //show dialog
+ this->exec();
+}
+
+void EncRbSpeexGui::accept(void)
+{
+ //save settings in user config
+ settings->setEncoderVolume("rbspeex",ui.volume->value());
+ settings->setEncoderQuality("rbspeex",ui.quality->value());
+ settings->setEncoderComplexity("rbspeex",ui.complexity->value());
+ settings->setEncoderNarrowband("rbspeex",ui.narrowband->isChecked() ? true : false);
+
+ // sync settings
+ settings->sync();
+ this->close();
+}
+
+void EncRbSpeexGui::reject(void)
+{
+ this->close();
+}
+
+void EncRbSpeexGui::reset()
+{
+ ui.volume->setValue(defaultVolume);
+ ui.quality->setValue(defaultQuality);
+ ui.complexity->setValue(defaultComplexity);
+ ui.narrowband->setChecked(Qt::Unchecked);
+}