/[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 2646 by capela, Wed Jun 18 08:39:54 2014 UTC revision 2779 by capela, Mon Jun 15 14:11:33 2015 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-2015, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 72  void Options::loadOptions (void) Line 72  void Options::loadOptions (void)
72          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();
73  #endif  #endif
74          bServerStart   = m_settings.value("/ServerStart", true).toBool();          bServerStart   = m_settings.value("/ServerStart", true).toBool();
75  #if defined(__APPLE__)  //  Toshi Nagata 20080113  #if defined(__APPLE__)
76          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").toString();          sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString();
77  #else  #else
78          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();
79  #endif  #endif
# 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 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 363  void Options::loadWidgetGeometry ( QWidg Line 369  void Options::loadWidgetGeometry ( QWidg
369  {  {
370          // Try to restore old form window positioning.          // Try to restore old form window positioning.
371          if (pWidget) {          if (pWidget) {
                 QPoint wpos;  
                 QSize  wsize;  
372                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
373                  wpos.setX(m_settings.value("/x", -1).toInt());                  const QByteArray& geometry
374                  wpos.setY(m_settings.value("/y", -1).toInt());                          = m_settings.value("/geometry").toByteArray();
375                  wsize.setWidth(m_settings.value("/width", -1).toInt());                  if (!geometry.isEmpty()) {
376                  wsize.setHeight(m_settings.value("/height", -1).toInt());                          pWidget->restoreGeometry(geometry);
377                  if (!bVisible) bVisible = m_settings.value("/visible", false).toBool();                  } else {
378                  m_settings.endGroup();                  #if 1//--LOAD_OLD_GEOMETRY
379                  if (wpos.x() > 0 && wpos.y() > 0)                          QPoint wpos;
380                          pWidget->move(wpos);                          QSize  wsize;
381                  if (wsize.width() > 0 && wsize.height() > 0)                          wpos.setX(m_settings.value("/x", -1).toInt());
382                          pWidget->resize(wsize);                          wpos.setY(m_settings.value("/y", -1).toInt());
383          //      else                          wsize.setWidth(m_settings.value("/width", -1).toInt());
384          //              pWidget->adjustSize();                          wsize.setHeight(m_settings.value("/height", -1).toInt());
385                            if (wpos.x() > 0 && wpos.y() > 0)
386                                    pWidget->move(wpos);
387                            if (wsize.width() > 0 && wsize.height() > 0)
388                                    pWidget->resize(wsize);
389                            else
390                    #endif
391                            pWidget->adjustSize();
392                    }
393                    if (!bVisible)
394                            bVisible = m_settings.value("/visible", false).toBool();
395                  if (bVisible)                  if (bVisible)
396                          pWidget->show();                          pWidget->show();
397          //      else                  else
398          //              pWidget->hide();                          pWidget->hide();
399                    m_settings.endGroup();
400          }          }
401  }  }
402    
# Line 393  void Options::saveWidgetGeometry ( QWidg Line 408  void Options::saveWidgetGeometry ( QWidg
408          // only save the form geometry while its up and visible)          // only save the form geometry while its up and visible)
409          if (pWidget) {          if (pWidget) {
410                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
411            #if 0//--SAVE_OLD_GEOMETRY
412                  const QPoint& wpos  = pWidget->pos();                  const QPoint& wpos  = pWidget->pos();
413                  const QSize&  wsize = pWidget->size();                  const QSize&  wsize = pWidget->size();
                 if (!bVisible) bVisible = pWidget->isVisible();  
414                  m_settings.setValue("/x", wpos.x());                  m_settings.setValue("/x", wpos.x());
415                  m_settings.setValue("/y", wpos.y());                  m_settings.setValue("/y", wpos.y());
416                  m_settings.setValue("/width", wsize.width());                  m_settings.setValue("/width", wsize.width());
417                  m_settings.setValue("/height", wsize.height());                  m_settings.setValue("/height", wsize.height());
418            #endif
419                    m_settings.setValue("/geometry", pWidget->saveGeometry());
420                    if (!bVisible) bVisible = pWidget->isVisible();
421                  m_settings.setValue("/visible", bVisible);                  m_settings.setValue("/visible", bVisible);
422                  m_settings.endGroup();                  m_settings.endGroup();
423          }          }
# Line 411  void Options::saveWidgetGeometry ( QWidg Line 429  void Options::saveWidgetGeometry ( QWidg
429    
430  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )
431  {  {
432            const bool bBlockSignals = pComboBox->blockSignals(true);
433    
434          // Load combobox list from configuration settings file...          // Load combobox list from configuration settings file...
435          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
436    
# Line 418  void Options::loadComboBoxHistory ( QCom Line 438  void Options::loadComboBoxHistory ( QCom
438                  pComboBox->setUpdatesEnabled(false);                  pComboBox->setUpdatesEnabled(false);
439                  pComboBox->setDuplicatesEnabled(false);                  pComboBox->setDuplicatesEnabled(false);
440                  pComboBox->clear();                  pComboBox->clear();
441                  for (int i = 0; i < iLimit; i++) {                  for (int i = 0; i < iLimit; ++i) {
442                          const QString& sText = m_settings.value(                          const QString& sText = m_settings.value(
443                                  "/Item" + QString::number(i + 1)).toString();                                  "/Item" + QString::number(i + 1)).toString();
444                          if (sText.isEmpty())                          if (sText.isEmpty())
# Line 429  void Options::loadComboBoxHistory ( QCom Line 449  void Options::loadComboBoxHistory ( QCom
449          }          }
450    
451          m_settings.endGroup();          m_settings.endGroup();
452    
453            pComboBox->blockSignals(bBlockSignals);
454  }  }
455    
456    
457  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
458  {  {
459            const bool bBlockSignals = pComboBox->blockSignals(true);
460    
461          // Add current text as latest item...          // Add current text as latest item...
462          const QString& sCurrentText = pComboBox->currentText();          const QString sCurrentText = pComboBox->currentText();
463          int iCount = pComboBox->count();          int iCount = pComboBox->count();
464          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; i++) {
465                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
466                  if (sText == sCurrentText) {                  if (sText == sCurrentText) {
467                          pComboBox->removeItem(i);                          pComboBox->removeItem(i);
468                          iCount--;                          --iCount;
469                          break;                          break;
470                  }                  }
471          }          }
472          while (iCount >= iLimit)          while (iCount >= iLimit)
473                  pComboBox->removeItem(--iCount);                  pComboBox->removeItem(--iCount);
474          pComboBox->insertItem(0, sCurrentText);          pComboBox->insertItem(0, sCurrentText);
475          iCount++;          pComboBox->setCurrentIndex(0);
476            ++iCount;
477    
478          // Save combobox list to configuration settings file...          // Save combobox list to configuration settings file...
479          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
480          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; ++i) {
481                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
482                  if (sText.isEmpty())                  if (sText.isEmpty())
483                          break;                          break;
484                  m_settings.setValue("/Item" + QString::number(i + 1), sText);                  m_settings.setValue("/Item" + QString::number(i + 1), sText);
485          }          }
486          m_settings.endGroup();          m_settings.endGroup();
487    
488            pComboBox->blockSignals(bBlockSignals);
489  }  }
490    
491    
492  int Options::getMaxVoices() {  int Options::getMaxVoices() {
493  #ifndef CONFIG_MAX_VOICES  #ifndef CONFIG_MAX_VOICES
494          return -1;          return -1;

Legend:
Removed from v.2646  
changed lines
  Added in v.2779

  ViewVC Help
Powered by ViewVC