/[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 2846 by capela, Thu Oct 1 15:43:03 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) {
372                    if (bVisible) pWidget->show(); // Force initial exposure!
373                    m_settings.beginGroup("/Geometry/" + pWidget->objectName());
374            #if QT_VERSION >= 0x050000
375                    const QByteArray& geometry
376                            = m_settings.value("/geometry").toByteArray();
377                    if (!geometry.isEmpty())
378                            pWidget->restoreGeometry(geometry);
379                    else
380            #else//--LOAD_OLD_GEOMETRY
381                  QPoint wpos;                  QPoint wpos;
382                  QSize  wsize;                  QSize  wsize;
                 m_settings.beginGroup("/Geometry/" + pWidget->objectName());  
383                  wpos.setX(m_settings.value("/x", -1).toInt());                  wpos.setX(m_settings.value("/x", -1).toInt());
384                  wpos.setY(m_settings.value("/y", -1).toInt());                  wpos.setY(m_settings.value("/y", -1).toInt());
385                  wsize.setWidth(m_settings.value("/width", -1).toInt());                  wsize.setWidth(m_settings.value("/width", -1).toInt());
386                  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();  
387                  if (wpos.x() > 0 && wpos.y() > 0)                  if (wpos.x() > 0 && wpos.y() > 0)
388                          pWidget->move(wpos);                          pWidget->move(wpos);
389                  if (wsize.width() > 0 && wsize.height() > 0)                  if (wsize.width() > 0 && wsize.height() > 0)
390                          pWidget->resize(wsize);                          pWidget->resize(wsize);
391          //      else                  else
392          //              pWidget->adjustSize();          #endif
393                    pWidget->adjustSize();
394                    if (!bVisible)
395                            bVisible = m_settings.value("/visible", false).toBool();
396                  if (bVisible)                  if (bVisible)
397                          pWidget->show();                          pWidget->show();
398          //      else                  else
399          //              pWidget->hide();                          pWidget->hide();
400                    m_settings.endGroup();
401          }          }
402  }  }
403    
# Line 399  void Options::saveWidgetGeometry ( QWidg Line 409  void Options::saveWidgetGeometry ( QWidg
409          // only save the form geometry while its up and visible)          // only save the form geometry while its up and visible)
410          if (pWidget) {          if (pWidget) {
411                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
412            #if QT_VERSION >= 0x050000
413                    m_settings.setValue("/geometry", pWidget->saveGeometry());
414            #else//--SAVE_OLD_GEOMETRY
415                  const QPoint& wpos  = pWidget->pos();                  const QPoint& wpos  = pWidget->pos();
416                  const QSize&  wsize = pWidget->size();                  const QSize&  wsize = pWidget->size();
                 if (!bVisible) bVisible = pWidget->isVisible();  
417                  m_settings.setValue("/x", wpos.x());                  m_settings.setValue("/x", wpos.x());
418                  m_settings.setValue("/y", wpos.y());                  m_settings.setValue("/y", wpos.y());
419                  m_settings.setValue("/width", wsize.width());                  m_settings.setValue("/width", wsize.width());
420                  m_settings.setValue("/height", wsize.height());                  m_settings.setValue("/height", wsize.height());
421            #endif
422                    if (!bVisible) bVisible = pWidget->isVisible();
423                  m_settings.setValue("/visible", bVisible);                  m_settings.setValue("/visible", bVisible);
424                  m_settings.endGroup();                  m_settings.endGroup();
425          }          }
# Line 417  void Options::saveWidgetGeometry ( QWidg Line 431  void Options::saveWidgetGeometry ( QWidg
431    
432  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )
433  {  {
434            const bool bBlockSignals = pComboBox->blockSignals(true);
435    
436          // Load combobox list from configuration settings file...          // Load combobox list from configuration settings file...
437          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
438    
# Line 424  void Options::loadComboBoxHistory ( QCom Line 440  void Options::loadComboBoxHistory ( QCom
440                  pComboBox->setUpdatesEnabled(false);                  pComboBox->setUpdatesEnabled(false);
441                  pComboBox->setDuplicatesEnabled(false);                  pComboBox->setDuplicatesEnabled(false);
442                  pComboBox->clear();                  pComboBox->clear();
443                  for (int i = 0; i < iLimit; i++) {                  for (int i = 0; i < iLimit; ++i) {
444                          const QString& sText = m_settings.value(                          const QString& sText = m_settings.value(
445                                  "/Item" + QString::number(i + 1)).toString();                                  "/Item" + QString::number(i + 1)).toString();
446                          if (sText.isEmpty())                          if (sText.isEmpty())
# Line 435  void Options::loadComboBoxHistory ( QCom Line 451  void Options::loadComboBoxHistory ( QCom
451          }          }
452    
453          m_settings.endGroup();          m_settings.endGroup();
454    
455            pComboBox->blockSignals(bBlockSignals);
456  }  }
457    
458    
459  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
460  {  {
461            const bool bBlockSignals = pComboBox->blockSignals(true);
462    
463          // Add current text as latest item...          // Add current text as latest item...
464          const QString& sCurrentText = pComboBox->currentText();          const QString sCurrentText = pComboBox->currentText();
465          int iCount = pComboBox->count();          int iCount = pComboBox->count();
466          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; i++) {
467                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
468                  if (sText == sCurrentText) {                  if (sText == sCurrentText) {
469                          pComboBox->removeItem(i);                          pComboBox->removeItem(i);
470                          iCount--;                          --iCount;
471                          break;                          break;
472                  }                  }
473          }          }
474          while (iCount >= iLimit)          while (iCount >= iLimit)
475                  pComboBox->removeItem(--iCount);                  pComboBox->removeItem(--iCount);
476          pComboBox->insertItem(0, sCurrentText);          pComboBox->insertItem(0, sCurrentText);
477          iCount++;          pComboBox->setCurrentIndex(0);
478            ++iCount;
479    
480          // Save combobox list to configuration settings file...          // Save combobox list to configuration settings file...
481          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
482          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; ++i) {
483                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
484                  if (sText.isEmpty())                  if (sText.isEmpty())
485                          break;                          break;
486                  m_settings.setValue("/Item" + QString::number(i + 1), sText);                  m_settings.setValue("/Item" + QString::number(i + 1), sText);
487          }          }
488          m_settings.endGroup();          m_settings.endGroup();
489    
490            pComboBox->blockSignals(bBlockSignals);
491  }  }
492    
493    
494  int Options::getMaxVoices() {  int Options::getMaxVoices() {
495  #ifndef CONFIG_MAX_VOICES  #ifndef CONFIG_MAX_VOICES
496          return -1;          return -1;

Legend:
Removed from v.2722  
changed lines
  Added in v.2846

  ViewVC Help
Powered by ViewVC