1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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,int 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);
}
|