/[svn]/qsampler/trunk/src/qsamplerOptions.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerOptions.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2712 by schoenebeck, Sun Jan 18 20:25:22 2015 UTC revision 3556 by capela, Thu Aug 15 09:09:21 2019 UTC
# Line 1  Line 1 
1  // qsamplerOptions.cpp  // qsamplerOptions.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, 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
# Line 97  void Options::loadOptions (void) Line 97  void Options::loadOptions (void)
97          bMessagesLimit   = m_settings.value("/MessagesLimit", true).toBool();          bMessagesLimit   = m_settings.value("/MessagesLimit", true).toBool();
98          iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt();          iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt();
99          bConfirmRemove   = m_settings.value("/ConfirmRemove", true).toBool();          bConfirmRemove   = m_settings.value("/ConfirmRemove", true).toBool();
100            bConfirmReset    = m_settings.value("/ConfirmReset", true).toBool();
101            bConfirmRestart  = m_settings.value("/ConfirmRestart", true).toBool();
102            bConfirmError    = m_settings.value("/ConfirmError", true).toBool();
103          bKeepOnTop       = m_settings.value("/KeepOnTop", true).toBool();          bKeepOnTop       = m_settings.value("/KeepOnTop", true).toBool();
104          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();
105          bCompletePath    = m_settings.value("/CompletePath", true).toBool();          bCompletePath    = m_settings.value("/CompletePath", true).toBool();
# Line 159  void Options::saveOptions (void) Line 162  void Options::saveOptions (void)
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.
# Line 192  void Options::saveOptions (void) Line 195  void Options::saveOptions (void)
195          m_settings.setValue("/MessagesLimit", bMessagesLimit);          m_settings.setValue("/MessagesLimit", bMessagesLimit);
196          m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines);          m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines);
197          m_settings.setValue("/ConfirmRemove", bConfirmRemove);          m_settings.setValue("/ConfirmRemove", bConfirmRemove);
198            m_settings.setValue("/ConfirmReset", bConfirmReset);
199            m_settings.setValue("/ConfirmRestart", bConfirmRestart);
200            m_settings.setValue("/ConfirmError", bConfirmError);
201          m_settings.setValue("/KeepOnTop", bKeepOnTop);          m_settings.setValue("/KeepOnTop", bKeepOnTop);
202          m_settings.setValue("/StdoutCapture", bStdoutCapture);          m_settings.setValue("/StdoutCapture", bStdoutCapture);
203          m_settings.setValue("/CompletePath", bCompletePath);          m_settings.setValue("/CompletePath", bCompletePath);
# Line 280  bool Options::parse_args ( const QString Line 286  bool Options::parse_args ( const QString
286  {  {
287          QTextStream out(stderr);          QTextStream out(stderr);
288          const QString sEol = "\n\n";          const QString sEol = "\n\n";
         int iCmdArgs = 0;  
289          const int argc = args.count();          const int argc = args.count();
290            int iCmdArgs = 0;
291    
292          for (int i = 1; i < argc; i++) {          for (int i = 1; i < argc; ++i) {
293    
294                  if (iCmdArgs > 0) {                  if (iCmdArgs > 0) {
295                          sSessionFile += " ";                          sSessionFile += " ";
296                          sSessionFile += args.at(i);                          sSessionFile += args.at(i);
297                          iCmdArgs++;                          ++iCmdArgs;
298                          continue;                          continue;
299                  }                  }
300    
301                  QString sArg = args.at(i);                  QString sArg = args.at(i);
302                  QString sVal = QString::null;                  QString sVal;
303                  const int iEqual = sArg.indexOf("=");                  const int iEqual = sArg.indexOf("=");
304                  if (iEqual >= 0) {                  if (iEqual >= 0) {
305                          sVal = sArg.right(sArg.length() - iEqual - 1);                          sVal = sArg.right(sArg.length() - iEqual - 1);
# Line 315  bool Options::parse_args ( const QString Line 321  bool Options::parse_args ( const QString
321                          }                          }
322                          sServerHost = sVal;                          sServerHost = sVal;
323                          if (iEqual < 0)                          if (iEqual < 0)
324                                  i++;                                  ++i;
325                  }                  }
326                  else if (sArg == "-p" || sArg == "--port") {                  else if (sArg == "-p" || sArg == "--port") {
327                          if (sVal.isNull()) {                          if (sVal.isNull()) {
# Line 324  bool Options::parse_args ( const QString Line 330  bool Options::parse_args ( const QString
330                          }                          }
331                          iServerPort = sVal.toInt();                          iServerPort = sVal.toInt();
332                          if (iEqual < 0)                          if (iEqual < 0)
333                                  i++;                                  ++i;
334                  }                  }
335                  else if (sArg == "-?" || sArg == "--help") {                  else if (sArg == "-?" || sArg == "--help") {
336                          print_usage(args.at(0));                          print_usage(args.at(0));
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())
# Line 340  bool Options::parse_args ( const QString Line 350  bool Options::parse_args ( const QString
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 {
356                          // If we don't have one by now,                          // If we don't have one by now,
357                          // this will be the startup sesion file...                          // this will be the startup sesion file...
358                          sSessionFile += sArg;                          sSessionFile += sArg;
359                          iCmdArgs++;                          ++iCmdArgs;
360                  }                  }
361          }          }
362    
# Line 363  void Options::loadWidgetGeometry ( QWidg Line 372  void Options::loadWidgetGeometry ( QWidg
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 >= QT_VERSION_CHECK(5, 0, 0)
378                    const QByteArray& geometry
379                            = m_settings.value("/geometry").toByteArray();
380                    if (!geometry.isEmpty())
381                            pWidget->restoreGeometry(geometry);
382            #else//--LOAD_OLD_GEOMETRY
383                  QPoint wpos;                  QPoint wpos;
384                  QSize  wsize;                  QSize  wsize;
                 m_settings.beginGroup("/Geometry/" + pWidget->objectName());  
