1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2009, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, 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 |
44 |
Options::Options (void) |
Options::Options (void) |
45 |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
46 |
{ |
{ |
47 |
|
loadOptions(); |
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
|
// Default Destructor. |
52 |
|
Options::~Options (void) |
53 |
|
{ |
54 |
|
saveOptions(); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
// Explicit load method. |
59 |
|
void Options::loadOptions (void) |
60 |
|
{ |
61 |
// Begin into general options group. |
// Begin into general options group. |
62 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Options"); |
63 |
|
|
154 |
} |
} |
155 |
|
|
156 |
|
|
157 |
// Default Destructor. |
// Explicit save method. |
158 |
Options::~Options (void) |
void Options::saveOptions (void) |
159 |
{ |
{ |
160 |
// Make program version available in the future. |
// Make program version available in the future. |
161 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
239 |
m_settings.setValue("/Volume", iVolume); |
m_settings.setValue("/Volume", iVolume); |
240 |
m_settings.setValue("/Loadmode", iLoadMode); |
m_settings.setValue("/Loadmode", iLoadMode); |
241 |
m_settings.endGroup(); |
m_settings.endGroup(); |
242 |
|
|
243 |
|
// Save/commit to disk. |
244 |
|
m_settings.sync(); |
245 |
} |
} |
246 |
|
|
247 |
|
|
248 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
249 |
// Settings accessor. |
// Settings accessor. |
250 |
// |
// |
260 |
// |
// |
261 |
|
|
262 |
// Help about command line options. |
// Help about command line options. |
263 |
void Options::print_usage ( const char *arg0 ) |
void Options::print_usage ( const QString& arg0 ) |
264 |
{ |
{ |
265 |
QTextStream out(stderr); |
QTextStream out(stderr); |
266 |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
276 |
|
|
277 |
|
|
278 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
279 |
bool Options::parse_args ( int argc, char **argv ) |
bool Options::parse_args ( const QStringList& args ) |
280 |
{ |
{ |
281 |
QTextStream out(stderr); |
QTextStream out(stderr); |
282 |
const QString sEol = "\n\n"; |
const QString sEol = "\n\n"; |
283 |
int iCmdArgs = 0; |
int iCmdArgs = 0; |
284 |
|
int argc = args.count(); |
285 |
|
|
286 |
for (int i = 1; i < argc; i++) { |
for (int i = 1; i < argc; i++) { |
287 |
|
|
288 |
if (iCmdArgs > 0) { |
if (iCmdArgs > 0) { |
289 |
sSessionFile += " "; |
sSessionFile += " "; |
290 |
sSessionFile += argv[i]; |
sSessionFile += args.at(i); |
291 |
iCmdArgs++; |
iCmdArgs++; |
292 |
continue; |
continue; |
293 |
} |
} |
294 |
|
|
295 |
QString sArg = argv[i]; |
QString sArg = args.at(i); |
296 |
QString sVal = QString::null; |
QString sVal = QString::null; |
297 |
int iEqual = sArg.indexOf("="); |
int iEqual = sArg.indexOf("="); |
298 |
if (iEqual >= 0) { |
if (iEqual >= 0) { |
299 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
sVal = sArg.right(sArg.length() - iEqual - 1); |
300 |
sArg = sArg.left(iEqual); |
sArg = sArg.left(iEqual); |
301 |
} |
} |
302 |
else if (i < argc) |
else if (i < argc - 1) |
303 |
sVal = argv[i + 1]; |
sVal = args.at(i + 1); |
304 |
|
|
305 |
if (sArg == "-s" || sArg == "--start") { |
if (sArg == "-s" || sArg == "--start") { |
306 |
bServerStart = true; |
bServerStart = true; |
324 |
i++; |
i++; |
325 |
} |
} |
326 |
else if (sArg == "-?" || sArg == "--help") { |
else if (sArg == "-?" || sArg == "--help") { |
327 |
print_usage(argv[0]); |
print_usage(args.at(0)); |
328 |
return false; |
return false; |
329 |
} |
} |
330 |
else if (sArg == "-v" || sArg == "--version") { |
else if (sArg == "-v" || sArg == "--version") { |