1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "encodersgui.h"
22 #include "rbsettings.h"
23 #include "browsedirtree.h"
25 EncExesGui::EncExesGui(QDialog
* parent
) : QDialog(parent
)
29 connect(ui
.reset
,SIGNAL(clicked()),this,SLOT(reset()));
30 connect(ui
.browse
,SIGNAL(clicked()),this,SLOT(browse()));
33 void EncExesGui::showCfg(QString name
)
36 // try to get config from settings
37 QString exepath
=settings
->encoderPath(m_name
);
38 ui
.encoderoptions
->setText(settings
->encoderOptions(m_name
));
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
);
51 for(int i
= 0; i
< path
.size(); i
++)
53 QString executable
= QDir::fromNativeSeparators(path
.at(i
)) + "/" + m_name
;
56 QStringList ex
= executable
.split("\"", QString::SkipEmptyParts
);
57 executable
= ex
.join("");
59 if(QFileInfo(executable
).isExecutable())
61 qDebug() << "found:" << executable
;
62 exepath
= QDir::toNativeSeparators(executable
);
68 ui
.encoderpath
->setText(exepath
);
75 void EncExesGui::accept(void)
77 //save settings in user config
78 settings
->setEncoderPath(m_name
,ui
.encoderpath
->text());
79 settings
->setEncoderOptions(m_name
,ui
.encoderoptions
->text());
86 void EncExesGui::reject(void)
91 void EncExesGui::reset()
93 ui
.encoderpath
->setText("");
94 ui
.encoderoptions
->setText("");
97 void EncExesGui::browse()
99 BrowseDirtree
browser(this);
100 browser
.setFilter(QDir::Dirs
| QDir::Files
| QDir::NoDotAndDotDot
);
102 if(QFileInfo(ui
.encoderpath
->text()).isDir())
104 browser
.setDir(ui
.encoderpath
->text());
106 if(browser
.exec() == QDialog::Accepted
)
108 qDebug() << browser
.getSelected();
109 QString exe
= browser
.getSelected();
110 if(!QFileInfo(exe
).isExecutable())
112 ui
.encoderpath
->setText(exe
);
117 EncRbSpeexGui::EncRbSpeexGui(QDialog
* parent
) : QDialog(parent
)
121 connect(ui
.reset
,SIGNAL(clicked()),this,SLOT(reset()));
125 void EncRbSpeexGui::showCfg(float defQ
,float defV
,int defC
, bool defB
)
127 defaultQuality
=defQ
;
128 defaultVolume
= defV
;
129 defaultComplexity
= defC
;
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"));
137 if(settings
->encoderNarrowband("rbspeex"))
138 ui
.narrowband
->setCheckState(Qt::Checked
);
140 ui
.narrowband
->setCheckState(Qt::Unchecked
);
146 void EncRbSpeexGui::accept(void)
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);
159 void EncRbSpeexGui::reject(void)
164 void EncRbSpeexGui::reset()
166 ui
.volume
->setValue(defaultVolume
);
167 ui
.quality
->setValue(defaultQuality
);
168 ui
.complexity
->setValue(defaultComplexity
);
169 ui
.narrowband
->setChecked(Qt::Unchecked
);