1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2022, 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 |
27 |
#include <QTextStream> |
#include <QTextStream> |
28 |
#include <QComboBox> |
#include <QComboBox> |
29 |
|
|
30 |
#include <lscp/client.h> |
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) |
31 |
|
#include <QCommandLineParser> |
32 |
|
#include <QCommandLineOption> |
33 |
|
#if defined(Q_OS_WINDOWS) |
34 |
|
#include <QMessageBox> |
35 |
|
#endif |
36 |
|
#endif |
37 |
|
|
38 |
|
#include <QApplication> |
39 |
|
|
40 |
#ifdef CONFIG_LIBGIG |
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
41 |
#include <gig.h> |
#include <QDesktopWidget> |
42 |
#endif |
#endif |
43 |
|
|
44 |
|
|
80 |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
81 |
#endif |
#endif |
82 |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
83 |
#if defined(__APPLE__) // Toshi Nagata 20080113 |
#if defined(__APPLE__) |
84 |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").toString(); |
sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString(); |
85 |
#else |
#else |
86 |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
87 |
#endif |
#endif |
105 |
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
106 |
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
107 |
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
108 |
|
bConfirmReset = m_settings.value("/ConfirmReset", true).toBool(); |
109 |
|
bConfirmRestart = m_settings.value("/ConfirmRestart", true).toBool(); |
110 |
|
bConfirmError = m_settings.value("/ConfirmError", true).toBool(); |
111 |
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
112 |
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
113 |
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
115 |
iBaseFontSize = m_settings.value("/BaseFontSize", 0).toInt(); |
iBaseFontSize = m_settings.value("/BaseFontSize", 0).toInt(); |
116 |
// 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 |
117 |
// .gig files, then we enable this feature by default |
// .gig files, then we enable this feature by default |
118 |
#if HAVE_LIBGIG_SETAUTOLOAD |
#ifdef CONFIG_LIBGIG_SETAUTOLOAD |
119 |
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
120 |
#else |
#else |
121 |
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
122 |
#endif |
#endif |
123 |
m_settings.endGroup(); |
m_settings.endGroup(); |
124 |
|
|
125 |
|
// Load custom options... |
126 |
|
m_settings.beginGroup("/Custom"); |
127 |
|
sCustomColorTheme = m_settings.value("/ColorTheme").toString(); |
128 |
|
sCustomStyleTheme = m_settings.value("/StyleTheme").toString(); |
129 |
|
m_settings.endGroup(); |
130 |
|
|
131 |
// And go into view options group. |
// And go into view options group. |
132 |
m_settings.beginGroup("/View"); |
m_settings.beginGroup("/View"); |
133 |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
176 |
{ |
{ |
177 |
// Make program version available in the future. |
// Make program version available in the future. |
178 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
179 |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", CONFIG_BUILD_VERSION); |
180 |
m_settings.endGroup(); |
m_settings.endGroup(); |
181 |
|
|
182 |
// And go into general options group. |
// And go into general options group. |
209 |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
210 |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
211 |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
212 |
|
m_settings.setValue("/ConfirmReset", bConfirmReset); |
213 |
|
m_settings.setValue("/ConfirmRestart", bConfirmRestart); |
214 |
|
m_settings.setValue("/ConfirmError", bConfirmError); |
215 |
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
216 |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
217 |
m_settings.setValue("/CompletePath", bCompletePath); |
m_settings.setValue("/CompletePath", bCompletePath); |
220 |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
221 |
m_settings.endGroup(); |
m_settings.endGroup(); |
222 |
|
|
223 |
|
// Save custom options... |
224 |
|
m_settings.beginGroup("/Custom"); |
225 |
|
m_settings.setValue("/ColorTheme", sCustomColorTheme); |
226 |
|
m_settings.setValue("/StyleTheme", sCustomStyleTheme); |
227 |
|
m_settings.endGroup(); |
228 |
|
|
229 |
// View options group. |
// View options group. |
230 |
m_settings.beginGroup("/View"); |
m_settings.beginGroup("/View"); |
231 |
m_settings.setValue("/Menubar", bMenubar); |
m_settings.setValue("/Menubar", bMenubar); |
285 |
// Command-line argument stuff. |
// Command-line argument stuff. |
286 |
// |
// |
287 |
|
|
288 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) |
289 |
|
|
290 |
|
void Options::show_error( const QString& msg ) |
291 |
|
{ |
292 |
|
#if defined(Q_OS_WINDOWS) |
293 |
|
QMessageBox::information(nullptr, QApplication::applicationName(), msg); |
294 |
|
#else |
295 |
|
const QByteArray tmp = msg.toUtf8() + '\n'; |
296 |
|
::fputs(tmp.constData(), stderr); |
297 |
|
#endif |
298 |
|
} |
299 |
|
|
300 |
|
#else |
301 |
|
|
302 |
// Help about command line options. |
// Help about command line options. |
303 |
void Options::print_usage ( const QString& arg0 ) |
void Options::print_usage ( const QString& arg0 ) |
304 |
{ |
{ |
305 |
QTextStream out(stderr); |
QTextStream out(stderr); |
306 |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
const QString sEot = "\n\t"; |
307 |
QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" |
const QString sEol = "\n\n"; |
308 |
"Options:\n\n" |
|
309 |
" -s, --start\n\tStart linuxsampler server locally\n\n" |
out << QObject::tr("Usage: %1 [options] [session-file]").arg(arg0) + sEol; |
310 |
" -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n" |
out << QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE) + sEol; |
311 |
" -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n" |
out << QObject::tr("Options:") + sEol; |
312 |
" -?, --help\n\tShow help about command line options\n\n" |
out << " -s, --start" + sEot + |
313 |
" -v, --version\n\tShow version information\n\n") |
QObject::tr("Start linuxsampler server locally.") + sEol; |
314 |
.arg(arg0); |
out << " -n, --hostname" + sEot + |
315 |
|
QObject::tr("Specify linuxsampler server hostname (default = localhost)") + sEol; |
316 |
|
out << " -p, --port" + sEot + |
317 |
|
QObject::tr("Specify linuxsampler server port number (default = 8888)") + sEol; |
318 |
|
out << " -h, --help" + sEot + |
319 |
|
QObject::tr("Show help about command line options.") + sEol; |
320 |
|
out << " -v, --version" + sEot + |
321 |
|
QObject::tr("Show version information") + sEol; |
322 |
} |
} |
323 |
|
|
324 |
|
#endif |
325 |
|
|
326 |
|
|
327 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
328 |
bool Options::parse_args ( const QStringList& args ) |
bool Options::parse_args ( const QStringList& args ) |
329 |
{ |
{ |
330 |
|
int iCmdArgs = 0; |
331 |
|
|
332 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) |
333 |
|
|
334 |
|
QCommandLineParser parser; |
335 |
|
parser.setApplicationDescription( |
336 |
|
QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE)); |
337 |
|
|
338 |
|
parser.addOption({{"s", "start"}, |
339 |
|
QObject::tr("Start linuxsampler server locally.")}); |
340 |
|
parser.addOption({{"n", "hostname"}, |
341 |
|
QObject::tr("Specify linuxsampler server hostname (default = localhost)"), "name"}); |
342 |
|
parser.addOption({{"p", "port"}, |
343 |
|
QObject::tr("Specify linuxsampler server port number (default = 8888)"), "num"}); |
344 |
|
parser.addHelpOption(); |
345 |
|
parser.addVersionOption(); |
346 |
|
parser.addPositionalArgument("session-file", |
347 |
|
QObject::tr("Session file (.lscp)"), |
348 |
|
QObject::tr("[session-file]")); |
349 |
|
parser.process(args); |
350 |
|
|
351 |
|
if (parser.isSet("start")) { |
352 |
|
bServerStart = true; |
353 |
|
} |
354 |
|
|
355 |
|
if (parser.isSet("hostname")) { |
356 |
|
const QString& sVal = parser.value("hostname"); |
357 |
|
if (sVal.isEmpty()) { |
358 |
|
show_error(QObject::tr("Option -n requires an argument (hostname).")); |
359 |
|
return false; |
360 |
|
} |
361 |
|
sServerHost = sVal; |
362 |
|
} |
363 |
|
|
364 |
|
if (parser.isSet("port")) { |
365 |
|
bool bOK = false; |
366 |
|
const int iVal = parser.value("port").toInt(&bOK); |
367 |
|
if (!bOK) { |
368 |
|
show_error(QObject::tr("Option -p requires an argument (port).")); |
369 |
|
return false; |
370 |
|
} |
371 |
|
iServerPort = iVal; |
372 |
|
} |
373 |
|
|
374 |
|
foreach(const QString& sArg, parser.positionalArguments()) { |
375 |
|
if (iCmdArgs > 0) |
376 |
|
sSessionFile += ' '; |
377 |
|
sSessionFile += sArg; |
378 |
|
++iCmdArgs; |
379 |
|
} |
380 |
|
|
381 |
|
#else |
382 |
|
|
383 |
QTextStream out(stderr); |
QTextStream out(stderr); |
384 |
const QString sEol = "\n\n"; |
const QString sEol = "\n\n"; |
|
int iCmdArgs = 0; |
|
385 |
const int argc = args.count(); |
const int argc = args.count(); |
386 |
|
|
387 |
for (int i = 1; i < argc; i++) { |
for (int i = 1; i < argc; ++i) { |
388 |
|
|
389 |
if (iCmdArgs > 0) { |
if (iCmdArgs > 0) { |
390 |
sSessionFile += " "; |
sSessionFile += " "; |
391 |
sSessionFile += args.at(i); |
sSessionFile += args.at(i); |
392 |
iCmdArgs++; |
++iCmdArgs; |
393 |
continue; |
continue; |
394 |
} |
} |
395 |
|
|
396 |
QString sArg = args.at(i); |
QString sArg = args.at(i); |
397 |
QString sVal = QString::null; |
QString sVal; |
398 |
const int iEqual = sArg.indexOf("="); |
const int iEqual = sArg.indexOf("="); |
399 |
if (iEqual >= 0) { |
if (iEqual >= 0) { |
400 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
sVal = sArg.right(sArg.length() - iEqual - 1); |
409 |
if (sArg == "-s" || sArg == "--start") { |
if (sArg == "-s" || sArg == "--start") { |
410 |
bServerStart = true; |
bServerStart = true; |
411 |
} |
} |
412 |
else if (sArg == "-h" || sArg == "--hostname") { |
else if (sArg == "-n" || sArg == "--hostname") { |
413 |
if (sVal.isNull()) { |
if (sVal.isNull()) { |
414 |
out << QObject::tr("Option -h requires an argument (host).") + sEol; |
out << QObject::tr("Option -n requires an argument (hostname).") + sEol; |
415 |
return false; |
return false; |
416 |
} |
} |
417 |
sServerHost = sVal; |
sServerHost = sVal; |
418 |
if (iEqual < 0) |
if (iEqual < 0) |
419 |
i++; |
++i; |
420 |
} |
} |
421 |
else if (sArg == "-p" || sArg == "--port") { |
else if (sArg == "-p" || sArg == "--port") { |
422 |
if (sVal.isNull()) { |
if (sVal.isNull()) { |
425 |
} |
} |
426 |
iServerPort = sVal.toInt(); |
iServerPort = sVal.toInt(); |
427 |
if (iEqual < 0) |
if (iEqual < 0) |
428 |
i++; |
++i; |
429 |
} |
} |
430 |
else if (sArg == "-?" || sArg == "--help") { |
else if (sArg == "-h" || sArg == "--help") { |
431 |
print_usage(args.at(0)); |
print_usage(args.at(0)); |
432 |
return false; |
return false; |
433 |
} |
} |
434 |
else if (sArg == "-v" || sArg == "--version") { |
else if (sArg == "-v" || sArg == "--version") { |
435 |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
out << QString("Qt: %1").arg(qVersion()); |
436 |
|
#if defined(QT_STATIC) |
437 |
|
out << "-static"; |
438 |
|
#endif |
439 |
|
out << '\n'; |
440 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
441 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
442 |
.arg(gig::libraryName().c_str()) |
.arg(gig::libraryName().c_str()) |
445 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
446 |
.arg(::lscp_client_package()) |
.arg(::lscp_client_package()) |
447 |
.arg(::lscp_client_version()); |
.arg(::lscp_client_version()); |
448 |
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
out << QString("%1: %2\n") |
449 |
|
.arg(QSAMPLER_TITLE) |
450 |
|
.arg(CONFIG_BUILD_VERSION); |
451 |
return false; |
return false; |
452 |
} |
} |
453 |
else { |
else { |
454 |
// If we don't have one by now, |
// If we don't have one by now, |
455 |
// this will be the startup sesion file... |
// this will be the startup sesion file... |
456 |
sSessionFile += sArg; |
sSessionFile += sArg; |
457 |
iCmdArgs++; |
++iCmdArgs; |
458 |
} |
} |
459 |
} |
} |
460 |
|
|
461 |
|
#endif |
462 |
|
|
463 |
// Alright with argument parsing. |
// Alright with argument parsing. |
464 |
return true; |
return true; |
465 |
} |
} |
472 |
{ |
{ |
473 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
474 |
if (pWidget) { |
if (pWidget) { |
475 |
|
// if (bVisible) pWidget->show(); -- force initial exposure? |
476 |
|
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
477 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
478 |
|
const QByteArray& geometry |
479 |
|
= m_settings.value("/geometry").toByteArray(); |
480 |
|
if (geometry.isEmpty()) { |
481 |
|
QWidget *pParent = pWidget->parentWidget(); |
482 |
|
if (pParent) |
483 |
|
pParent = pParent->window(); |
484 |
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
485 |
|
if (pParent == nullptr) |
486 |
|
pParent = QApplication::desktop(); |
487 |
|
#endif |
488 |
|
if (pParent) { |
489 |
|
QRect wrect(pWidget->geometry()); |
490 |
|
wrect.moveCenter(pParent->geometry().center()); |
491 |
|
pWidget->move(wrect.topLeft()); |
492 |
|
} |
493 |
|
} else { |
494 |
|
pWidget->restoreGeometry(geometry); |
495 |
|
} |
496 |
|
#else//--LOAD_OLD_GEOMETRY |
497 |
QPoint wpos; |
QPoint wpos; |
498 |
QSize wsize; |
QSize wsize; |
|
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
|
499 |
wpos.setX(m_settings.value("/x", -1).toInt()); |
wpos.setX(m_settings.value("/x", -1).toInt()); |
500 |
wpos.setY(m_settings.value("/y", -1).toInt()); |
wpos.setY(m_settings.value("/y", -1).toInt()); |
501 |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
502 |
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
wsize.setHeight(m_settings.value("/height", -1).toInt()); |
|
if (!bVisible) bVisible = m_settings.value("/visible", false).toBool(); |
|
|
m_settings.endGroup(); |
|
503 |
if (wpos.x() > 0 && wpos.y() > 0) |
if (wpos.x() > 0 && wpos.y() > 0) |
504 |
pWidget->move(wpos); |
pWidget->move(wpos); |
505 |
if (wsize.width() > 0 && wsize.height() > 0) |
if (wsize.width() > 0 && wsize.height() > 0) |
506 |
pWidget->resize(wsize); |
pWidget->resize(wsize); |
507 |
|
#endif |
508 |
// else |
// else |
509 |
// pWidget->adjustSize(); |
// pWidget->adjustSize(); |
510 |
|
if (!bVisible) |
511 |
|
bVisible = m_settings.value("/visible", false).toBool(); |
512 |
if (bVisible) |
if (bVisible) |
513 |
pWidget->show(); |
pWidget->show(); |
514 |
// else |
else |
515 |
// pWidget->hide(); |
pWidget->hide(); |
516 |
|
m_settings.endGroup(); |
517 |
} |
} |
518 |
} |
} |
519 |
|
|
525 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
526 |
if (pWidget) { |
if (pWidget) { |
527 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
528 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
529 |
|
m_settings.setValue("/geometry", pWidget->saveGeometry()); |
530 |
|
#else//--SAVE_OLD_GEOMETRY |
531 |
const QPoint& wpos = pWidget->pos(); |
const QPoint& wpos = pWidget->pos(); |
532 |
const QSize& wsize = pWidget->size(); |
const QSize& wsize = pWidget->size(); |
|
if (!bVisible) bVisible = pWidget->isVisible(); |
|
533 |
m_settings.setValue("/x", wpos.x()); |
m_settings.setValue("/x", wpos.x()); |
534 |
m_settings.setValue("/y", wpos.y()); |
m_settings.setValue("/y", wpos.y()); |
535 |
m_settings.setValue("/width", wsize.width()); |
m_settings.setValue("/width", wsize.width()); |
536 |
m_settings.setValue("/height", wsize.height()); |
m_settings.setValue("/height", wsize.height()); |
537 |
|
#endif |
538 |
|
if (!bVisible) bVisible = pWidget->isVisible(); |
539 |
m_settings.setValue("/visible", bVisible); |
m_settings.setValue("/visible", bVisible); |
540 |
m_settings.endGroup(); |
m_settings.endGroup(); |
541 |
} |
} |
547 |
|
|
548 |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
549 |
{ |
{ |
550 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
551 |
|
|
552 |
// Load combobox list from configuration settings file... |
// Load combobox list from configuration settings file... |
553 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
554 |
|
|
556 |
pComboBox->setUpdatesEnabled(false); |
pComboBox->setUpdatesEnabled(false); |
557 |
pComboBox->setDuplicatesEnabled(false); |
pComboBox->setDuplicatesEnabled(false); |
558 |
pComboBox->clear(); |
pComboBox->clear(); |
559 |
for (int i = 0; i < iLimit; i++) { |
for (int i = 0; i < iLimit; ++i) { |
560 |
const QString& sText = m_settings.value( |
const QString& sText = m_settings.value( |
561 |
"/Item" + QString::number(i + 1)).toString(); |
"/Item" + QString::number(i + 1)).toString(); |
562 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
567 |
} |
} |
568 |
|
|
569 |
m_settings.endGroup(); |
m_settings.endGroup(); |
570 |
|
|
571 |
|
pComboBox->blockSignals(bBlockSignals); |
572 |
} |
} |
573 |
|
|
574 |
|
|
575 |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
576 |
{ |
{ |
577 |
// Add current text as latest item... |
const bool bBlockSignals = pComboBox->blockSignals(true); |
578 |
const QString& sCurrentText = pComboBox->currentText(); |
|
579 |
int iCount = pComboBox->count(); |
int iCount = pComboBox->count(); |
580 |
for (int i = 0; i < iCount; i++) { |
|
581 |
const QString& sText = pComboBox->itemText(i); |
// Add current text as latest item (if not blank)... |
582 |
if (sText == sCurrentText) { |
const QString& sCurrentText = pComboBox->currentText(); |
583 |
pComboBox->removeItem(i); |
if (!sCurrentText.isEmpty()) { |
584 |
iCount--; |
for (int i = 0; i < iCount; ++i) { |
585 |
break; |
const QString& sText = pComboBox->itemText(i); |
586 |
|
if (sText == sCurrentText) { |
587 |
|
pComboBox->removeItem(i); |
588 |
|
--iCount; |
589 |
|
break; |
590 |
|
} |
591 |
} |
} |
592 |
|
pComboBox->insertItem(0, sCurrentText); |
593 |
|
pComboBox->setCurrentIndex(0); |
594 |
|
++iCount; |
595 |
} |
} |
596 |
|
|
597 |
while (iCount >= iLimit) |
while (iCount >= iLimit) |
598 |
pComboBox->removeItem(--iCount); |
pComboBox->removeItem(--iCount); |
|
pComboBox->insertItem(0, sCurrentText); |
|
|
iCount++; |
|
599 |
|
|
600 |
// Save combobox list to configuration settings file... |
// Save combobox list to configuration settings file... |
601 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
602 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; ++i) { |
603 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
604 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
605 |
break; |
break; |
606 |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
607 |
} |
} |
608 |
m_settings.endGroup(); |
m_settings.endGroup(); |
609 |
|
|
610 |
|
pComboBox->blockSignals(bBlockSignals); |
611 |
} |
} |
612 |
|
|
613 |
|
|
614 |
int Options::getMaxVoices() { |
int Options::getMaxVoices() { |
615 |
#ifndef CONFIG_MAX_VOICES |
#ifndef CONFIG_MAX_VOICES |
616 |
return -1; |
return -1; |
708 |
|
|
709 |
|
|
710 |
// end of qsamplerOptions.cpp |
// end of qsamplerOptions.cpp |
711 |
|
|