summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/encodersgui.cpp
diff options
context:
space:
mode:
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: encodersgui.cpp 15212 2007-10-19 21:49:07Z domonoky $
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "encodersgui.h"
21
22#include "rbsettings.h"
23#include "browsedirtree.h"
24
25EncExesGui::EncExesGui(QDialog* parent) : QDialog(parent)
26{
27 ui.setupUi(this);
28 this->hide();
29 connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
30 connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
31}
32
33void EncExesGui::showCfg(QString name)
34{
35 m_name = name;
36 // try to get config from settings
37 QString exepath =settings->encoderPath(m_name);
38 ui.encoderoptions->setText(settings->encoderOptions(m_name));
39
40 if(exepath == "")
41 {
42
43 // try to autodetect encoder
44#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
45 QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
46#elif defined(Q_OS_WIN)
47 QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
48#endif
49 qDebug() << path;
50
51 for(int i = 0; i < path.size(); i++)
52 {
53 QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
54#if defined(Q_OS_WIN)
55 executable += ".exe";
56 QStringList ex = executable.split("\"", QString::SkipEmptyParts);
57 executable = ex.join("");
58#endif
59 if(QFileInfo(executable).isExecutable())
60 {
61 qDebug() << "found:" << executable;
62 exepath = QDir::toNativeSeparators(executable);
63 break;
64 }
65 }
66 }
67
68 ui.encoderpath->setText(exepath);
69
70 //show dialog
71 this->exec();
72
73}
74
75void EncExesGui::accept(void)
76{
77 //save settings in user config
78 settings->setEncoderPath(m_name,ui.encoderpath->text());
79 settings->setEncoderOptions(m_name,ui.encoderoptions->text());
80
81 // sync settings
82 settings->sync();
83 this->close();
84}
85
86void EncExesGui::reject(void)
87{
88 this->close();
89}
90
91void EncExesGui::reset()
92{
93 ui.encoderpath->setText("");
94 ui.encoderoptions->setText("");
95}
96
97void EncExesGui::browse()
98{
99 BrowseDirtree browser(this);
100 browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
101
102 if(QFileInfo(ui.encoderpath->text()).isDir())
103 {
104 browser.setDir(ui.encoderpath->text());
105 }
106 if(browser.exec() == QDialog::Accepted)
107 {
108 qDebug() << browser.getSelected();
109 QString exe = browser.getSelected();
110 if(!QFileInfo(exe).isExecutable())
111 return;
112 ui.encoderpath->setText(exe);
113 }
114}
115
116
117EncRbSpeexGui::EncRbSpeexGui(QDialog* parent) : QDialog(parent)
118{
119 ui.setupUi(this);
120 this->hide();
121 connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
122
123}
124
125void EncRbSpeexGui::showCfg(float defQ,float defV,float defC, bool defB)
126{
127 defaultQuality =defQ;
128 defaultVolume = defV;
129 defaultComplexity = defC;
130 defaultBand =defB;
131
132 //fill in the usersettings
133 ui.volume->setValue(settings->encoderVolume("rbspeex"));
134 ui.quality->setValue(settings->encoderQuality("rbspeex"));
135 ui.complexity->setValue(settings->encoderComplexity("rbspeex"));
136
137 if(settings->encoderNarrowband("rbspeex"))
138 ui.narrowband->setCheckState(Qt::Checked);
139 else
140 ui.narrowband->setCheckState(Qt::Unchecked);
141
142 //show dialog
143 this->exec();
144}
145
146void EncRbSpeexGui::accept(void)
147{
148 //save settings in user config
149 settings->setEncoderVolume("rbspeex",ui.volume->value());
150 settings->setEncoderQuality("rbspeex",ui.quality->value());
151 settings->setEncoderComplexity("rbspeex",ui.complexity->value());
152 settings->setEncoderNarrowband("rbspeex",ui.narrowband->isChecked() ? true : false);
153
154 // sync settings
155 settings->sync();
156 this->close();
157}
158
159void EncRbSpeexGui::reject(void)
160{
161 this->close();
162}
163
164void EncRbSpeexGui::reset()
165{
166 ui.volume->setValue(defaultVolume);
167 ui.quality->setValue(defaultQuality);
168 ui.complexity->setValue(defaultComplexity);
169 ui.narrowband->setChecked(Qt::Unchecked);
170}