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