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