1 |
capela |
106 |
// qsamplerOptions.cpp |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
2718 |
Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
|
Copyright (C) 2007,2015 Christian Schoenebeck |
6 |
capela |
106 |
|
7 |
|
|
This program is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU General Public License |
9 |
|
|
as published by the Free Software Foundation; either version 2 |
10 |
|
|
of the License, or (at your option) any later version. |
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
GNU General Public License for more details. |
16 |
|
|
|
17 |
capela |
920 |
You should have received a copy of the GNU General Public License along |
18 |
|
|
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
capela |
106 |
|
21 |
|
|
*****************************************************************************/ |
22 |
|
|
|
23 |
capela |
753 |
#include "qsamplerAbout.h" |
24 |
capela |
106 |
#include "qsamplerOptions.h" |
25 |
schoenebeck |
1803 |
#include "qsamplerMainForm.h" |
26 |
capela |
106 |
|
27 |
capela |
1499 |
#include <QTextStream> |
28 |
|
|
#include <QComboBox> |
29 |
capela |
106 |
|
30 |
capela |
264 |
#include <lscp/client.h> |
31 |
capela |
106 |
|
32 |
capela |
605 |
#ifdef CONFIG_LIBGIG |
33 |
|
|
#include <gig.h> |
34 |
|
|
#endif |
35 |
capela |
106 |
|
36 |
capela |
605 |
|
37 |
capela |
1558 |
namespace QSampler { |
38 |
|
|
|
39 |
capela |
106 |
//------------------------------------------------------------------------- |
40 |
capela |
1558 |
// QSampler::Options - Prototype settings structure. |
41 |
capela |
106 |
// |
42 |
|
|
|
43 |
|
|
// Constructor. |
44 |
capela |
1558 |
Options::Options (void) |
45 |
capela |
1504 |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
46 |
capela |
106 |
{ |
47 |
capela |
2028 |
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 |
capela |
1509 |
// Begin into general options group. |
62 |
|
|
m_settings.beginGroup("/Options"); |
63 |
capela |
106 |
|
64 |
capela |
1509 |
// 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 |
capela |
2642 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
69 |
nagata |
1643 |
// TODO: Should this be a configure option? |
70 |
|
|
iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt(); |
71 |
capela |
2642 |
#else |
72 |
capela |
1509 |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
73 |
capela |
2642 |
#endif |
74 |
capela |
1509 |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
75 |
schoenebeck |
2712 |
#if defined(__APPLE__) |
76 |
|
|
sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString(); |
77 |
capela |
2642 |
#else |
78 |
capela |
1509 |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
79 |
capela |
2642 |
#endif |
80 |
capela |
1509 |
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
81 |
|
|
m_settings.endGroup(); |
82 |
capela |
106 |
|
83 |
capela |
1738 |
// 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 |
capela |
1509 |
// 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 |
|
|
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
101 |
|
|
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
102 |
|
|
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
103 |
|
|
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
104 |
capela |
1749 |
iBaseFontSize = m_settings.value("/BaseFontSize", 0).toInt(); |
105 |
schoenebeck |
1527 |
// if libgig provides a fast way to retrieve instrument names even for large |
106 |
|
|
// .gig files, then we enable this feature by default |
107 |
capela |
2646 |
#ifdef CONFIG_LIBGIG_SETAUTOLOAD |
108 |
schoenebeck |
1527 |
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
109 |
|
|
#else |
110 |
capela |
1509 |
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
111 |
schoenebeck |
1527 |
#endif |
112 |
capela |
1509 |
m_settings.endGroup(); |
113 |
capela |
106 |
|
114 |
capela |
1509 |
// And go into view options group. |
115 |
|
|
m_settings.beginGroup("/View"); |
116 |
|
|
bMenubar = m_settings.value("/Menubar", true).toBool(); |
117 |
|
|
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
118 |
|
|
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
119 |
|
|
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
120 |
|
|
m_settings.endGroup(); |
121 |
capela |
106 |
|
122 |
capela |
1509 |
m_settings.endGroup(); // Options group. |
123 |
capela |
106 |
|
124 |
capela |
1499 |
// Recent file list. |
125 |
|
|
recentFiles.clear(); |
126 |
|
|
m_settings.beginGroup("/RecentFiles"); |
127 |
|
|
for (int iFile = 0; iFile < iMaxRecentFiles; iFile++) { |
128 |
|
|
QString sFilename = m_settings.value( |
129 |
|
|
"/File" + QString::number(iFile + 1)).toString(); |
130 |
|
|
if (!sFilename.isEmpty()) |
131 |
|
|
recentFiles.append(sFilename); |
132 |
|
|
} |
133 |
|
|
m_settings.endGroup(); |
134 |
capela |
106 |
|
135 |
schoenebeck |
1803 |
// Sampler fine tuning settings. |
136 |
|
|
m_settings.beginGroup("/Tuning"); |
137 |
|
|
iMaxVoices = m_settings.value("/MaxVoices", -1).toInt(); |
138 |
|
|
iMaxStreams = m_settings.value("/MaxStreams", -1).toInt(); |
139 |
|
|
m_settings.endGroup(); |
140 |
|
|
|
141 |
capela |
1509 |
// Last but not least, get the default directories. |
142 |
|
|
m_settings.beginGroup("/Default"); |
143 |
|
|
sSessionDir = m_settings.value("/SessionDir").toString(); |
144 |
|
|
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
145 |
|
|
sEngineName = m_settings.value("/EngineName").toString(); |
146 |
|
|
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
147 |
|
|
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 |
capela |
106 |
} |
155 |
|
|
|
156 |
|
|
|
157 |
capela |
2028 |
// Explicit save method. |
158 |
|
|
void Options::saveOptions (void) |
159 |
capela |
106 |
{ |
160 |
capela |
1509 |
// Make program version available in the future. |
161 |
|
|
m_settings.beginGroup("/Program"); |
162 |
|
|
m_settings.setValue("/Version", QSAMPLER_VERSION); |
163 |
|
|
m_settings.endGroup(); |
164 |
capela |
106 |
|
165 |
capela |
1509 |
// And go into general options group. |
166 |
|
|
m_settings.beginGroup("/Options"); |
167 |
capela |
106 |
|
168 |
capela |
1509 |
// 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 |
capela |
106 |
|
178 |
capela |
1738 |
// 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 |
capela |
1509 |
// 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 |
capela |
1749 |
m_settings.setValue("/BaseFontSize", iBaseFontSize); |
200 |
capela |
1509 |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
201 |
|
|
m_settings.endGroup(); |
202 |
capela |
106 |
|
203 |
capela |
1509 |
// 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 |
capela |
106 |
|
211 |
capela |
1509 |
m_settings.endGroup(); // Options group. |
212 |
capela |
106 |
|
213 |
capela |
1509 |
// Recent file list. |
214 |
capela |
1499 |
int iFile = 0; |
215 |
|
|
m_settings.beginGroup("/RecentFiles"); |
216 |
|
|
QStringListIterator iter(recentFiles); |
217 |
|
|
while (iter.hasNext()) |
218 |
|
|
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
219 |
|
|
m_settings.endGroup(); |
220 |
capela |
106 |
|
221 |
schoenebeck |
1803 |
// Sampler fine tuning settings. |
222 |
|
|
m_settings.beginGroup("/Tuning"); |
223 |
|
|
if (iMaxVoices > 0) |
224 |
|
|
m_settings.setValue("/MaxVoices", iMaxVoices); |
225 |
|
|
if (iMaxStreams >= 0) |
226 |
|
|
m_settings.setValue("/MaxStreams", iMaxStreams); |
227 |
|
|
m_settings.endGroup(); |
228 |
|
|
|
229 |
capela |
1509 |
// Default directories. |
230 |
|
|
m_settings.beginGroup("/Default"); |
231 |
|
|
m_settings.setValue("/SessionDir", sSessionDir); |
232 |
|
|
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
233 |
|
|
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 |
capela |
2028 |
|
243 |
|
|
// Save/commit to disk. |
244 |
|
|
m_settings.sync(); |
245 |
capela |
106 |
} |
246 |
|
|
|
247 |
capela |
2028 |
|
248 |
capela |
106 |
//------------------------------------------------------------------------- |
249 |
|
|
// Settings accessor. |
250 |
|
|
// |
251 |
|
|
|
252 |
capela |
1558 |
QSettings& Options::settings (void) |
253 |
capela |
106 |
{ |
254 |
capela |
1509 |
return m_settings; |
255 |
capela |
106 |
} |
256 |
|
|
|
257 |
|
|
|
258 |
|
|
//------------------------------------------------------------------------- |
259 |
|
|
// Command-line argument stuff. |
260 |
|
|
// |
261 |
|
|
|
262 |
|
|
// Help about command line options. |
263 |
capela |
1890 |
void Options::print_usage ( const QString& arg0 ) |
264 |
capela |
106 |
{ |
265 |
capela |
1499 |
QTextStream out(stderr); |
266 |
|
|
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
267 |
|
|
QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" |
268 |
|
|
"Options:\n\n" |
269 |
|
|
" -s, --start\n\tStart linuxsampler server locally\n\n" |
270 |
capela |
2642 |
" -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n" |
271 |
|
|
" -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n" |
272 |
capela |
1499 |
" -?, --help\n\tShow help about command line options\n\n" |
273 |
|
|
" -v, --version\n\tShow version information\n\n") |
274 |
|
|
.arg(arg0); |
275 |
capela |
106 |
} |
276 |
|
|
|
277 |
|
|
|
278 |
|
|
// Parse command line arguments into m_settings. |
279 |
capela |
1890 |
bool Options::parse_args ( const QStringList& args ) |
280 |
capela |
106 |
{ |
281 |
capela |
1499 |
QTextStream out(stderr); |
282 |
capela |
1509 |
const QString sEol = "\n\n"; |
283 |
|
|
int iCmdArgs = 0; |
284 |
capela |
2642 |
const int argc = args.count(); |
285 |
capela |
106 |
|
286 |
capela |
1509 |
for (int i = 1; i < argc; i++) { |
287 |
capela |
106 |
|
288 |
capela |
1509 |
if (iCmdArgs > 0) { |
289 |
|
|
sSessionFile += " "; |
290 |
capela |
1890 |
sSessionFile += args.at(i); |
291 |
capela |
1509 |
iCmdArgs++; |
292 |
|
|
continue; |
293 |
|
|
} |
294 |
capela |
106 |
|
295 |
capela |
1890 |
QString sArg = args.at(i); |
296 |
capela |
1509 |
QString sVal = QString::null; |
297 |
capela |
2642 |
const int iEqual = sArg.indexOf("="); |
298 |
capela |
1509 |
if (iEqual >= 0) { |
299 |
|
|
sVal = sArg.right(sArg.length() - iEqual - 1); |
300 |
|
|
sArg = sArg.left(iEqual); |
301 |
|
|
} |
302 |
capela |
2642 |
else if (i < argc - 1) { |
303 |
capela |
1890 |
sVal = args.at(i + 1); |
304 |
capela |
2642 |
if (sVal[0] == '-') |
305 |
|
|
sVal.clear(); |
306 |
|
|
} |
307 |
capela |
106 |
|
308 |
capela |
1509 |
if (sArg == "-s" || sArg == "--start") { |
309 |
|
|
bServerStart = true; |
310 |
|
|
} |
311 |
|
|
else if (sArg == "-h" || sArg == "--hostname") { |
312 |
|
|
if (sVal.isNull()) { |
313 |
capela |
2642 |
out << QObject::tr("Option -h requires an argument (host).") + sEol; |
314 |
capela |
1509 |
return false; |
315 |
|
|
} |
316 |
|
|
sServerHost = sVal; |
317 |
|
|
if (iEqual < 0) |
318 |
|
|
i++; |
319 |
|
|
} |
320 |
|
|
else if (sArg == "-p" || sArg == "--port") { |
321 |
|
|
if (sVal.isNull()) { |
322 |
|
|
out << QObject::tr("Option -p requires an argument (port).") + sEol; |
323 |
|
|
return false; |
324 |
|
|
} |
325 |
|
|
iServerPort = sVal.toInt(); |
326 |
|
|
if (iEqual < 0) |
327 |
|
|
i++; |
328 |
|
|
} |
329 |
|
|
else if (sArg == "-?" || sArg == "--help") { |
330 |
capela |
1890 |
print_usage(args.at(0)); |
331 |
capela |
1509 |
return false; |
332 |
|
|
} |
333 |
|
|
else if (sArg == "-v" || sArg == "--version") { |
334 |
capela |
1499 |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
335 |
capela |
2642 |
#ifdef CONFIG_LIBGIG |
336 |
capela |
1499 |
out << QString("%1: %2\n") |
337 |
|
|
.arg(gig::libraryName().c_str()) |
338 |
|
|
.arg(gig::libraryVersion().c_str()); |
339 |
capela |
2642 |
#endif |
340 |
capela |
1499 |
out << QString("%1: %2\n") |
341 |
|
|
.arg(::lscp_client_package()) |
342 |
|
|
.arg(::lscp_client_version()); |
343 |
|
|
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
344 |
capela |
1509 |
return false; |
345 |
|
|
} |
346 |
|
|
else { |
347 |
|
|
// If we don't have one by now, |
348 |
|
|
// this will be the startup sesion file... |
349 |
|
|
sSessionFile += sArg; |
350 |
|
|
iCmdArgs++; |
351 |
|
|
} |
352 |
|
|
} |
353 |
capela |
106 |
|
354 |
capela |
1509 |
// Alright with argument parsing. |
355 |
|
|
return true; |
356 |
capela |
106 |
} |
357 |
|
|
|
358 |
|
|
|
359 |
|
|
//--------------------------------------------------------------------------- |
360 |
|
|
// Widget geometry persistence helper methods. |
361 |
|
|
|
362 |
capela |
2077 |
void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
363 |
capela |
106 |
{ |
364 |
capela |
1499 |
// Try to restore old form window positioning. |
365 |
|
|
if (pWidget) { |
366 |
capela |
2077 |
QPoint wpos; |
367 |
|
|
QSize wsize; |
368 |
capela |
1499 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
369 |
capela |
2077 |
wpos.setX(m_settings.value("/x", -1).toInt()); |
370 |
|
|
wpos.setY(m_settings.value("/y", -1).toInt()); |
371 |
|
|
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
372 |
|
|
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
373 |
|
|
if (!bVisible) bVisible = m_settings.value("/visible", false).toBool(); |
374 |
capela |
1499 |
m_settings.endGroup(); |
375 |
capela |
2077 |
if (wpos.x() > 0 && wpos.y() > 0) |
376 |
|
|
pWidget->move(wpos); |
377 |
|
|
if (wsize.width() > 0 && wsize.height() > 0) |
378 |
|
|
pWidget->resize(wsize); |
379 |
|
|
// else |
380 |
|
|
// pWidget->adjustSize(); |
381 |
capela |
1499 |
if (bVisible) |
382 |
|
|
pWidget->show(); |
383 |
capela |
2077 |
// else |
384 |
|
|
// pWidget->hide(); |
385 |
capela |
1499 |
} |
386 |
capela |
106 |
} |
387 |
|
|
|
388 |
|
|
|
389 |
capela |
2077 |
void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
390 |
capela |
106 |
{ |
391 |
capela |
1499 |
// Try to save form window position... |
392 |
|
|
// (due to X11 window managers ideossincrasies, we better |
393 |
|
|
// only save the form geometry while its up and visible) |
394 |
|
|
if (pWidget) { |
395 |
|
|
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
396 |
capela |
2077 |
const QPoint& wpos = pWidget->pos(); |
397 |
|
|
const QSize& wsize = pWidget->size(); |
398 |
|
|
if (!bVisible) bVisible = pWidget->isVisible(); |
399 |
|
|
m_settings.setValue("/x", wpos.x()); |
400 |
|
|
m_settings.setValue("/y", wpos.y()); |
401 |
|
|
m_settings.setValue("/width", wsize.width()); |
402 |
|
|
m_settings.setValue("/height", wsize.height()); |
403 |
capela |
1499 |
m_settings.setValue("/visible", bVisible); |
404 |
|
|
m_settings.endGroup(); |
405 |
|
|
} |
406 |
capela |
106 |
} |
407 |
|
|
|
408 |
|
|
|
409 |
|
|
//--------------------------------------------------------------------------- |
410 |
|
|
// Combo box history persistence helper implementation. |
411 |
|
|
|
412 |
capela |
1558 |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
413 |
capela |
106 |
{ |
414 |
capela |
1499 |
// Load combobox list from configuration settings file... |
415 |
|
|
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
416 |
capela |
106 |
|
417 |
capela |
1499 |
if (m_settings.childKeys().count() > 0) { |
418 |
|
|
pComboBox->setUpdatesEnabled(false); |
419 |
|
|
pComboBox->setDuplicatesEnabled(false); |
420 |
|
|
pComboBox->clear(); |
421 |
|
|
for (int i = 0; i < iLimit; i++) { |
422 |
|
|
const QString& sText = m_settings.value( |
423 |
|
|
"/Item" + QString::number(i + 1)).toString(); |
424 |
|
|
if (sText.isEmpty()) |
425 |
|
|
break; |
426 |
|
|
pComboBox->addItem(sText); |
427 |
|
|
} |
428 |
|
|
pComboBox->setUpdatesEnabled(true); |
429 |
|
|
} |
430 |
capela |
106 |
|
431 |
capela |
1499 |
m_settings.endGroup(); |
432 |
capela |
106 |
} |
433 |
|
|
|
434 |
|
|
|
435 |
capela |
1558 |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
436 |
capela |
106 |
{ |
437 |
capela |
1499 |
// Add current text as latest item... |
438 |
|
|
const QString& sCurrentText = pComboBox->currentText(); |
439 |
|
|
int iCount = pComboBox->count(); |
440 |
|
|
for (int i = 0; i < iCount; i++) { |
441 |
|
|
const QString& sText = pComboBox->itemText(i); |
442 |
|
|
if (sText == sCurrentText) { |
443 |
|
|
pComboBox->removeItem(i); |
444 |
|
|
iCount--; |
445 |
|
|
break; |
446 |
|
|
} |
447 |
|
|
} |
448 |
|
|
while (iCount >= iLimit) |
449 |
|
|
pComboBox->removeItem(--iCount); |
450 |
|
|
pComboBox->insertItem(0, sCurrentText); |
451 |
|
|
iCount++; |
452 |
capela |
106 |
|
453 |
capela |
1499 |
// Save combobox list to configuration settings file... |
454 |
|
|
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
455 |
|
|
for (int i = 0; i < iCount; i++) { |
456 |
|
|
const QString& sText = pComboBox->itemText(i); |
457 |
|
|
if (sText.isEmpty()) |
458 |
|
|
break; |
459 |
|
|
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
460 |
|
|
} |
461 |
|
|
m_settings.endGroup(); |
462 |
capela |
106 |
} |
463 |
|
|
|
464 |
schoenebeck |
1803 |
int Options::getMaxVoices() { |
465 |
|
|
#ifndef CONFIG_MAX_VOICES |
466 |
|
|
return -1; |
467 |
|
|
#else |
468 |
|
|
if (iMaxVoices > 0) return iMaxVoices; |
469 |
|
|
return getEffectiveMaxVoices(); |
470 |
|
|
#endif // CONFIG_MAX_VOICES |
471 |
|
|
} |
472 |
|
|
|
473 |
|
|
int Options::getEffectiveMaxVoices() { |
474 |
|
|
#ifndef CONFIG_MAX_VOICES |
475 |
|
|
return -1; |
476 |
|
|
#else |
477 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
478 |
|
|
if (!pMainForm || !pMainForm->client()) |
479 |
|
|
return -1; |
480 |
|
|
|
481 |
|
|
return ::lscp_get_voices(pMainForm->client()); |
482 |
|
|
#endif // CONFIG_MAX_VOICES |
483 |
|
|
} |
484 |
|
|
|
485 |
|
|
void Options::setMaxVoices(int iMaxVoices) { |
486 |
|
|
#ifdef CONFIG_MAX_VOICES |
487 |
|
|
if (iMaxVoices < 1) return; |
488 |
|
|
|
489 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
490 |
|
|
if (!pMainForm || !pMainForm->client()) |
491 |
|
|
return; |
492 |
|
|
|
493 |
|
|
lscp_status_t result = |
494 |
|
|
::lscp_set_voices(pMainForm->client(), iMaxVoices); |
495 |
|
|
|
496 |
|
|
if (result != LSCP_OK) { |
497 |
|
|
pMainForm->appendMessagesClient("lscp_set_voices"); |
498 |
|
|
return; |
499 |
|
|
} |
500 |
|
|
|
501 |
|
|
this->iMaxVoices = iMaxVoices; |
502 |
|
|
#endif // CONFIG_MAX_VOICES |
503 |
|
|
} |
504 |
|
|
|
505 |
|
|
int Options::getMaxStreams() { |
506 |
|
|
#ifndef CONFIG_MAX_VOICES |
507 |
|
|
return -1; |
508 |
|
|
#else |
509 |
|
|
if (iMaxStreams > 0) return iMaxStreams; |
510 |
|
|
return getEffectiveMaxStreams(); |
511 |
|
|
#endif // CONFIG_MAX_VOICES |
512 |
|
|
} |
513 |
|
|
|
514 |
|
|
int Options::getEffectiveMaxStreams() { |
515 |
|
|
#ifndef CONFIG_MAX_VOICES |
516 |
|
|
return -1; |
517 |
|
|
#else |
518 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
519 |
|
|
if (!pMainForm || !pMainForm->client()) |
520 |
|
|
return -1; |
521 |
|
|
|
522 |
|
|
return ::lscp_get_streams(pMainForm->client()); |
523 |
|
|
#endif // CONFIG_MAX_VOICES |
524 |
|
|
} |
525 |
|
|
|
526 |
|
|
void Options::setMaxStreams(int iMaxStreams) { |
527 |
|
|
#ifdef CONFIG_MAX_VOICES |
528 |
|
|
if (iMaxStreams < 0) return; |
529 |
|
|
|
530 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
531 |
|
|
if (!pMainForm || !pMainForm->client()) |
532 |
|
|
return; |
533 |
|
|
|
534 |
|
|
lscp_status_t result = |
535 |
|
|
::lscp_set_streams(pMainForm->client(), iMaxStreams); |
536 |
|
|
|
537 |
|
|
if (result != LSCP_OK) { |
538 |
|
|
pMainForm->appendMessagesClient("lscp_set_streams"); |
539 |
|
|
return; |
540 |
|
|
} |
541 |
|
|
|
542 |
|
|
this->iMaxStreams = iMaxStreams; |
543 |
|
|
#endif // CONFIG_MAX_VOICES |
544 |
|
|
} |
545 |
|
|
|
546 |
|
|
void Options::sendFineTuningSettings() { |
547 |
|
|
setMaxVoices(iMaxVoices); |
548 |
|
|
setMaxStreams(iMaxStreams); |
549 |
|
|
|
550 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
551 |
|
|
if (!pMainForm || !pMainForm->client()) |
552 |
|
|
return; |
553 |
|
|
|
554 |
|
|
pMainForm->appendMessages(QObject::tr("Sent fine tuning settings.")); |
555 |
|
|
} |
556 |
|
|
|
557 |
capela |
1558 |
} // namespace QSampler |
558 |
capela |
106 |
|
559 |
capela |
1558 |
|
560 |
capela |
106 |
// end of qsamplerOptions.cpp |