1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007,2008,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 |
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> |
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> |
#include <lscp/client.h> |
37 |
|
|
38 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
39 |
|
#pragma GCC diagnostic push |
40 |
|
#pragma GCC diagnostic ignored "-Wunused-parameter" |
41 |
#include <gig.h> |
#include <gig.h> |
42 |
|
#pragma GCC diagnostic pop |
43 |
#endif |
#endif |
44 |
|
|
45 |
|
|
53 |
Options::Options (void) |
Options::Options (void) |
54 |
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
: 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. |
// Begin into general options group. |
71 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Options"); |
72 |
|
|
74 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/Server"); |
75 |
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
76 |
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
77 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
78 |
// TODO: Should this be a configure option? |
// TODO: Should this be a configure option? |
79 |
iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt(); |
iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt(); |
80 |
#else |
#else |
81 |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
82 |
#endif |
#endif |
83 |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
84 |
#if defined(__APPLE__) // Toshi Nagata 20080113 |
#if defined(__APPLE__) |
85 |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").toString(); |
sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString(); |
86 |
#else |
#else |
87 |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
88 |
#endif |
#endif |
89 |
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
90 |
m_settings.endGroup(); |
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... |
// Load display options... |
99 |
m_settings.beginGroup("/Display"); |
m_settings.beginGroup("/Display"); |
100 |
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
106 |
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
107 |
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
108 |
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
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(); |
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
113 |
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
114 |
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
115 |
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
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 |
// if libgig provides a fast way to retrieve instrument names even for large |
118 |
// .gig files, then we enable this feature by default |
// .gig files, then we enable this feature by default |
119 |
#if HAVE_LIBGIG_SETAUTOLOAD |
#ifdef CONFIG_LIBGIG_SETAUTOLOAD |
120 |
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
121 |
#else |
#else |
122 |
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
123 |
#endif |
#endif |
124 |
m_settings.endGroup(); |
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. |
// And go into view options group. |
133 |
m_settings.beginGroup("/View"); |
m_settings.beginGroup("/View"); |
134 |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
150 |
} |
} |
151 |
m_settings.endGroup(); |
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. |
// Last but not least, get the default directories. |
160 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
161 |
sSessionDir = m_settings.value("/SessionDir").toString(); |
sSessionDir = m_settings.value("/SessionDir").toString(); |
172 |
} |
} |
173 |
|
|
174 |
|
|
175 |
// Default Destructor. |
// Explicit save method. |
176 |
Options::~Options (void) |
void Options::saveOptions (void) |
177 |
{ |
{ |
178 |
// Make program version available in the future. |
// Make program version available in the future. |
179 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
180 |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", CONFIG_BUILD_VERSION); |
181 |
m_settings.endGroup(); |
m_settings.endGroup(); |
182 |
|
|
183 |
// And go into general options group. |
// And go into general options group. |
193 |
m_settings.setValue("/StartDelay", iStartDelay); |
m_settings.setValue("/StartDelay", iStartDelay); |
194 |
m_settings.endGroup(); |
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. |
// Save display options. |
203 |
m_settings.beginGroup("/Display"); |
m_settings.beginGroup("/Display"); |
204 |
m_settings.setValue("/DisplayFont", sDisplayFont); |
m_settings.setValue("/DisplayFont", sDisplayFont); |
210 |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
211 |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
212 |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
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); |
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
217 |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
218 |
m_settings.setValue("/CompletePath", bCompletePath); |
m_settings.setValue("/CompletePath", bCompletePath); |
219 |
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
220 |
|
m_settings.setValue("/BaseFontSize", iBaseFontSize); |
221 |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
222 |
m_settings.endGroup(); |
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. |
// View options group. |
231 |
m_settings.beginGroup("/View"); |
m_settings.beginGroup("/View"); |
232 |
m_settings.setValue("/Menubar", bMenubar); |
m_settings.setValue("/Menubar", bMenubar); |
245 |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
246 |
m_settings.endGroup(); |
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. |
// Default directories. |
257 |
m_settings.beginGroup("/Default"); |
m_settings.beginGroup("/Default"); |
258 |
m_settings.setValue("/SessionDir", sSessionDir); |
m_settings.setValue("/SessionDir", sSessionDir); |
266 |
m_settings.setValue("/Volume", iVolume); |
m_settings.setValue("/Volume", iVolume); |
267 |
m_settings.setValue("/Loadmode", iLoadMode); |
m_settings.setValue("/Loadmode", iLoadMode); |
268 |
m_settings.endGroup(); |
m_settings.endGroup(); |
269 |
|
|
270 |
|
// Save/commit to disk. |
271 |
|
m_settings.sync(); |
272 |
} |
} |
273 |
|
|
274 |
|
|
275 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
276 |
// Settings accessor. |
// Settings accessor. |
277 |
// |
// |
287 |
// |
// |
288 |
|
|
289 |
// Help about command line options. |
// Help about command line options. |
290 |
void Options::print_usage ( const char *arg0 ) |
void Options::print_usage ( const QString& arg0 ) |
291 |
{ |
{ |
292 |
QTextStream out(stderr); |
QTextStream out(stderr); |
293 |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
294 |
QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" |
QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" |
295 |
"Options:\n\n" |
"Options:\n\n" |
296 |
" -s, --start\n\tStart linuxsampler server locally\n\n" |
" -s, --start\n\tStart linuxsampler server locally\n\n" |
297 |
" -h, --hostname\n\tSpecify linuxsampler server hostname\n\n" |
" -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n" |
298 |
" -p, --port\n\tSpecify linuxsampler server port number\n\n" |
" -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n" |
299 |
" -?, --help\n\tShow help about command line options\n\n" |
" -?, --help\n\tShow help about command line options\n\n" |
300 |
" -v, --version\n\tShow version information\n\n") |
" -v, --version\n\tShow version information\n\n") |
301 |
.arg(arg0); |
.arg(arg0); |
303 |
|
|
304 |
|
|
305 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
306 |
bool Options::parse_args ( int argc, char **argv ) |
bool Options::parse_args ( const QStringList& args ) |
307 |
{ |
{ |
308 |
QTextStream out(stderr); |
QTextStream out(stderr); |
309 |
const QString sEol = "\n\n"; |
const QString sEol = "\n\n"; |
310 |
|
const int argc = args.count(); |
311 |
int iCmdArgs = 0; |
int iCmdArgs = 0; |
312 |
|
|
313 |
for (int i = 1; i < argc; i++) { |
for (int i = 1; i < argc; ++i) { |
314 |
|
|
315 |
if (iCmdArgs > 0) { |
if (iCmdArgs > 0) { |
316 |
sSessionFile += " "; |
sSessionFile += " "; |
317 |
sSessionFile += argv[i]; |
sSessionFile += args.at(i); |
318 |
iCmdArgs++; |
++iCmdArgs; |
319 |
continue; |
continue; |
320 |
} |
} |
321 |
|
|
322 |
QString sArg = argv[i]; |
QString sArg = args.at(i); |
323 |
QString sVal = QString::null; |
QString sVal; |
324 |
int iEqual = sArg.indexOf("="); |
const int iEqual = sArg.indexOf("="); |
325 |
if (iEqual >= 0) { |
if (iEqual >= 0) { |
326 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
sVal = sArg.right(sArg.length() - iEqual - 1); |
327 |
sArg = sArg.left(iEqual); |
sArg = sArg.left(iEqual); |
328 |
} |
} |
329 |
else if (i < argc) |
else if (i < argc - 1) { |
330 |
sVal = argv[i + 1]; |
sVal = args.at(i + 1); |
331 |
|
if (sVal[0] == '-') |
332 |
|
sVal.clear(); |
333 |
|
} |
334 |
|
|
335 |
if (sArg == "-s" || sArg == "--start") { |
if (sArg == "-s" || sArg == "--start") { |
336 |
bServerStart = true; |
bServerStart = true; |
337 |
} |
} |
338 |
else if (sArg == "-h" || sArg == "--hostname") { |
else if (sArg == "-h" || sArg == "--hostname") { |
339 |
if (sVal.isNull()) { |
if (sVal.isNull()) { |
340 |
out << QObject::tr("Option -h requires an argument (hostname).") + sEol; |
out << QObject::tr("Option -h requires an argument (host).") + sEol; |
341 |
return false; |
return false; |
342 |
} |
} |
343 |
sServerHost = sVal; |
sServerHost = sVal; |
344 |
if (iEqual < 0) |
if (iEqual < 0) |
345 |
i++; |
++i; |
346 |
} |
} |
347 |
else if (sArg == "-p" || sArg == "--port") { |
else if (sArg == "-p" || sArg == "--port") { |
348 |
if (sVal.isNull()) { |
if (sVal.isNull()) { |
351 |
} |
} |
352 |
iServerPort = sVal.toInt(); |
iServerPort = sVal.toInt(); |
353 |
if (iEqual < 0) |
if (iEqual < 0) |
354 |
i++; |
++i; |
355 |
} |
} |
356 |
else if (sArg == "-?" || sArg == "--help") { |
else if (sArg == "-?" || sArg == "--help") { |
357 |
print_usage(argv[0]); |
print_usage(args.at(0)); |
358 |
return false; |
return false; |
359 |
} |
} |
360 |
else if (sArg == "-v" || sArg == "--version") { |
else if (sArg == "-v" || sArg == "--version") { |
361 |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
out << QString("Qt: %1").arg(qVersion()); |
362 |
#ifdef CONFIG_LIBGIG |
#if defined(QT_STATIC) |
363 |
|
out << "-static"; |
364 |
|
#endif |
365 |
|
out << '\n'; |
366 |
|
#ifdef CONFIG_LIBGIG |
367 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
368 |
.arg(gig::libraryName().c_str()) |
.arg(gig::libraryName().c_str()) |
369 |
.arg(gig::libraryVersion().c_str()); |
.arg(gig::libraryVersion().c_str()); |
370 |
#endif |
#endif |
371 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
372 |
.arg(::lscp_client_package()) |
.arg(::lscp_client_package()) |
373 |
.arg(::lscp_client_version()); |
.arg(::lscp_client_version()); |
374 |
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
out << QString("%1: %2\n") |
375 |
|
.arg(QSAMPLER_TITLE) |
376 |
|
.arg(CONFIG_BUILD_VERSION); |
377 |
return false; |
return false; |
378 |
} |
} |
379 |
else { |
else { |
380 |
// If we don't have one by now, |
// If we don't have one by now, |
381 |
// this will be the startup sesion file... |
// this will be the startup sesion file... |
382 |
sSessionFile += sArg; |
sSessionFile += sArg; |
383 |
iCmdArgs++; |
++iCmdArgs; |
384 |
} |
} |
385 |
} |
} |
386 |
|
|
392 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
393 |
// Widget geometry persistence helper methods. |
// Widget geometry persistence helper methods. |
394 |
|
|
395 |
void Options::loadWidgetGeometry ( QWidget *pWidget ) |
void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
396 |
{ |
{ |
397 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
398 |
if (pWidget) { |
if (pWidget) { |
399 |
QPoint fpos; |
// if (bVisible) pWidget->show(); -- force initial exposure? |
|
QSize fsize; |
|
|
bool bVisible; |
|
400 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
401 |
fpos.setX(m_settings.value("/x", -1).toInt()); |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
402 |
fpos.setY(m_settings.value("/y", -1).toInt()); |
const QByteArray& geometry |
403 |
fsize.setWidth(m_settings.value("/width", -1).toInt()); |
= m_settings.value("/geometry").toByteArray(); |
404 |
fsize.setHeight(m_settings.value("/height", -1).toInt()); |
if (geometry.isEmpty()) { |
405 |
bVisible = m_settings.value("/visible", false).toBool(); |
QWidget *pParent = pWidget->parentWidget(); |
406 |
m_settings.endGroup(); |
if (pParent) |
407 |
if (fpos.x() > 0 && fpos.y() > 0) |
pParent = pParent->window(); |
408 |
pWidget->move(fpos); |
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
409 |
if (fsize.width() > 0 && fsize.height() > 0) |
if (pParent == nullptr) |
410 |
pWidget->resize(fsize); |
pParent = QApplication::desktop(); |
411 |
else |
#endif |
412 |
pWidget->adjustSize(); |
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) |
if (bVisible) |
437 |
pWidget->show(); |
pWidget->show(); |
438 |
else |
else |
439 |
pWidget->hide(); |
pWidget->hide(); |
440 |
|
m_settings.endGroup(); |
441 |
} |
} |
442 |
} |
} |
443 |
|
|
444 |
|
|
445 |
void Options::saveWidgetGeometry ( QWidget *pWidget ) |
void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible ) |
446 |
{ |
{ |
447 |
// Try to save form window position... |
// Try to save form window position... |
448 |
// (due to X11 window managers ideossincrasies, we better |
// (due to X11 window managers ideossincrasies, we better |
449 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
450 |
if (pWidget) { |
if (pWidget) { |
451 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
452 |
bool bVisible = pWidget->isVisible(); |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
453 |
const QPoint& fpos = pWidget->pos(); |
m_settings.setValue("/geometry", pWidget->saveGeometry()); |
454 |
const QSize& fsize = pWidget->size(); |
#else//--SAVE_OLD_GEOMETRY |
455 |
m_settings.setValue("/x", fpos.x()); |
const QPoint& wpos = pWidget->pos(); |
456 |
m_settings.setValue("/y", fpos.y()); |
const QSize& wsize = pWidget->size(); |
457 |
m_settings.setValue("/width", fsize.width()); |
m_settings.setValue("/x", wpos.x()); |
458 |
m_settings.setValue("/height", fsize.height()); |
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); |
m_settings.setValue("/visible", bVisible); |
464 |
m_settings.endGroup(); |
m_settings.endGroup(); |
465 |
} |
} |
471 |
|
|
472 |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
473 |
{ |
{ |
474 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
475 |
|
|
476 |
// Load combobox list from configuration settings file... |
// Load combobox list from configuration settings file... |
477 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
478 |
|
|
480 |
pComboBox->setUpdatesEnabled(false); |
pComboBox->setUpdatesEnabled(false); |
481 |
pComboBox->setDuplicatesEnabled(false); |
pComboBox->setDuplicatesEnabled(false); |
482 |
pComboBox->clear(); |
pComboBox->clear(); |
483 |
for (int i = 0; i < iLimit; i++) { |
for (int i = 0; i < iLimit; ++i) { |
484 |
const QString& sText = m_settings.value( |
const QString& sText = m_settings.value( |
485 |
"/Item" + QString::number(i + 1)).toString(); |
"/Item" + QString::number(i + 1)).toString(); |
486 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
491 |
} |
} |
492 |
|
|
493 |
m_settings.endGroup(); |
m_settings.endGroup(); |
494 |
|
|
495 |
|
pComboBox->blockSignals(bBlockSignals); |
496 |
} |
} |
497 |
|
|
498 |
|
|
499 |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
500 |
{ |
{ |
501 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
502 |
|
|
503 |
// Add current text as latest item... |
// Add current text as latest item... |
504 |
const QString& sCurrentText = pComboBox->currentText(); |
const QString sCurrentText = pComboBox->currentText(); |
505 |
int iCount = pComboBox->count(); |
int iCount = pComboBox->count(); |
506 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; i++) { |
507 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
508 |
if (sText == sCurrentText) { |
if (sText == sCurrentText) { |
509 |
pComboBox->removeItem(i); |
pComboBox->removeItem(i); |
510 |
iCount--; |
--iCount; |
511 |
break; |
break; |
512 |
} |
} |
513 |
} |
} |
514 |
while (iCount >= iLimit) |
while (iCount >= iLimit) |
515 |
pComboBox->removeItem(--iCount); |
pComboBox->removeItem(--iCount); |
516 |
pComboBox->insertItem(0, sCurrentText); |
pComboBox->insertItem(0, sCurrentText); |
517 |
iCount++; |
pComboBox->setCurrentIndex(0); |
518 |
|
++iCount; |
519 |
|
|
520 |
// Save combobox list to configuration settings file... |
// Save combobox list to configuration settings file... |
521 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
522 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; ++i) { |
523 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
524 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
525 |
break; |
break; |
526 |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
527 |
} |
} |
528 |
m_settings.endGroup(); |
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 |
} // namespace QSampler |
628 |
|
|
629 |
|
|
630 |
// end of qsamplerOptions.cpp |
// end of qsamplerOptions.cpp |
631 |
|
|