--- qsampler/trunk/src/qsamplerOptions.cpp 2009/11/04 18:59:57 2028 +++ qsampler/trunk/src/qsamplerOptions.cpp 2015/09/17 20:43:47 2843 @@ -1,8 +1,8 @@ // qsamplerOptions.cpp // /**************************************************************************** - Copyright (C) 2004-2009, rncbc aka Rui Nuno Capela. All rights reserved. - Copyright (C) 2007, Christian Schoenebeck + Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2007,2015 Christian Schoenebeck This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -65,18 +65,18 @@ m_settings.beginGroup("/Server"); sServerHost = m_settings.value("/ServerHost", "localhost").toString(); iServerPort = m_settings.value("/ServerPort", 8888).toInt(); - #if defined(__APPLE__) // Toshi Nagata 20080105 +#if defined(__APPLE__) // Toshi Nagata 20080105 // TODO: Should this be a configure option? iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt(); - #else +#else iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); - #endif +#endif bServerStart = m_settings.value("/ServerStart", true).toBool(); - #if defined(__APPLE__) // Toshi Nagata 20080113 - sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").toString(); - #else +#if defined(__APPLE__) + sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString(); +#else sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); - #endif +#endif iStartDelay = m_settings.value("/StartDelay", 3).toInt(); m_settings.endGroup(); @@ -97,6 +97,9 @@ bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); + bConfirmReset = m_settings.value("/ConfirmReset", true).toBool(); + bConfirmRestart = m_settings.value("/ConfirmRestart", true).toBool(); + bConfirmError = m_settings.value("/ConfirmError", true).toBool(); bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); bCompletePath = m_settings.value("/CompletePath", true).toBool(); @@ -104,7 +107,7 @@ iBaseFontSize = m_settings.value("/BaseFontSize", 0).toInt(); // if libgig provides a fast way to retrieve instrument names even for large // .gig files, then we enable this feature by default -#if HAVE_LIBGIG_SETAUTOLOAD +#ifdef CONFIG_LIBGIG_SETAUTOLOAD bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); #else bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); @@ -192,6 +195,9 @@ m_settings.setValue("/MessagesLimit", bMessagesLimit); m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); m_settings.setValue("/ConfirmRemove", bConfirmRemove); + m_settings.setValue("/ConfirmReset", bConfirmReset); + m_settings.setValue("/ConfirmRestart", bConfirmRestart); + m_settings.setValue("/ConfirmError", bConfirmError); m_settings.setValue("/KeepOnTop", bKeepOnTop); m_settings.setValue("/StdoutCapture", bStdoutCapture); m_settings.setValue("/CompletePath", bCompletePath); @@ -267,8 +273,8 @@ QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" "Options:\n\n" " -s, --start\n\tStart linuxsampler server locally\n\n" - " -h, --hostname\n\tSpecify linuxsampler server hostname\n\n" - " -p, --port\n\tSpecify linuxsampler server port number\n\n" + " -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n" + " -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n" " -?, --help\n\tShow help about command line options\n\n" " -v, --version\n\tShow version information\n\n") .arg(arg0); @@ -281,7 +287,7 @@ QTextStream out(stderr); const QString sEol = "\n\n"; int iCmdArgs = 0; - int argc = args.count(); + const int argc = args.count(); for (int i = 1; i < argc; i++) { @@ -294,20 +300,23 @@ QString sArg = args.at(i); QString sVal = QString::null; - int iEqual = sArg.indexOf("="); + const int iEqual = sArg.indexOf("="); if (iEqual >= 0) { sVal = sArg.right(sArg.length() - iEqual - 1); sArg = sArg.left(iEqual); } - else if (i < argc - 1) + else if (i < argc - 1) { sVal = args.at(i + 1); + if (sVal[0] == '-') + sVal.clear(); + } if (sArg == "-s" || sArg == "--start") { bServerStart = true; } else if (sArg == "-h" || sArg == "--hostname") { if (sVal.isNull()) { - out << QObject::tr("Option -h requires an argument (hostname).") + sEol; + out << QObject::tr("Option -h requires an argument (host).") + sEol; return false; } sServerHost = sVal; @@ -329,11 +338,11 @@ } else if (sArg == "-v" || sArg == "--version") { out << QObject::tr("Qt: %1\n").arg(qVersion()); -#ifdef CONFIG_LIBGIG + #ifdef CONFIG_LIBGIG out << QString("%1: %2\n") .arg(gig::libraryName().c_str()) .arg(gig::libraryVersion().c_str()); -#endif + #endif out << QString("%1: %2\n") .arg(::lscp_client_package()) .arg(::lscp_client_version()); @@ -356,48 +365,60 @@ //--------------------------------------------------------------------------- // Widget geometry persistence helper methods. -void Options::loadWidgetGeometry ( QWidget *pWidget ) +void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible ) { // Try to restore old form window positioning. if (pWidget) { - QPoint fpos; - QSize fsize; - bool bVisible; m_settings.beginGroup("/Geometry/" + pWidget->objectName()); - fpos.setX(m_settings.value("/x", -1).toInt()); - fpos.setY(m_settings.value("/y", -1).toInt()); - fsize.setWidth(m_settings.value("/width", -1).toInt()); - fsize.setHeight(m_settings.value("/height", -1).toInt()); - bVisible = m_settings.value("/visible", false).toBool(); - m_settings.endGroup(); - if (fpos.x() > 0 && fpos.y() > 0) - pWidget->move(fpos); - if (fsize.width() > 0 && fsize.height() > 0) - pWidget->resize(fsize); + #if QT_VERSION >= 0x050000 + const QByteArray& geometry + = m_settings.value("/geometry").toByteArray(); + if (!geometry.isEmpty()) + pWidget->restoreGeometry(geometry); else - pWidget->adjustSize(); + #else//--LOAD_OLD_GEOMETRY + QPoint wpos; + QSize wsize; + wpos.setX(m_settings.value("/x", -1).toInt()); + wpos.setY(m_settings.value("/y", -1).toInt()); + wsize.setWidth(m_settings.value("/width", -1).toInt()); + wsize.setHeight(m_settings.value("/height", -1).toInt()); + if (wpos.x() > 0 && wpos.y() > 0) + pWidget->move(wpos); + if (wsize.width() > 0 && wsize.height() > 0) + pWidget->resize(wsize); + else + #endif + pWidget->adjustSize(); + if (!bVisible) + bVisible = m_settings.value("/visible", false).toBool(); if (bVisible) pWidget->show(); else pWidget->hide(); + m_settings.endGroup(); } } -void Options::saveWidgetGeometry ( QWidget *pWidget ) +void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible ) { // Try to save form window position... // (due to X11 window managers ideossincrasies, we better // only save the form geometry while its up and visible) if (pWidget) { m_settings.beginGroup("/Geometry/" + pWidget->objectName()); - bool bVisible = pWidget->isVisible(); - const QPoint& fpos = pWidget->pos(); - const QSize& fsize = pWidget->size(); - m_settings.setValue("/x", fpos.x()); - m_settings.setValue("/y", fpos.y()); - m_settings.setValue("/width", fsize.width()); - m_settings.setValue("/height", fsize.height()); + #if QT_VERSION >= 0x050000 + m_settings.setValue("/geometry", pWidget->saveGeometry()); + #else//--SAVE_OLD_GEOMETRY + const QPoint& wpos = pWidget->pos(); + const QSize& wsize = pWidget->size(); + m_settings.setValue("/x", wpos.x()); + m_settings.setValue("/y", wpos.y()); + m_settings.setValue("/width", wsize.width()); + m_settings.setValue("/height", wsize.height()); + #endif + if (!bVisible) bVisible = pWidget->isVisible(); m_settings.setValue("/visible", bVisible); m_settings.endGroup(); } @@ -409,6 +430,8 @@ void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) { + const bool bBlockSignals = pComboBox->blockSignals(true); + // Load combobox list from configuration settings file... m_settings.beginGroup("/History/" + pComboBox->objectName()); @@ -416,7 +439,7 @@ pComboBox->setUpdatesEnabled(false); pComboBox->setDuplicatesEnabled(false); pComboBox->clear(); - for (int i = 0; i < iLimit; i++) { + for (int i = 0; i < iLimit; ++i) { const QString& sText = m_settings.value( "/Item" + QString::number(i + 1)).toString(); if (sText.isEmpty()) @@ -427,38 +450,46 @@ } m_settings.endGroup(); + + pComboBox->blockSignals(bBlockSignals); } void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) { + const bool bBlockSignals = pComboBox->blockSignals(true); + // Add current text as latest item... - const QString& sCurrentText = pComboBox->currentText(); + const QString sCurrentText = pComboBox->currentText(); int iCount = pComboBox->count(); for (int i = 0; i < iCount; i++) { const QString& sText = pComboBox->itemText(i); if (sText == sCurrentText) { pComboBox->removeItem(i); - iCount--; + --iCount; break; } } while (iCount >= iLimit) pComboBox->removeItem(--iCount); pComboBox->insertItem(0, sCurrentText); - iCount++; + pComboBox->setCurrentIndex(0); + ++iCount; // Save combobox list to configuration settings file... m_settings.beginGroup("/History/" + pComboBox->objectName()); - for (int i = 0; i < iCount; i++) { + for (int i = 0; i < iCount; ++i) { const QString& sText = pComboBox->itemText(i); if (sText.isEmpty()) break; m_settings.setValue("/Item" + QString::number(i + 1), sText); } m_settings.endGroup(); + + pComboBox->blockSignals(bBlockSignals); } + int Options::getMaxVoices() { #ifndef CONFIG_MAX_VOICES return -1;