1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
Copyright (C) 2007,2015 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
18 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
|
#include "qsamplerOptions.h" |
|
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
|
#include "qsamplerOptions.h" |
25 |
|
#include "qsamplerMainForm.h" |
26 |
|
|
27 |
|
#include <QTextStream> |
28 |
|
#include <QComboBox> |
29 |
|
|
30 |
#include <qcombobox.h> |
#include <lscp/client.h> |
31 |
|
|
32 |
#include "lscp/client.h" |
#ifdef CONFIG_LIBGIG |
33 |
|
#include <gig.h> |
34 |
|
#endif |
35 |
|
|
|
#include "config.h" |
|
36 |
|
|
37 |
|
namespace QSampler { |
38 |
|
|
39 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
40 |
// qsamplerOptions - Prototype settings structure. |
// QSampler::Options - Prototype settings structure. |
41 |
// |
// |
42 |
|
|
43 |
// Constructor. |
// Constructor. |
44 |
qsamplerOptions::qsamplerOptions (void) |
Options::Options (void) |
45 |
|
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
46 |
{ |
{ |
47 |
// Begin master key group. |
loadOptions(); |
48 |
m_settings.beginGroup("/qsampler"); |
} |
49 |
|
|
|
// And go into general options group. |
|
|
m_settings.beginGroup("/Options"); |
|
50 |
|
|
51 |
// Load server options... |
// Default Destructor. |
52 |
m_settings.beginGroup("/Server"); |
Options::~Options (void) |
53 |
sServerHost = m_settings.readEntry("/ServerHost", "localhost"); |
{ |
54 |
iServerPort = m_settings.readNumEntry("/ServerPort", 8888); |
saveOptions(); |
|
iServerTimeout = m_settings.readNumEntry("/ServerTimeout", 500); |
|
|
bServerStart = m_settings.readBoolEntry("/ServerStart", true); |
|
|
sServerCmdLine = m_settings.readEntry("/ServerCmdLine", "linuxsampler"); |
|
|
iStartDelay = m_settings.readNumEntry("/StartDelay", 2); |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// Load display options... |
|
|
m_settings.beginGroup("/Display"); |
|
|
sDisplayFont = m_settings.readEntry("/DisplayFont", QString::null); |
|
|
bAutoRefresh = m_settings.readBoolEntry("/AutoRefresh", true); |
|
|
iAutoRefreshTime = m_settings.readNumEntry("/AutoRefreshTime", 1000); |
|
|
iMaxVolume = m_settings.readNumEntry("/MaxVolume", 100); |
|
|
sMessagesFont = m_settings.readEntry("/MessagesFont", QString::null); |
|
|
bMessagesLimit = m_settings.readBoolEntry("/MessagesLimit", true); |
|
|
iMessagesLimitLines = m_settings.readNumEntry("/MessagesLimitLines", 1000); |
|
|
bConfirmRemove = m_settings.readBoolEntry("/ConfirmRemove", true); |
|
|
bStdoutCapture = m_settings.readBoolEntry("/StdoutCapture", true); |
|
|
bCompletePath = m_settings.readBoolEntry("/CompletePath", true); |
|
|
iMaxRecentFiles = m_settings.readNumEntry("/MaxRecentFiles", 5); |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// And go into view options group. |
|
|
m_settings.beginGroup("/View"); |
|
|
bMenubar = m_settings.readBoolEntry("/Menubar", true); |
|
|
bToolbar = m_settings.readBoolEntry("/Toolbar", true); |
|
|
bStatusbar = m_settings.readBoolEntry("/Statusbar", true); |
|
|
bAutoArrange = m_settings.readBoolEntry("/AutoArrange", true); |
|
|
m_settings.endGroup(); |
|
|
|
|
|
m_settings.endGroup(); // Options group. |
|
|
|
|
|
// Recent file list. |
|
|
m_settings.beginGroup("/RecentFiles"); |
|
|
recentFiles.clear(); |
|
|
for (int i = 0; i < iMaxRecentFiles; i++) { |
|
|
QString sFilename = m_settings.readEntry("/File" + QString::number(i + 1), QString::null); |
|
|
if (!sFilename.isEmpty()) |
|
|
recentFiles.append(sFilename); |
|
|
} |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// Last but not least, get the default directories. |
|
|
m_settings.beginGroup("/Default"); |
|
|
sSessionDir = m_settings.readEntry("/SessionDir", QString::null); |
|
|
sInstrumentDir = m_settings.readEntry("/InstrumentDir", QString::null); |
|
|
sEngineName = m_settings.readEntry("/EngineName", QString::null); |
|
|
sAudioDriver = m_settings.readEntry("/AudioDriver", QString::null); |
|
|
sMidiDriver = m_settings.readEntry("/MidiDriver", QString::null); |
|
|
m_settings.endGroup(); |
|
55 |
} |
} |
56 |
|
|
57 |
|
|
58 |
// Default Destructor. |
// Explicit load method. |
59 |
qsamplerOptions::~qsamplerOptions (void) |
void Options::loadOptions (void) |
60 |
|
{ |
61 |
|
// Begin into general options group. |
62 |
|
m_settings.beginGroup("/Options"); |
63 |
|
|
64 |
|
// Load server options... |
65 |
|
m_settings.beginGroup("/Server"); |
66 |
|
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
67 |
|
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
68 |
|
#if defined(__APPLE__) // Toshi Nagata 20080105 |
69 |
|
// TODO: Should this be a configure option? |
70 |
|
iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt(); |
71 |
|
#else |
72 |
|
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
73 |
|
#endif |
74 |
|
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
75 |
|
#if defined(__APPLE__) |
76 |
|
sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString(); |
77 |
|
#else |
78 |
|
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
79 |
|
#endif |
80 |
|
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
81 |
|
m_settings.endGroup(); |
82 |
|
|
83 |
|
// Load logging options... |
84 |
|
m_settings.beginGroup("/Logging"); |
85 |
|
bMessagesLog = m_settings.value("/MessagesLog", false).toBool(); |
86 |
|
sMessagesLogPath = m_settings.value("/MessagesLogPath", "qsampler.log").toString(); |
87 |
|
m_settings.endGroup(); |
88 |
|
|
89 |
|
// Load display options... |
90 |
|
m_settings.beginGroup("/Display"); |
91 |
|
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
92 |
|
bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool(); |
93 |
|
bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool(); |
94 |
|
iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt(); |
95 |
|
iMaxVolume = m_settings.value("/MaxVolume", 100).toInt(); |
96 |
|
sMessagesFont = m_settings.value("/MessagesFont").toString(); |
97 |
|
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
98 |
|
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
99 |
|
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
100 |
|
bConfirmReset = m_settings.value("/ConfirmReset", true).toBool(); |
101 |
|
bConfirmRestart = m_settings.value("/ConfirmRestart", true).toBool(); |
102 |
|
bConfirmError = m_settings.value("/ConfirmError", true).toBool(); |
103 |
|
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
104 |
|
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
105 |
|
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
106 |
|
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
107 |
|
iBaseFontSize = m_settings.value("/BaseFontSize", 0).toInt(); |
108 |
|
// if libgig provides a fast way to retrieve instrument names even for large |
109 |
|
// .gig files, then we enable this feature by default |
110 |
|
#ifdef CONFIG_LIBGIG_SETAUTOLOAD |
111 |
|
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
112 |
|
#else |
113 |
|
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
114 |
|
#endif |
115 |
|
m_settings.endGroup(); |
116 |
|
|
117 |
|
// And go into view options group. |
118 |
|
m_settings.beginGroup("/View"); |
119 |
|
bMenubar = m_settings.value("/Menubar", true).toBool(); |
120 |
|
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
121 |
|
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
122 |
|
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
123 |
|
m_settings.endGroup(); |
124 |
|
|
125 |
|
m_settings.endGroup(); // Options group. |
126 |
|
|
127 |
|
// Recent file list. |
128 |
|
recentFiles.clear(); |
129 |
|
m_settings.beginGroup("/RecentFiles"); |
130 |
|
for (int iFile = 0; iFile < iMaxRecentFiles; iFile++) { |
131 |
|
QString sFilename = m_settings.value( |
132 |
|
"/File" + QString::number(iFile + 1)).toString(); |
133 |
|
if (!sFilename.isEmpty()) |
134 |
|
recentFiles.append(sFilename); |
135 |
|
} |
136 |
|
m_settings.endGroup(); |
137 |
|
|
138 |
|
// Sampler fine tuning settings. |
139 |
|
m_settings.beginGroup("/Tuning"); |
140 |
|
iMaxVoices = m_settings.value("/MaxVoices", -1).toInt(); |
141 |
|
iMaxStreams = m_settings.value("/MaxStreams", -1).toInt(); |
142 |
|
m_settings.endGroup(); |
143 |
|
|
144 |
|
// Last but not least, get the default directories. |
145 |
|
m_settings.beginGroup("/Default"); |
146 |
|
sSessionDir = m_settings.value("/SessionDir").toString(); |
147 |
|
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
148 |
|
sEngineName = m_settings.value("/EngineName").toString(); |
149 |
|
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
150 |
|
sMidiDriver = m_settings.value("/MidiDriver").toString(); |
151 |
|
iMidiMap = m_settings.value("/MidiMap", 0).toInt(); |
152 |
|
iMidiBank = m_settings.value("/MidiBank", 0).toInt(); |
153 |
|
iMidiProg = m_settings.value("/MidiProg", 0).toInt(); |
154 |
|
iVolume = m_settings.value("/Volume", 100).toInt(); |
155 |
|
iLoadMode = m_settings.value("/Loadmode", 0).toInt(); |
156 |
|
m_settings.endGroup(); |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
// Explicit save method. |
161 |
|
void Options::saveOptions (void) |
162 |
{ |
{ |
163 |
// Make program version available in the future. |
// Make program version available in the future. |
164 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
165 |
m_settings.writeEntry("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
166 |
m_settings.endGroup(); |
m_settings.endGroup(); |
167 |
|
|
168 |
// And go into general options group. |
// And go into general options group. |
169 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Options"); |
170 |
|
|
171 |
// Save server options. |
// Save server options. |
172 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/Server"); |
173 |
m_settings.writeEntry("/ServerHost", sServerHost); |
m_settings.setValue("/ServerHost", sServerHost); |
174 |
m_settings.writeEntry("/ServerPort", iServerPort); |
m_settings.setValue("/ServerPort", iServerPort); |
175 |
m_settings.writeEntry("/ServerTimeout", iServerTimeout); |
m_settings.setValue("/ServerTimeout", iServerTimeout); |
176 |
m_settings.writeEntry("/ServerStart", bServerStart); |
m_settings.setValue("/ServerStart", bServerStart); |
177 |
m_settings.writeEntry("/ServerCmdLine", sServerCmdLine); |
m_settings.setValue("/ServerCmdLine", sServerCmdLine); |
178 |
m_settings.writeEntry("/StartDelay", iStartDelay); |
m_settings.setValue("/StartDelay", iStartDelay); |
179 |
m_settings.endGroup(); |
m_settings.endGroup(); |
180 |
|
|
181 |
// Save display options. |
// Save logging options... |
182 |
m_settings.beginGroup("/Display"); |
m_settings.beginGroup("/Logging"); |
183 |
m_settings.writeEntry("/DisplayFont", sDisplayFont); |
m_settings.setValue("/MessagesLog", bMessagesLog); |
184 |
m_settings.writeEntry("/AutoRefresh", bAutoRefresh); |
m_settings.setValue("/MessagesLogPath", sMessagesLogPath); |
185 |
m_settings.writeEntry("/AutoRefreshTime", iAutoRefreshTime); |
m_settings.endGroup(); |
186 |
m_settings.writeEntry("/MaxVolume", iMaxVolume); |
|
187 |
m_settings.writeEntry("/MessagesFont", sMessagesFont); |
// Save display options. |
188 |
m_settings.writeEntry("/MessagesLimit", bMessagesLimit); |
m_settings.beginGroup("/Display"); |
189 |
m_settings.writeEntry("/MessagesLimitLines", iMessagesLimitLines); |
m_settings.setValue("/DisplayFont", sDisplayFont); |
190 |
m_settings.writeEntry("/ConfirmRemove", bConfirmRemove); |
m_settings.setValue("/DisplayEffect", bDisplayEffect); |
191 |
m_settings.writeEntry("/StdoutCapture", bStdoutCapture); |
m_settings.setValue("/AutoRefresh", bAutoRefresh); |
192 |
m_settings.writeEntry("/CompletePath", bCompletePath); |
m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime); |
193 |
m_settings.writeEntry("/MaxRecentFiles", iMaxRecentFiles); |
m_settings.setValue("/MaxVolume", iMaxVolume); |
194 |
m_settings.endGroup(); |
m_settings.setValue("/MessagesFont", sMessagesFont); |
195 |
|
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
196 |
// View options group. |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
197 |
m_settings.beginGroup("/View"); |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
198 |
m_settings.writeEntry("/Menubar", bMenubar); |
m_settings.setValue("/ConfirmReset", bConfirmReset); |
199 |
m_settings.writeEntry("/Toolbar", bToolbar); |
m_settings.setValue("/ConfirmRestart", bConfirmRestart); |
200 |
m_settings.writeEntry("/Statusbar", bStatusbar); |
m_settings.setValue("/ConfirmError", bConfirmError); |
201 |
m_settings.writeEntry("/AutoArrange", bAutoArrange); |
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
202 |
m_settings.endGroup(); |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
203 |
|
m_settings.setValue("/CompletePath", bCompletePath); |
204 |
m_settings.endGroup(); // Options group. |
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
205 |
|
m_settings.setValue("/BaseFontSize", iBaseFontSize); |
206 |
// Recent file list. |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
207 |
m_settings.beginGroup("/RecentFiles"); |
m_settings.endGroup(); |
208 |
for (int i = 0; i < (int) recentFiles.count(); i++) |
|
209 |
m_settings.writeEntry("/File" + QString::number(i + 1), recentFiles[i]); |
// View options group. |
210 |
m_settings.endGroup(); |
m_settings.beginGroup("/View"); |
211 |
|
m_settings.setValue("/Menubar", bMenubar); |
212 |
// Default directories. |
m_settings.setValue("/Toolbar", bToolbar); |
213 |
m_settings.beginGroup("/Default"); |
m_settings.setValue("/Statusbar", bStatusbar); |
214 |
m_settings.writeEntry("/SessionDir", sSessionDir); |
m_settings.setValue("/AutoArrange", bAutoArrange); |
215 |
m_settings.writeEntry("/InstrumentDir", sInstrumentDir); |
m_settings.endGroup(); |
216 |
m_settings.writeEntry("/EngineName", sEngineName); |
|
217 |
m_settings.writeEntry("/AudioDriver", sAudioDriver); |
m_settings.endGroup(); // Options group. |
218 |
m_settings.writeEntry("/MidiDriver", sMidiDriver); |
|
219 |
m_settings.endGroup(); |
// Recent file list. |
220 |
|
int iFile = 0; |
221 |
|
m_settings.beginGroup("/RecentFiles"); |
222 |
|
QStringListIterator iter(recentFiles); |
223 |
|
while (iter.hasNext()) |
224 |
|
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
225 |
|
m_settings.endGroup(); |
226 |
|
|
227 |
|
// Sampler fine tuning settings. |
228 |
|
m_settings.beginGroup("/Tuning"); |
229 |
|
if (iMaxVoices > 0) |
230 |
|
m_settings.setValue("/MaxVoices", iMaxVoices); |
231 |
|
if (iMaxStreams >= 0) |
232 |
|
m_settings.setValue("/MaxStreams", iMaxStreams); |
233 |
|
m_settings.endGroup(); |
234 |
|
|
235 |
|
// Default directories. |
236 |
|
m_settings.beginGroup("/Default"); |
237 |
|
m_settings.setValue("/SessionDir", sSessionDir); |
238 |
|
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
239 |
|
m_settings.setValue("/EngineName", sEngineName); |
240 |
|
m_settings.setValue("/AudioDriver", sAudioDriver); |
241 |
|
m_settings.setValue("/MidiDriver", sMidiDriver); |
242 |
|
m_settings.setValue("/MidiMap", iMidiMap); |
243 |
|
m_settings.setValue("/MidiBank", iMidiBank); |
244 |
|
m_settings.setValue("/MidiProg", iMidiProg); |
245 |
|
m_settings.setValue("/Volume", iVolume); |
246 |
|
m_settings.setValue("/Loadmode", iLoadMode); |
247 |
|
m_settings.endGroup(); |
248 |
|
|
249 |
m_settings.endGroup(); |
// Save/commit to disk. |
250 |
|
m_settings.sync(); |
251 |
} |
} |
252 |
|
|
253 |
|
|
254 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
255 |
// Settings accessor. |
// Settings accessor. |
256 |
// |
// |
257 |
|
|
258 |
QSettings& qsamplerOptions::settings (void) |
QSettings& Options::settings (void) |
259 |
{ |
{ |
260 |
return m_settings; |
return m_settings; |
261 |
} |
} |
262 |
|
|
263 |
|
|
266 |
// |
// |
267 |
|
|
268 |
// Help about command line options. |
// Help about command line options. |
269 |
void qsamplerOptions::print_usage ( const char *arg0 ) |
void Options::print_usage ( const QString& arg0 ) |
270 |
{ |
{ |
271 |
const QString sEot = "\n\t"; |
QTextStream out(stderr); |
272 |
const QString sEol = "\n\n"; |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
273 |
|
QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" |
274 |
fprintf(stderr, QObject::tr("Usage") + ": %s [" + QObject::tr("options") + "] [" + |
"Options:\n\n" |
275 |
QObject::tr("session-file") + "]" + sEol, arg0); |
" -s, --start\n\tStart linuxsampler server locally\n\n" |
276 |
fprintf(stderr, QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE) + sEol); |
" -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n" |
277 |
fprintf(stderr, QObject::tr("Options") + ":" + sEol); |
" -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n" |
278 |
fprintf(stderr, " -s, --start" + sEot + |
" -?, --help\n\tShow help about command line options\n\n" |
279 |
QObject::tr("Start linuxsampler server locally") + sEol); |
" -v, --version\n\tShow version information\n\n") |
280 |
fprintf(stderr, " -h, --hostname" + sEot + |
.arg(arg0); |
|
QObject::tr("Specify linuxsampler server hostname") + sEol); |
|
|
fprintf(stderr, " -p, --port" + sEot + |
|
|
QObject::tr("Specify linuxsampler server port number") + sEol); |
|
|
fprintf(stderr, " -?, --help" + sEot + |
|
|
QObject::tr("Show help about command line options") + sEol); |
|
|
fprintf(stderr, " -v, --version" + sEot + |
|
|
QObject::tr("Show version information") + sEol); |
|
281 |
} |
} |
282 |
|
|
283 |
|
|
284 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
285 |
bool qsamplerOptions::parse_args ( int argc, char **argv ) |
bool Options::parse_args ( const QStringList& args ) |
286 |
{ |
{ |
287 |
const QString sEol = "\n\n"; |
QTextStream out(stderr); |
288 |
int iCmdArgs = 0; |
const QString sEol = "\n\n"; |
289 |
|
int iCmdArgs = 0; |
290 |
for (int i = 1; i < argc; i++) { |
const int argc = args.count(); |
291 |
|
|
292 |
|
for (int i = 1; i < argc; i++) { |
293 |
|
|
294 |
|
if (iCmdArgs > 0) { |
295 |
|
sSessionFile += " "; |
296 |
|
sSessionFile += args.at(i); |
297 |
|
iCmdArgs++; |
298 |
|
continue; |
299 |
|
} |
300 |
|
|
301 |
|
QString sArg = args.at(i); |
302 |
|
QString sVal = QString::null; |
303 |
|
const int iEqual = sArg.indexOf("="); |
304 |
|
if (iEqual >= 0) { |
305 |
|
sVal = sArg.right(sArg.length() - iEqual - 1); |
306 |
|
sArg = sArg.left(iEqual); |
307 |
|
} |
308 |
|
else if (i < argc - 1) { |
309 |
|
sVal = args.at(i + 1); |
310 |
|
if (sVal[0] == '-') |
311 |
|
sVal.clear(); |
312 |
|
} |
313 |
|
|
314 |
|
if (sArg == "-s" || sArg == "--start") { |
315 |
|
bServerStart = true; |
316 |
|
} |
317 |
|
else if (sArg == "-h" || sArg == "--hostname") { |
318 |
|
if (sVal.isNull()) { |
319 |
|
out << QObject::tr("Option -h requires an argument (host).") + sEol; |
320 |
|
return false; |
321 |
|
} |
322 |
|
sServerHost = sVal; |
323 |
|
if (iEqual < 0) |
324 |
|
i++; |
325 |
|
} |
326 |
|
else if (sArg == "-p" || sArg == "--port") { |
327 |
|
if (sVal.isNull()) { |
328 |
|
out << QObject::tr("Option -p requires an argument (port).") + sEol; |
329 |
|
return false; |
330 |
|
} |
331 |
|
iServerPort = sVal.toInt(); |
332 |
|
if (iEqual < 0) |
333 |
|
i++; |
334 |
|
} |
335 |
|
else if (sArg == "-?" || sArg == "--help") { |
336 |
|
print_usage(args.at(0)); |
337 |
|
return false; |
338 |
|
} |
339 |
|
else if (sArg == "-v" || sArg == "--version") { |
340 |
|
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
341 |
|
#ifdef CONFIG_LIBGIG |
342 |
|
out << QString("%1: %2\n") |
343 |
|
.arg(gig::libraryName().c_str()) |
344 |
|
.arg(gig::libraryVersion().c_str()); |
345 |
|
#endif |
346 |
|
out << QString("%1: %2\n") |
347 |
|
.arg(::lscp_client_package()) |
348 |
|
.arg(::lscp_client_version()); |
349 |
|
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
350 |
|
return false; |
351 |
|
} |
352 |
|
else { |
353 |
|
// If we don't have one by now, |
354 |
|
// this will be the startup sesion file... |
355 |
|
sSessionFile += sArg; |
356 |
|
iCmdArgs++; |
357 |
|
} |
358 |
|
} |
359 |
|
|
360 |
if (iCmdArgs > 0) { |
// Alright with argument parsing. |
361 |
sSessionFile += " "; |
return true; |
|
sSessionFile += argv[i]; |
|
|
iCmdArgs++; |
|
|
continue; |
|
|
} |
|
|
|
|
|
QString sArg = argv[i]; |
|
|
QString sVal = QString::null; |
|
|
int iEqual = sArg.find("="); |
|
|
if (iEqual >= 0) { |
|
|
sVal = sArg.right(sArg.length() - iEqual - 1); |
|
|
sArg = sArg.left(iEqual); |
|
|
} |
|
|
else if (i < argc) |
|
|
sVal = argv[i + 1]; |
|
|
|
|
|
if (sArg == "-s" || sArg == "--start") { |
|
|
bServerStart = true; |
|
|
} |
|
|
else if (sArg == "-h" || sArg == "--hostname") { |
|
|
if (sVal.isNull()) { |
|
|
fprintf(stderr, QObject::tr("Option -h requires an argument (hostname).") + sEol); |
|
|
return false; |
|
|
} |
|
|
sServerHost = sVal; |
|
|
if (iEqual < 0) |
|
|
i++; |
|
|
} |
|
|
else if (sArg == "-p" || sArg == "--port") { |
|
|
if (sVal.isNull()) { |
|
|
fprintf(stderr, QObject::tr("Option -p requires an argument (port).") + sEol); |
|
|
return false; |
|
|
} |
|
|
iServerPort = sVal.toInt(); |
|
|
if (iEqual < 0) |
|
|
i++; |
|
|
} |
|
|
else if (sArg == "-?" || sArg == "--help") { |
|
|
print_usage(argv[0]); |
|
|
return false; |
|
|
} |
|
|
else if (sArg == "-v" || sArg == "--version") { |
|
|
fprintf(stderr, "Qt: %s\n", qVersion()); |
|
|
fprintf(stderr, "liblscp: %s\n", ::lscp_client_version()); |
|
|
fprintf(stderr, "qsampler: %s\n", QSAMPLER_VERSION); |
|
|
return false; |
|
|
} |
|
|
else { |
|
|
// If we don't have one by now, |
|
|
// this will be the startup sesion file... |
|
|
sSessionFile += sArg; |
|
|
iCmdArgs++; |
|
|
} |
|
|
} |
|
|
|
|
|
// Alright with argument parsing. |
|
|
return true; |
|
362 |
} |
} |
363 |
|
|
364 |
|
|
365 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
366 |
// Widget geometry persistence helper methods. |
// Widget geometry persistence helper methods. |
367 |
|
|
368 |
void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget ) |
void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
369 |
{ |
{ |
370 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
371 |
if (pWidget) { |
if (pWidget) { |
372 |
QPoint fpos; |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
373 |
QSize fsize; |
const QByteArray& geometry |
374 |
bool bVisible; |
= m_settings.value("/geometry").toByteArray(); |
375 |
m_settings.beginGroup("/Geometry/" + QString(pWidget->name())); |
if (!geometry.isEmpty()) { |
376 |
fpos.setX(m_settings.readNumEntry("/x", -1)); |
pWidget->restoreGeometry(geometry); |
377 |
fpos.setY(m_settings.readNumEntry("/y", -1)); |
} else { |
378 |
fsize.setWidth(m_settings.readNumEntry("/width", -1)); |
#if 1//--LOAD_OLD_GEOMETRY |
379 |
fsize.setHeight(m_settings.readNumEntry("/height", -1)); |
QPoint wpos; |
380 |
bVisible = m_settings.readBoolEntry("/visible", false); |
QSize wsize; |
381 |
m_settings.endGroup(); |
wpos.setX(m_settings.value("/x", -1).toInt()); |
382 |
if (fpos.x() > 0 && fpos.y() > 0) |
wpos.setY(m_settings.value("/y", -1).toInt()); |
383 |
pWidget->move(fpos); |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
384 |
if (fsize.width() > 0 && fsize.height() > 0) |
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
385 |
pWidget->resize(fsize); |
if (wpos.x() > 0 && wpos.y() > 0) |
386 |
else |
pWidget->move(wpos); |
387 |
pWidget->adjustSize(); |
if (wsize.width() > 0 && wsize.height() > 0) |
388 |
if (bVisible) |
pWidget->resize(wsize); |
389 |
pWidget->show(); |
else |
390 |
else |
#endif |
391 |
pWidget->hide(); |
pWidget->adjustSize(); |
392 |
} |
} |
393 |
|
if (!bVisible) |
394 |
|
bVisible = m_settings.value("/visible", false).toBool(); |
395 |
|
if (bVisible) |
396 |
|
pWidget->show(); |
397 |
|
else |
398 |
|
pWidget->hide(); |
399 |
|
m_settings.endGroup(); |
400 |
|
} |
401 |
} |
} |
402 |
|
|
403 |
|
|
404 |
void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget ) |
void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
405 |
{ |
{ |
406 |
// Try to save form window position... |
// Try to save form window position... |
407 |
// (due to X11 window managers ideossincrasies, we better |
// (due to X11 window managers ideossincrasies, we better |
408 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
409 |
if (pWidget) { |
if (pWidget) { |
410 |
m_settings.beginGroup("/Geometry/" + QString(pWidget->name())); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
411 |
bool bVisible = pWidget->isVisible(); |
#if 0//--SAVE_OLD_GEOMETRY |
412 |
if (bVisible) { |
const QPoint& wpos = pWidget->pos(); |
413 |
QPoint fpos = pWidget->pos(); |
const QSize& wsize = pWidget->size(); |
414 |
QSize fsize = pWidget->size(); |
m_settings.setValue("/x", wpos.x()); |
415 |
m_settings.writeEntry("/x", fpos.x()); |
m_settings.setValue("/y", wpos.y()); |
416 |
m_settings.writeEntry("/y", fpos.y()); |
m_settings.setValue("/width", wsize.width()); |
417 |
m_settings.writeEntry("/width", fsize.width()); |
m_settings.setValue("/height", wsize.height()); |
418 |
m_settings.writeEntry("/height", fsize.height()); |
#endif |
419 |
} |
m_settings.setValue("/geometry", pWidget->saveGeometry()); |
420 |
m_settings.writeEntry("/visible", bVisible); |
if (!bVisible) bVisible = pWidget->isVisible(); |
421 |
m_settings.endGroup(); |
m_settings.setValue("/visible", bVisible); |
422 |
} |
m_settings.endGroup(); |
423 |
|
} |
424 |
} |
} |
425 |
|
|
426 |
|
|
427 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
428 |
// Combo box history persistence helper implementation. |
// Combo box history persistence helper implementation. |
429 |
|
|
430 |
void qsamplerOptions::add2ComboBoxHistory ( QComboBox *pComboBox, const QString& sNewText, int iLimit, int iIndex ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
431 |
{ |
{ |
432 |
int iCount = pComboBox->count(); |
const bool bBlockSignals = pComboBox->blockSignals(true); |
433 |
for (int i = 0; i < iCount; i++) { |
|
434 |
QString sText = pComboBox->text(i); |
// Load combobox list from configuration settings file... |
435 |
if (sText == sNewText) { |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
436 |
pComboBox->removeItem(i); |
|
437 |
iCount--; |
if (m_settings.childKeys().count() > 0) { |
438 |
break; |
pComboBox->setUpdatesEnabled(false); |
439 |
} |
pComboBox->setDuplicatesEnabled(false); |
440 |
} |
pComboBox->clear(); |
441 |
while (iCount >= iLimit) |
for (int i = 0; i < iLimit; ++i) { |
442 |
pComboBox->removeItem(--iCount); |
const QString& sText = m_settings.value( |
443 |
pComboBox->insertItem(sNewText, iIndex); |
"/Item" + QString::number(i + 1)).toString(); |
444 |
|
if (sText.isEmpty()) |
445 |
|
break; |
446 |
|
pComboBox->addItem(sText); |
447 |
|
} |
448 |
|
pComboBox->setUpdatesEnabled(true); |
449 |
|
} |
450 |
|
|
451 |
|
m_settings.endGroup(); |
452 |
|
|
453 |
|
pComboBox->blockSignals(bBlockSignals); |
454 |
} |
} |
455 |
|
|
456 |
|
|
457 |
void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
458 |
{ |
{ |
459 |
pComboBox->setUpdatesEnabled(false); |
const bool bBlockSignals = pComboBox->blockSignals(true); |
|
pComboBox->setDuplicatesEnabled(false); |
|
460 |
|
|
461 |
m_settings.beginGroup("/History/" + QString(pComboBox->name())); |
// Add current text as latest item... |
462 |
for (int i = 0; i < iLimit; i++) { |
const QString sCurrentText = pComboBox->currentText(); |
463 |
QString sText = m_settings.readEntry("/Item" + QString::number(i + 1), QString::null); |
int iCount = pComboBox->count(); |
464 |
if (sText.isEmpty()) |
for (int i = 0; i < iCount; i++) { |
465 |
break; |
const QString& sText = pComboBox->itemText(i); |
466 |
add2ComboBoxHistory(pComboBox, sText, iLimit); |
if (sText == sCurrentText) { |
467 |
} |
pComboBox->removeItem(i); |
468 |
m_settings.endGroup(); |
--iCount; |
469 |
|
break; |
470 |
|
} |
471 |
|
} |
472 |
|
while (iCount >= iLimit) |
473 |
|
pComboBox->removeItem(--iCount); |
474 |
|
pComboBox->insertItem(0, sCurrentText); |
475 |
|
pComboBox->setCurrentIndex(0); |
476 |
|
++iCount; |
477 |
|
|
478 |
|
// Save combobox list to configuration settings file... |
479 |
|
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
480 |
|
for (int i = 0; i < iCount; ++i) { |
481 |
|
const QString& sText = pComboBox->itemText(i); |
482 |
|
if (sText.isEmpty()) |
483 |
|
break; |
484 |
|
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
485 |
|
} |
486 |
|
m_settings.endGroup(); |
487 |
|
|
488 |
pComboBox->setUpdatesEnabled(true); |
pComboBox->blockSignals(bBlockSignals); |
489 |
} |
} |
490 |
|
|
491 |
|
|
492 |
void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
int Options::getMaxVoices() { |
493 |
{ |
#ifndef CONFIG_MAX_VOICES |
494 |
add2ComboBoxHistory(pComboBox, pComboBox->currentText(), iLimit, 0); |
return -1; |
495 |
|
#else |
496 |
|
if (iMaxVoices > 0) return iMaxVoices; |
497 |
|
return getEffectiveMaxVoices(); |
498 |
|
#endif // CONFIG_MAX_VOICES |
499 |
|
} |
500 |
|
|
501 |
|
int Options::getEffectiveMaxVoices() { |
502 |
|
#ifndef CONFIG_MAX_VOICES |
503 |
|
return -1; |
504 |
|
#else |
505 |
|
MainForm *pMainForm = MainForm::getInstance(); |
506 |
|
if (!pMainForm || !pMainForm->client()) |
507 |
|
return -1; |
508 |
|
|
509 |
|
return ::lscp_get_voices(pMainForm->client()); |
510 |
|
#endif // CONFIG_MAX_VOICES |
511 |
|
} |
512 |
|
|
513 |
|
void Options::setMaxVoices(int iMaxVoices) { |
514 |
|
#ifdef CONFIG_MAX_VOICES |
515 |
|
if (iMaxVoices < 1) return; |
516 |
|
|
517 |
|
MainForm *pMainForm = MainForm::getInstance(); |
518 |
|
if (!pMainForm || !pMainForm->client()) |
519 |
|
return; |
520 |
|
|
521 |
|
lscp_status_t result = |
522 |
|
::lscp_set_voices(pMainForm->client(), iMaxVoices); |
523 |
|
|
524 |
|
if (result != LSCP_OK) { |
525 |
|
pMainForm->appendMessagesClient("lscp_set_voices"); |
526 |
|
return; |
527 |
|
} |
528 |
|
|
529 |
m_settings.beginGroup("/History/" + QString(pComboBox->name())); |
this->iMaxVoices = iMaxVoices; |
530 |
for (int i = 0; i < iLimit && i < pComboBox->count(); i++) { |
#endif // CONFIG_MAX_VOICES |
|
QString sText = pComboBox->text(i); |
|
|
if (sText.isEmpty()) |
|
|
break; |
|
|
m_settings.writeEntry("/Item" + QString::number(i + 1), sText); |
|
|
} |
|
|
m_settings.endGroup(); |
|
531 |
} |
} |
532 |
|
|
533 |
|
int Options::getMaxStreams() { |
534 |
|
#ifndef CONFIG_MAX_VOICES |
535 |
|
return -1; |
536 |
|
#else |
537 |
|
if (iMaxStreams > 0) return iMaxStreams; |
538 |
|
return getEffectiveMaxStreams(); |
539 |
|
#endif // CONFIG_MAX_VOICES |
540 |
|
} |
541 |
|
|
542 |
|
int Options::getEffectiveMaxStreams() { |
543 |
|
#ifndef CONFIG_MAX_VOICES |
544 |
|
return -1; |
545 |
|
#else |
546 |
|
MainForm *pMainForm = MainForm::getInstance(); |
547 |
|
if (!pMainForm || !pMainForm->client()) |
548 |
|
return -1; |
549 |
|
|
550 |
|
return ::lscp_get_streams(pMainForm->client()); |
551 |
|
#endif // CONFIG_MAX_VOICES |
552 |
|
} |
553 |
|
|
554 |
|
void Options::setMaxStreams(int iMaxStreams) { |
555 |
|
#ifdef CONFIG_MAX_VOICES |
556 |
|
if (iMaxStreams < 0) return; |
557 |
|
|
558 |
|
MainForm *pMainForm = MainForm::getInstance(); |
559 |
|
if (!pMainForm || !pMainForm->client()) |
560 |
|
return; |
561 |
|
|
562 |
|
lscp_status_t result = |
563 |
|
::lscp_set_streams(pMainForm->client(), iMaxStreams); |
564 |
|
|
565 |
|
if (result != LSCP_OK) { |
566 |
|
pMainForm->appendMessagesClient("lscp_set_streams"); |
567 |
|
return; |
568 |
|
} |
569 |
|
|
570 |
|
this->iMaxStreams = iMaxStreams; |
571 |
|
#endif // CONFIG_MAX_VOICES |
572 |
|
} |
573 |
|
|
574 |
|
void Options::sendFineTuningSettings() { |
575 |
|
setMaxVoices(iMaxVoices); |
576 |
|
setMaxStreams(iMaxStreams); |
577 |
|
|
578 |
|
MainForm *pMainForm = MainForm::getInstance(); |
579 |
|
if (!pMainForm || !pMainForm->client()) |
580 |
|
return; |
581 |
|
|
582 |
|
pMainForm->appendMessages(QObject::tr("Sent fine tuning settings.")); |
583 |
|
} |
584 |
|
|
585 |
|
} // namespace QSampler |
586 |
|
|
587 |
|
|
588 |
// end of qsamplerOptions.cpp |
// end of qsamplerOptions.cpp |