385                  wpos.setX(m_settings.value("/x", -1).toInt());                  wpos.setX(m_settings.value("/x", -1).toInt());
386                  wpos.setY(m_settings.value("/y", -1).toInt());                  wpos.setY(m_settings.value("/y", -1).toInt());
387                  wsize.setWidth(m_settings.value("/width", -1).toInt());                  wsize.setWidth(m_settings.value("/width", -1).toInt());
388                  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();  
389                  if (wpos.x() > 0 && wpos.y() > 0)                  if (wpos.x() > 0 && wpos.y() > 0)
390                          pWidget->move(wpos);                          pWidget->move(wpos);
391                  if (wsize.width() > 0 && wsize.height() > 0)                  if (wsize.width() > 0 && wsize.height() > 0)
392                          pWidget->resize(wsize);                          pWidget->resize(wsize);
393            #endif
394          //      else          //      else
395          //              pWidget->adjustSize();          //      pWidget->adjustSize();
396                    if (!bVisible)
397                            bVisible = m_settings.value("/visible", false).toBool();
398                  if (bVisible)                  if (bVisible)
399                          pWidget->show();                          pWidget->show();
400          //      else                  else
401          //              pWidget->hide();                          pWidget->hide();
402                    m_settings.endGroup();
403          }          }
404  }  }
405    
# Line 393  void Options::saveWidgetGeometry ( QWidg Line 411  void Options::saveWidgetGeometry ( QWidg
411          // only save the form geometry while its up and visible)          // only save the form geometry while its up and visible)
412          if (pWidget) {          if (pWidget) {
413                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
414            #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
415                    m_settings.setValue("/geometry", pWidget->saveGeometry());
416            #else//--SAVE_OLD_GEOMETRY
417                  const QPoint& wpos  = pWidget->pos();                  const QPoint& wpos  = pWidget->pos();
418                  const QSize&  wsize = pWidget->size();                  const QSize&  wsize = pWidget->size();
                 if (!bVisible) bVisible = pWidget->isVisible();  
419                  m_settings.setValue("/x", wpos.x());                  m_settings.setValue("/x", wpos.x());
420                  m_settings.setValue("/y", wpos.y());                  m_settings.setValue("/y", wpos.y());
421                  m_settings.setValue("/width", wsize.width());                  m_settings.setValue("/width", wsize.width());
422                  m_settings.setValue("/height", wsize.height());                  m_settings.setValue("/height", wsize.height());
423            #endif
424                    if (!bVisible) bVisible = pWidget->isVisible();
425                  m_settings.setValue("/visible", bVisible);                  m_settings.setValue("/visible", bVisible);
426                  m_settings.endGroup();                  m_settings.endGroup();
427          }          }
# Line 411  void Options::saveWidgetGeometry ( QWidg Line 433  void Options::saveWidgetGeometry ( QWidg
433    
434  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )
435  {  {
436            const bool bBlockSignals = pComboBox->blockSignals(true);
437    
438          // Load combobox list from configuration settings file...          // Load combobox list from configuration settings file...
439          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
440    
# Line 418  void Options::loadComboBoxHistory ( QCom Line 442  void Options::loadComboBoxHistory ( QCom
442                  pComboBox->setUpdatesEnabled(false);                  pComboBox->setUpdatesEnabled(false);
443                  pComboBox->setDuplicatesEnabled(false);                  pComboBox->setDuplicatesEnabled(false);
444                  pComboBox->clear();                  pComboBox->clear();
445                  for (int i = 0; i < iLimit; i++) {                  for (int i = 0; i < iLimit; ++i) {
446                          const QString& sText = m_settings.value(                          const QString& sText = m_settings.value(
447                                  "/Item" + QString::number(i + 1)).toString();                                  "/Item" + QString::number(i + 1)).toString();
448                          if (sText.isEmpty())                          if (sText.isEmpty())
# Line 429  void Options::loadComboBoxHistory ( QCom Line 453  void Options::loadComboBoxHistory ( QCom
453          }          }
454    
455          m_settings.endGroup();          m_settings.endGroup();
456    
457            pComboBox->blockSignals(bBlockSignals);
458  }  }
459    
460    
461  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
462  {  {
463            const bool bBlockSignals = pComboBox->blockSignals(true);
464    
465          // Add current text as latest item...          // Add current text as latest item...
466          const QString& sCurrentText = pComboBox->currentText();          const QString sCurrentText = pComboBox->currentText();
467          int iCount = pComboBox->count();          int iCount = pComboBox->count();
468          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; i++) {
469                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
470                  if (sText == sCurrentText) {                  if (sText == sCurrentText) {
471                          pComboBox->removeItem(i);                          pComboBox->removeItem(i);
472                          iCount--;                          --iCount;
473                          break;                          break;
474                  }                  }
475          }          }
476          while (iCount >= iLimit)          while (iCount >= iLimit)
477                  pComboBox->removeItem(--iCount);                  pComboBox->removeItem(--iCount);
478          pComboBox->insertItem(0, sCurrentText);          pComboBox->insertItem(0, sCurrentText);
479          iCount++;          pComboBox->setCurrentIndex(0);
480            ++iCount;
481    
482          // Save combobox list to configuration settings file...          // Save combobox list to configuration settings file...
483          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
484          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; ++i) {
485                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
486                  if (sText.isEmpty())                  if (sText.isEmpty())
487                          break;                          break;
488                  m_settings.setValue("/Item" + QString::number(i + 1), sText);                  m_settings.setValue("/Item" + QString::number(i + 1), sText);
489          }          }
490          m_settings.endGroup();          m_settings.endGroup();
491    
492            pComboBox->blockSignals(bBlockSignals);
493  }  }
494    
495    
496  int Options::getMaxVoices() {  int Options::getMaxVoices() {
497  #ifndef CONFIG_MAX_VOICES  #ifndef CONFIG_MAX_VOICES
498          return -1;          return -1;
# Line 558  void Options::sendFineTuningSettings() { Line 590  void Options::sendFineTuningSettings() {
590    
591    
592  // end of qsamplerOptions.cpp  // end of qsamplerOptions.cpp
593    

Legend:
Removed from v.2712  
changed lines
  Added in v.3556

  ViewVC Help
Powered by ViewVC