1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2016, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007,2015 Christian Schoenebeck |
Copyright (C) 2007,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 |
162 |
{ |
{ |
163 |
// Make program version available in the future. |
// Make program version available in the future. |
164 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
165 |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", CONFIG_BUILD_VERSION); |
166 |
m_settings.endGroup(); |
m_settings.endGroup(); |
167 |
|
|
168 |
// And go into general options group. |
// And go into general options group. |
337 |
return false; |
return false; |
338 |
} |
} |
339 |
else if (sArg == "-v" || sArg == "--version") { |
else if (sArg == "-v" || sArg == "--version") { |
340 |
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
out << QString("Qt: %1\n") |
341 |
|
.arg(qVersion()); |
342 |
|
out << QString("%1: %2\n") |
343 |
|
.arg(QSAMPLER_TITLE) |
344 |
|
.arg(CONFIG_BUILD_VERSION); |
345 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
346 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
347 |
.arg(gig::libraryName().c_str()) |
.arg(gig::libraryName().c_str()) |
350 |
out << QString("%1: %2\n") |
out << QString("%1: %2\n") |
351 |
.arg(::lscp_client_package()) |
.arg(::lscp_client_package()) |
352 |
.arg(::lscp_client_version()); |
.arg(::lscp_client_version()); |
|
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
|
353 |
return false; |
return false; |
354 |
} |
} |
355 |
else { |
else { |
372 |
{ |
{ |
373 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
374 |
if (pWidget) { |
if (pWidget) { |
375 |
|
// if (bVisible) pWidget->show(); -- force initial exposure? |
376 |
|
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
377 |
|
#if QT_VERSION >= 0x050000 |
378 |
|
const QByteArray& geometry |
379 |
|
= m_settings.value("/geometry").toByteArray(); |
380 |
|
if (!geometry.isEmpty()) |
381 |
|
pWidget->restoreGeometry(geometry); |
382 |
|
else |
383 |
|
#else//--LOAD_OLD_GEOMETRY |
384 |
QPoint wpos; |
QPoint wpos; |
385 |
QSize wsize; |
QSize wsize; |
|
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
|
386 |
wpos.setX(m_settings.value("/x", -1).toInt()); |
wpos.setX(m_settings.value("/x", -1).toInt()); |
387 |
wpos.setY(m_settings.value("/y", -1).toInt()); |
wpos.setY(m_settings.value("/y", -1).toInt()); |
388 |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
wsize.setWidth(m_settings.value("/width", -1).toInt()); |
389 |
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(); |
|
390 |
if (wpos.x() > 0 && wpos.y() > 0) |
if (wpos.x() > 0 && wpos.y() > 0) |
391 |
pWidget->move(wpos); |
pWidget->move(wpos); |
392 |
if (wsize.width() > 0 && wsize.height() > 0) |
if (wsize.width() > 0 && wsize.height() > 0) |
393 |
pWidget->resize(wsize); |
pWidget->resize(wsize); |
394 |
// else |
else |
395 |
// pWidget->adjustSize(); |
#endif |
396 |
|
pWidget->adjustSize(); |
397 |
|
if (!bVisible) |
398 |
|
bVisible = m_settings.value("/visible", false).toBool(); |
399 |
if (bVisible) |
if (bVisible) |
400 |
pWidget->show(); |
pWidget->show(); |
401 |
// else |
else |
402 |
// pWidget->hide(); |
pWidget->hide(); |
403 |
|
m_settings.endGroup(); |
404 |
} |
} |
405 |
} |
} |
406 |
|
|
412 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
413 |
if (pWidget) { |
if (pWidget) { |
414 |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
415 |
|
#if QT_VERSION >= 0x050000 |
416 |
|
m_settings.setValue("/geometry", pWidget->saveGeometry()); |
417 |
|
#else//--SAVE_OLD_GEOMETRY |
418 |
const QPoint& wpos = pWidget->pos(); |
const QPoint& wpos = pWidget->pos(); |
419 |
const QSize& wsize = pWidget->size(); |
const QSize& wsize = pWidget->size(); |
|
if (!bVisible) bVisible = pWidget->isVisible(); |
|
420 |
m_settings.setValue("/x", wpos.x()); |
m_settings.setValue("/x", wpos.x()); |
421 |
m_settings.setValue("/y", wpos.y()); |
m_settings.setValue("/y", wpos.y()); |
422 |
m_settings.setValue("/width", wsize.width()); |
m_settings.setValue("/width", wsize.width()); |
423 |
m_settings.setValue("/height", wsize.height()); |
m_settings.setValue("/height", wsize.height()); |
424 |
|
#endif |
425 |
|
if (!bVisible) bVisible = pWidget->isVisible(); |
426 |
m_settings.setValue("/visible", bVisible); |
m_settings.setValue("/visible", bVisible); |
427 |
m_settings.endGroup(); |
m_settings.endGroup(); |
428 |
} |
} |
434 |
|
|
435 |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
436 |
{ |
{ |
437 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
438 |
|
|
439 |
// Load combobox list from configuration settings file... |
// Load combobox list from configuration settings file... |
440 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
441 |
|
|
443 |
pComboBox->setUpdatesEnabled(false); |
pComboBox->setUpdatesEnabled(false); |
444 |
pComboBox->setDuplicatesEnabled(false); |
pComboBox->setDuplicatesEnabled(false); |
445 |
pComboBox->clear(); |
pComboBox->clear(); |
446 |
for (int i = 0; i < iLimit; i++) { |
for (int i = 0; i < iLimit; ++i) { |
447 |
const QString& sText = m_settings.value( |
const QString& sText = m_settings.value( |
448 |
"/Item" + QString::number(i + 1)).toString(); |
"/Item" + QString::number(i + 1)).toString(); |
449 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
454 |
} |
} |
455 |
|
|
456 |
m_settings.endGroup(); |
m_settings.endGroup(); |
457 |
|
|
458 |
|
pComboBox->blockSignals(bBlockSignals); |
459 |
} |
} |
460 |
|
|
461 |
|
|
462 |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
463 |
{ |
{ |
464 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
465 |
|
|
466 |
// Add current text as latest item... |
// Add current text as latest item... |
467 |
const QString& sCurrentText = pComboBox->currentText(); |
const QString sCurrentText = pComboBox->currentText(); |
468 |
int iCount = pComboBox->count(); |
int iCount = pComboBox->count(); |
469 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; i++) { |
470 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
471 |
if (sText == sCurrentText) { |
if (sText == sCurrentText) { |
472 |
pComboBox->removeItem(i); |
pComboBox->removeItem(i); |
473 |
iCount--; |
--iCount; |
474 |
break; |
break; |
475 |
} |
} |
476 |
} |
} |
477 |
while (iCount >= iLimit) |
while (iCount >= iLimit) |
478 |
pComboBox->removeItem(--iCount); |
pComboBox->removeItem(--iCount); |
479 |
pComboBox->insertItem(0, sCurrentText); |
pComboBox->insertItem(0, sCurrentText); |
480 |
iCount++; |
pComboBox->setCurrentIndex(0); |
481 |
|
++iCount; |
482 |
|
|
483 |
// Save combobox list to configuration settings file... |
// Save combobox list to configuration settings file... |
484 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
485 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; ++i) { |
486 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
487 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
488 |
break; |
break; |
489 |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
490 |
} |
} |
491 |
m_settings.endGroup(); |
m_settings.endGroup(); |
492 |
|
|
493 |
|
pComboBox->blockSignals(bBlockSignals); |
494 |
} |
} |
495 |
|
|
496 |
|
|
497 |
int Options::getMaxVoices() { |
int Options::getMaxVoices() { |
498 |
#ifndef CONFIG_MAX_VOICES |
#ifndef CONFIG_MAX_VOICES |
499 |
return -1; |
return -1; |