/[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 2722 by capela, Tue Mar 3 17:41:04 2015 UTC revision 2779 by capela, Mon Jun 15 14:11:33 2015 UTC
# Line 369  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 399  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 417  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 424  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 435  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.2722  
changed lines
  Added in v.2779

  ViewVC Help
Powered by ViewVC