1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2010, 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 |
22 |
|
|
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
25 |
|
#include "qsamplerMainForm.h" |
26 |
|
|
27 |
#include <QTextStream> |
#include <QTextStream> |
28 |
#include <QComboBox> |
#include <QComboBox> |
34 |
#endif |
#endif |
35 |
|
|
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) |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
46 |
{ |
{ |
47 |
// Begin into general options group. |
loadOptions(); |
48 |
m_settings.beginGroup("/Options"); |
} |
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. |
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__) // Toshi Nagata 20080113 |
76 |
|
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").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 server options... |
// Load display options... |
90 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/Display"); |
91 |
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
92 |
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool(); |
93 |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool(); |
94 |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt(); |
95 |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
iMaxVolume = m_settings.value("/MaxVolume", 100).toInt(); |
96 |
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
sMessagesFont = m_settings.value("/MessagesFont").toString(); |
97 |
m_settings.endGroup(); |
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
98 |
|
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
99 |
// Load display options... |
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
100 |
m_settings.beginGroup("/Display"); |
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
101 |
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
102 |
bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool(); |
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
103 |
bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool(); |
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
104 |
iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt(); |
iBaseFontSize = m_settings.value("/BaseFontSize", 0).toInt(); |
105 |
iMaxVolume = m_settings.value("/MaxVolume", 100).toInt(); |
// if libgig provides a fast way to retrieve instrument names even for large |
106 |
sMessagesFont = m_settings.value("/MessagesFont").toString(); |
// .gig files, then we enable this feature by default |
107 |
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
#if HAVE_LIBGIG_SETAUTOLOAD |
108 |
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
109 |
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
#else |
110 |
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
111 |
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
#endif |
112 |
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
m_settings.endGroup(); |
113 |
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
|
114 |
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
// And go into view options group. |
115 |
m_settings.endGroup(); |
m_settings.beginGroup("/View"); |
116 |
|
bMenubar = m_settings.value("/Menubar", true).toBool(); |
117 |
// And go into view options group. |
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
118 |
m_settings.beginGroup("/View"); |
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
119 |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
120 |
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
m_settings.endGroup(); |
|
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
|
|
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
|
|
m_settings.endGroup(); |
|
121 |
|
|
122 |
m_settings.endGroup(); // Options group. |
m_settings.endGroup(); // Options group. |
123 |
|
|
124 |
// Recent file list. |
// Recent file list. |
125 |
recentFiles.clear(); |
recentFiles.clear(); |
132 |
} |
} |
133 |
m_settings.endGroup(); |
m_settings.endGroup(); |
134 |
|
|
135 |
// Last but not least, get the default directories. |
// Sampler fine tuning settings. |
136 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Tuning"); |
137 |
sSessionDir = m_settings.value("/SessionDir").toString(); |
iMaxVoices = m_settings.value("/MaxVoices", -1).toInt(); |
138 |
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
iMaxStreams = m_settings.value("/MaxStreams", -1).toInt(); |
139 |
sEngineName = m_settings.value("/EngineName").toString(); |
m_settings.endGroup(); |
140 |
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
|
141 |
sMidiDriver = m_settings.value("/MidiDriver").toString(); |
// Last but not least, get the default directories. |
142 |
iMidiMap = m_settings.value("/MidiMap", 0).toInt(); |
m_settings.beginGroup("/Default"); |
143 |
iMidiBank = m_settings.value("/MidiBank", 0).toInt(); |
sSessionDir = m_settings.value("/SessionDir").toString(); |
144 |
iMidiProg = m_settings.value("/MidiProg", 0).toInt(); |
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
145 |
iVolume = m_settings.value("/Volume", 100).toInt(); |
sEngineName = m_settings.value("/EngineName").toString(); |
146 |
iLoadMode = m_settings.value("/Loadmode", 0).toInt(); |
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
147 |
m_settings.endGroup(); |
sMidiDriver = m_settings.value("/MidiDriver").toString(); |
148 |
|
iMidiMap = m_settings.value("/MidiMap", 0).toInt(); |
149 |
|
iMidiBank = m_settings.value("/MidiBank", 0).toInt(); |
150 |
|
iMidiProg = m_settings.value("/MidiProg", 0).toInt(); |
151 |
|
iVolume = m_settings.value("/Volume", 100).toInt(); |
152 |
|
iLoadMode = m_settings.value("/Loadmode", 0).toInt(); |
153 |
|
m_settings.endGroup(); |
154 |
} |
} |
155 |
|
|
156 |
|
|
157 |
// Default Destructor. |
// Explicit save method. |
158 |
qsamplerOptions::~qsamplerOptions (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"); |
162 |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
163 |
m_settings.endGroup(); |
m_settings.endGroup(); |
|
|
|
|
// And go into general options group. |
|
|
m_settings.beginGroup("/Options"); |
|
|
|
|
|
// Save server options. |
|
|
m_settings.beginGroup("/Server"); |
|
|
m_settings.setValue("/ServerHost", sServerHost); |
|
|
m_settings.setValue("/ServerPort", iServerPort); |
|
|
m_settings.setValue("/ServerTimeout", iServerTimeout); |
|
|
m_settings.setValue("/ServerStart", bServerStart); |
|
|
m_settings.setValue("/ServerCmdLine", sServerCmdLine); |
|
|
m_settings.setValue("/StartDelay", iStartDelay); |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// Save display options. |
|
|
m_settings.beginGroup("/Display"); |
|
|
m_settings.setValue("/DisplayFont", sDisplayFont); |
|
|
m_settings.setValue("/DisplayEffect", bDisplayEffect); |
|
|
m_settings.setValue("/AutoRefresh", bAutoRefresh); |
|
|
m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime); |
|
|
m_settings.setValue("/MaxVolume", iMaxVolume); |
|
|
m_settings.setValue("/MessagesFont", sMessagesFont); |
|
|
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
|
|
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
|
|
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
|
|
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
|
|
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
|
|
m_settings.setValue("/CompletePath", bCompletePath); |
|
|
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
|
|
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// View options group. |
|
|
m_settings.beginGroup("/View"); |
|
|
m_settings.setValue("/Menubar", bMenubar); |
|
|
m_settings.setValue("/Toolbar", bToolbar); |
|
|
m_settings.setValue("/Statusbar", bStatusbar); |
|
|
m_settings.setValue("/AutoArrange", bAutoArrange); |
|
|
m_settings.endGroup(); |
|
164 |
|
|
165 |
m_settings.endGroup(); // Options group. |
// And go into general options group. |
166 |
|
m_settings.beginGroup("/Options"); |
167 |
|
|
168 |
|
// Save server options. |
169 |
|
m_settings.beginGroup("/Server"); |
170 |
|
m_settings.setValue("/ServerHost", sServerHost); |
171 |
|
m_settings.setValue("/ServerPort", iServerPort); |
172 |
|
m_settings.setValue("/ServerTimeout", iServerTimeout); |
173 |
|
m_settings.setValue("/ServerStart", bServerStart); |
174 |
|
m_settings.setValue("/ServerCmdLine", sServerCmdLine); |
175 |
|
m_settings.setValue("/StartDelay", iStartDelay); |
176 |
|
m_settings.endGroup(); |
177 |
|
|
178 |
|
// Save logging options... |
179 |
|
m_settings.beginGroup("/Logging"); |
180 |
|
m_settings.setValue("/MessagesLog", bMessagesLog); |
181 |
|
m_settings.setValue("/MessagesLogPath", sMessagesLogPath); |
182 |
|
m_settings.endGroup(); |
183 |
|
|
184 |
// Recent file list. |
// Save display options. |
185 |
|
m_settings.beginGroup("/Display"); |
186 |
|
m_settings.setValue("/DisplayFont", sDisplayFont); |
187 |
|
m_settings.setValue("/DisplayEffect", bDisplayEffect); |
188 |
|
m_settings.setValue("/AutoRefresh", bAutoRefresh); |
189 |
|
m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime); |
190 |
|
m_settings.setValue("/MaxVolume", iMaxVolume); |
191 |
|
m_settings.setValue("/MessagesFont", sMessagesFont); |
192 |
|
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
193 |
|
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
194 |
|
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
195 |
|
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
196 |
|
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
197 |
|
m_settings.setValue("/CompletePath", bCompletePath); |
198 |
|
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
199 |
|
m_settings.setValue("/BaseFontSize", iBaseFontSize); |
200 |
|
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
201 |
|
m_settings.endGroup(); |
202 |
|
|
203 |
|
// View options group. |
204 |
|
m_settings.beginGroup("/View"); |
205 |
|
m_settings.setValue("/Menubar", bMenubar); |
206 |
|
m_settings.setValue("/Toolbar", bToolbar); |
207 |
|
m_settings.setValue("/Statusbar", bStatusbar); |
208 |
|
m_settings.setValue("/AutoArrange", bAutoArrange); |
209 |
|
m_settings.endGroup(); |
210 |
|
|
211 |
|
m_settings.endGroup(); // Options group. |
212 |
|
|
213 |
|
// Recent file list. |
214 |
int iFile = 0; |
int iFile = 0; |
215 |
m_settings.beginGroup("/RecentFiles"); |
m_settings.beginGroup("/RecentFiles"); |
216 |
QStringListIterator iter(recentFiles); |
QStringListIterator iter(recentFiles); |
218 |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
219 |
m_settings.endGroup(); |
m_settings.endGroup(); |
220 |
|
|
221 |
// Default directories. |
// Sampler fine tuning settings. |
222 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Tuning"); |
223 |
m_settings.setValue("/SessionDir", sSessionDir); |
if (iMaxVoices > 0) |
224 |
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
m_settings.setValue("/MaxVoices", iMaxVoices); |
225 |
m_settings.setValue("/EngineName", sEngineName); |
if (iMaxStreams >= 0) |
226 |
m_settings.setValue("/AudioDriver", sAudioDriver); |
m_settings.setValue("/MaxStreams", iMaxStreams); |
227 |
m_settings.setValue("/MidiDriver", sMidiDriver); |
m_settings.endGroup(); |
228 |
m_settings.setValue("/MidiMap", iMidiMap); |
|
229 |
m_settings.setValue("/MidiBank", iMidiBank); |
// Default directories. |
230 |
m_settings.setValue("/MidiProg", iMidiProg); |
m_settings.beginGroup("/Default"); |
231 |
m_settings.setValue("/Volume", iVolume); |
m_settings.setValue("/SessionDir", sSessionDir); |
232 |
m_settings.setValue("/Loadmode", iLoadMode); |
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
233 |
m_settings.endGroup(); |
m_settings.setValue("/EngineName", sEngineName); |
234 |
|
m_settings.setValue("/AudioDriver", sAudioDriver); |
235 |
|
m_settings.setValue("/MidiDriver", sMidiDriver); |
236 |
|
m_settings.setValue("/MidiMap", iMidiMap); |
237 |
|
m_settings.setValue("/MidiBank", iMidiBank); |
238 |
|
m_settings.setValue("/MidiProg", iMidiProg); |
239 |
|
m_settings.setValue("/Volume", iVolume); |
240 |
|
m_settings.setValue("/Loadmode", iLoadMode); |
241 |
|
m_settings.endGroup(); |
242 |
|
|
243 |
|
// Save/commit to disk. |
244 |
|
m_settings.sync(); |
245 |
} |
} |
246 |
|
|
247 |
|
|
248 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
249 |
// Settings accessor. |
// Settings accessor. |
250 |
// |
// |
251 |
|
|
252 |
QSettings& qsamplerOptions::settings (void) |
QSettings& Options::settings (void) |
253 |
{ |
{ |
254 |
return m_settings; |
return m_settings; |
255 |
} |
} |
256 |
|
|
257 |
|
|
260 |
// |
// |
261 |
|
|
262 |
// Help about command line options. |
// Help about command line options. |
263 |
void qsamplerOptions::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 qsamplerOptions::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++) { |
287 |
|
|
288 |
|
if (iCmdArgs > 0) { |
289 |
|
sSessionFile += " "; |
290 |
|
sSessionFile += args.at(i); |
291 |
|
iCmdArgs++; |
292 |
|
continue; |
293 |
|
} |
294 |
|
|
295 |
for (int i = 1; i < argc; i++) { |
QString sArg = args.at(i); |
296 |
|
QString sVal = QString::null; |
297 |
|
int iEqual = sArg.indexOf("="); |
298 |
|
if (iEqual >= 0) { |
299 |
|
sVal = sArg.right(sArg.length() - iEqual - 1); |
300 |
|
sArg = sArg.left(iEqual); |
301 |
|
} |
302 |
|
else if (i < argc - 1) |
303 |
|
sVal = args.at(i + 1); |
304 |
|
|
305 |
if (iCmdArgs > 0) { |
if (sArg == "-s" || sArg == "--start") { |
306 |
sSessionFile += " "; |
bServerStart = true; |
307 |
sSessionFile += argv[i]; |
} |
308 |
iCmdArgs++; |
else if (sArg == "-h" || sArg == "--hostname") { |
309 |
continue; |
if (sVal.isNull()) { |
310 |
} |
out << QObject::tr("Option -h requires an argument (hostname).") + sEol; |
311 |
|
return false; |
312 |
QString sArg = argv[i]; |
} |
313 |
QString sVal = QString::null; |
sServerHost = sVal; |
314 |
int iEqual = sArg.indexOf("="); |
if (iEqual < 0) |
315 |
if (iEqual >= 0) { |
i++; |
316 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
} |
317 |
sArg = sArg.left(iEqual); |
else if (sArg == "-p" || sArg == "--port") { |
318 |
} |
if (sVal.isNull()) { |
319 |
else if (i < argc) |
out << QObject::tr("Option -p requires an argument (port).") + sEol; |
320 |
sVal = argv[i + 1]; |
return false; |
321 |
|
} |
322 |
if (sArg == "-s" || sArg == "--start") { |
iServerPort = sVal.toInt(); |
323 |
bServerStart = true; |
if (iEqual < 0) |
324 |
} |
i++; |
325 |
else if (sArg == "-h" || sArg == "--hostname") { |
} |
326 |
if (sVal.isNull()) { |
else if (sArg == "-?" || sArg == "--help") { |
327 |
out << QObject::tr("Option -h requires an argument (hostname).") + sEol; |
print_usage(args.at(0)); |
328 |
return false; |
return false; |
329 |
} |
} |
330 |
sServerHost = sVal; |
else if (sArg == "-v" || sArg == "--version") { |
|
if (iEqual < 0) |
|
|
i++; |
|
|
} |
|
|
else if (sArg == "-p" || sArg == "--port") { |
|
|
if (sVal.isNull()) { |
|
|
out << 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") { |
|
331 |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
332 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
333 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
338 |
.arg(::lscp_client_package()) |
.arg(::lscp_client_package()) |
339 |
.arg(::lscp_client_version()); |
.arg(::lscp_client_version()); |
340 |
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
341 |
return false; |
return false; |
342 |
} |
} |
343 |
else { |
else { |
344 |
// If we don't have one by now, |
// If we don't have one by now, |
345 |
// this will be the startup sesion file... |
// this will be the startup sesion file... |
346 |
sSessionFile += sArg; |
sSessionFile += sArg; |
347 |
iCmdArgs++; |
iCmdArgs++; |
348 |
} |
} |
349 |
} |
} |
350 |
|
|
351 |
// Alright with argument parsing. |
// Alright with argument parsing. |
352 |
return true; |
return true; |
353 |
} |
} |
354 |
|
|
355 |
|
|
356 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
357 |
// Widget geometry persistence helper methods. |
// Widget geometry persistence helper methods. |
358 |
|
|
359 |
void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget ) |
void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
360 |
{ |
{ |
361 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
362 |
if (pWidget) { |
if (pWidget) { |
363 |
QPoint fpos; |
QPoint wpos; |
364 |
QSize fsize; |
QSize wsize; |
|
bool bVisible; |
|
365 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
366 |
fpos.setX(m_settings.value("/x", -1).toInt()); |
wpos.setX(m_settings.value("/x", -1).toInt()); |
367 |
fpos.setY(m_settings.value("/y", -1).toInt()); |
wpos.setY(m_settings.value("/y", -1).toInt()); |
368 |
fsize.setWidth(m_settings.value("/width", -1).toInt()); |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
369 |
fsize.setHeight(m_settings.value("/height", -1).toInt()); |
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
370 |
bVisible = m_settings.value("/visible", false).toBool(); |
if (!bVisible) bVisible = m_settings.value("/visible", false).toBool(); |
371 |
m_settings.endGroup(); |
m_settings.endGroup(); |
372 |
if (fpos.x() > 0 && fpos.y() > 0) |
if (wpos.x() > 0 && wpos.y() > 0) |
373 |
pWidget->move(fpos); |
pWidget->move(wpos); |
374 |
if (fsize.width() > 0 && fsize.height() > 0) |
if (wsize.width() > 0 && wsize.height() > 0) |
375 |
pWidget->resize(fsize); |
pWidget->resize(wsize); |
376 |
else |
// else |
377 |
pWidget->adjustSize(); |
// pWidget->adjustSize(); |
378 |
if (bVisible) |
if (bVisible) |
379 |
pWidget->show(); |
pWidget->show(); |
380 |
else |
// else |
381 |
pWidget->hide(); |
// pWidget->hide(); |
382 |
} |
} |
383 |
} |
} |
384 |
|
|
385 |
|
|
386 |
void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget ) |
void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
387 |
{ |
{ |
388 |
// Try to save form window position... |
// Try to save form window position... |
389 |
// (due to X11 window managers ideossincrasies, we better |
// (due to X11 window managers ideossincrasies, we better |
390 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
391 |
if (pWidget) { |
if (pWidget) { |
392 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
393 |
bool bVisible = pWidget->isVisible(); |
const QPoint& wpos = pWidget->pos(); |
394 |
const QPoint& fpos = pWidget->pos(); |
const QSize& wsize = pWidget->size(); |
395 |
const QSize& fsize = pWidget->size(); |
if (!bVisible) bVisible = pWidget->isVisible(); |
396 |
m_settings.setValue("/x", fpos.x()); |
m_settings.setValue("/x", wpos.x()); |
397 |
m_settings.setValue("/y", fpos.y()); |
m_settings.setValue("/y", wpos.y()); |
398 |
m_settings.setValue("/width", fsize.width()); |
m_settings.setValue("/width", wsize.width()); |
399 |
m_settings.setValue("/height", fsize.height()); |
m_settings.setValue("/height", wsize.height()); |
400 |
m_settings.setValue("/visible", bVisible); |
m_settings.setValue("/visible", bVisible); |
401 |
m_settings.endGroup(); |
m_settings.endGroup(); |
402 |
} |
} |
406 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
407 |
// Combo box history persistence helper implementation. |
// Combo box history persistence helper implementation. |
408 |
|
|
409 |
void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
410 |
{ |
{ |
411 |
// Load combobox list from configuration settings file... |
// Load combobox list from configuration settings file... |
412 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
429 |
} |
} |
430 |
|
|
431 |
|
|
432 |
void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
433 |
{ |
{ |
434 |
// Add current text as latest item... |
// Add current text as latest item... |
435 |
const QString& sCurrentText = pComboBox->currentText(); |
const QString& sCurrentText = pComboBox->currentText(); |
458 |
m_settings.endGroup(); |
m_settings.endGroup(); |
459 |
} |
} |
460 |
|
|
461 |
|
int Options::getMaxVoices() { |
462 |
|
#ifndef CONFIG_MAX_VOICES |
463 |
|
return -1; |
464 |
|
#else |
465 |
|
if (iMaxVoices > 0) return iMaxVoices; |
466 |
|
return getEffectiveMaxVoices(); |
467 |
|
#endif // CONFIG_MAX_VOICES |
468 |
|
} |
469 |
|
|
470 |
|
int Options::getEffectiveMaxVoices() { |
471 |
|
#ifndef CONFIG_MAX_VOICES |
472 |
|
return -1; |
473 |
|
#else |
474 |
|
MainForm *pMainForm = MainForm::getInstance(); |
475 |
|
if (!pMainForm || !pMainForm->client()) |
476 |
|
return -1; |
477 |
|
|
478 |
|
return ::lscp_get_voices(pMainForm->client()); |
479 |
|
#endif // CONFIG_MAX_VOICES |
480 |
|
} |
481 |
|
|
482 |
|
void Options::setMaxVoices(int iMaxVoices) { |
483 |
|
#ifdef CONFIG_MAX_VOICES |
484 |
|
if (iMaxVoices < 1) return; |
485 |
|
|
486 |
|
MainForm *pMainForm = MainForm::getInstance(); |
487 |
|
if (!pMainForm || !pMainForm->client()) |
488 |
|
return; |
489 |
|
|
490 |
|
lscp_status_t result = |
491 |
|
::lscp_set_voices(pMainForm->client(), iMaxVoices); |
492 |
|
|
493 |
|
if (result != LSCP_OK) { |
494 |
|
pMainForm->appendMessagesClient("lscp_set_voices"); |
495 |
|
return; |
496 |
|
} |
497 |
|
|
498 |
|
this->iMaxVoices = iMaxVoices; |
499 |
|
#endif // CONFIG_MAX_VOICES |
500 |
|
} |
501 |
|
|
502 |
|
int Options::getMaxStreams() { |
503 |
|
#ifndef CONFIG_MAX_VOICES |
504 |
|
return -1; |
505 |
|
#else |
506 |
|
if (iMaxStreams > 0) return iMaxStreams; |
507 |
|
return getEffectiveMaxStreams(); |
508 |
|
#endif // CONFIG_MAX_VOICES |
509 |
|
} |
510 |
|
|
511 |
|
int Options::getEffectiveMaxStreams() { |
512 |
|
#ifndef CONFIG_MAX_VOICES |
513 |
|
return -1; |
514 |
|
#else |
515 |
|
MainForm *pMainForm = MainForm::getInstance(); |
516 |
|
if (!pMainForm || !pMainForm->client()) |
517 |
|
return -1; |
518 |
|
|
519 |
|
return ::lscp_get_streams(pMainForm->client()); |
520 |
|
#endif // CONFIG_MAX_VOICES |
521 |
|
} |
522 |
|
|
523 |
|
void Options::setMaxStreams(int iMaxStreams) { |
524 |
|
#ifdef CONFIG_MAX_VOICES |
525 |
|
if (iMaxStreams < 0) return; |
526 |
|
|
527 |
|
MainForm *pMainForm = MainForm::getInstance(); |
528 |
|
if (!pMainForm || !pMainForm->client()) |
529 |
|
return; |
530 |
|
|
531 |
|
lscp_status_t result = |
532 |
|
::lscp_set_streams(pMainForm->client(), iMaxStreams); |
533 |
|
|
534 |
|
if (result != LSCP_OK) { |
535 |
|
pMainForm->appendMessagesClient("lscp_set_streams"); |
536 |
|
return; |
537 |
|
} |
538 |
|
|
539 |
|
this->iMaxStreams = iMaxStreams; |
540 |
|
#endif // CONFIG_MAX_VOICES |
541 |
|
} |
542 |
|
|
543 |
|
void Options::sendFineTuningSettings() { |
544 |
|
setMaxVoices(iMaxVoices); |
545 |
|
setMaxStreams(iMaxStreams); |
546 |
|
|
547 |
|
MainForm *pMainForm = MainForm::getInstance(); |
548 |
|
if (!pMainForm || !pMainForm->client()) |
549 |
|
return; |
550 |
|
|
551 |
|
pMainForm->appendMessages(QObject::tr("Sent fine tuning settings.")); |
552 |
|
} |
553 |
|
|
554 |
|
} // namespace QSampler |
555 |
|
|
556 |
|
|
557 |
// end of qsamplerOptions.cpp |
// end of qsamplerOptions.cpp |