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

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

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

revision 1749 by capela, Wed Jul 2 13:19:09 2008 UTC revision 2028 by capela, Wed Nov 4 18:59:57 2009 UTC
# Line 1  Line 1 
1  // qsamplerOptionsForm.cpp  // qsamplerOptionsForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2009, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, 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
# Line 127  OptionsForm::OptionsForm ( QWidget* pPar Line 127  OptionsForm::OptionsForm ( QWidget* pPar
127          QObject::connect(m_ui.BaseFontSizeComboBox,          QObject::connect(m_ui.BaseFontSizeComboBox,
128                  SIGNAL(editTextChanged(const QString&)),                  SIGNAL(editTextChanged(const QString&)),
129                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
130            QObject::connect(m_ui.MaxVoicesSpinBox,
131                    SIGNAL(valueChanged(int)),
132                    SLOT(maxVoicesChanged(int)));
133            QObject::connect(m_ui.MaxStreamsSpinBox,
134                    SIGNAL(valueChanged(int)),
135                    SLOT(maxStreamsChanged(int)));
136          QObject::connect(m_ui.OkPushButton,          QObject::connect(m_ui.OkPushButton,
137                  SIGNAL(clicked()),                  SIGNAL(clicked()),
138                  SLOT(accept()));                  SLOT(accept()));
# Line 192  void OptionsForm::setup ( Options *pOpti Line 198  void OptionsForm::setup ( Options *pOpti
198          // Messages font.          // Messages font.
199          if (m_pOptions->sMessagesFont.isEmpty()          if (m_pOptions->sMessagesFont.isEmpty()
200                  || !font.fromString(m_pOptions->sMessagesFont))                  || !font.fromString(m_pOptions->sMessagesFont))
201                  font = QFont("Fixed", 8);                  font = QFont("Monospace", 8);
202          pal = m_ui.MessagesFontTextLabel->palette();          pal = m_ui.MessagesFontTextLabel->palette();
203          pal.setColor(QPalette::Background, Qt::white);          pal.setColor(QPalette::Background, pal.base().color());
204          m_ui.MessagesFontTextLabel->setPalette(pal);          m_ui.MessagesFontTextLabel->setPalette(pal);
205          m_ui.MessagesFontTextLabel->setFont(font);          m_ui.MessagesFontTextLabel->setFont(font);
206          m_ui.MessagesFontTextLabel->setText(font.family()          m_ui.MessagesFontTextLabel->setText(font.family()
# Line 220  void OptionsForm::setup ( Options *pOpti Line 226  void OptionsForm::setup ( Options *pOpti
226          m_ui.InstrumentNamesCheckBox->setEnabled(false);          m_ui.InstrumentNamesCheckBox->setEnabled(false);
227  #endif  #endif
228    
229            bMaxVoicesModified = bMaxStreamsModified = false;
230    #ifdef CONFIG_MAX_VOICES
231            const bool bMaxVoicesSupported =
232                    m_pOptions->getEffectiveMaxVoices() >= 0;
233            const bool bMaxStreamsSupported =
234                    m_pOptions->getEffectiveMaxStreams() >= 0;
235    
236            m_ui.MaxVoicesSpinBox->setEnabled(bMaxVoicesSupported);
237            m_ui.MaxVoicesSpinBox->setValue(m_pOptions->getMaxVoices());
238            if (!bMaxVoicesSupported)
239                    m_ui.MaxVoicesSpinBox->setToolTip(
240                            tr("This parameter is not supported by the current sampler "
241                               "version in use.")
242                    );
243            else
244                    m_ui.MaxVoicesSpinBox->setToolTip(
245                            tr("The max. amount of voices the sampler shall process "
246                               "simultaniously.")
247                    );
248    
249            m_ui.MaxStreamsSpinBox->setEnabled(bMaxStreamsSupported);
250            m_ui.MaxStreamsSpinBox->setValue(m_pOptions->getMaxStreams());
251            if (!bMaxStreamsSupported)
252                    m_ui.MaxStreamsSpinBox->setToolTip(
253                            tr("This parameter is not supported by the current sampler "
254                               "version in use.")
255                    );
256            else
257                    m_ui.MaxStreamsSpinBox->setToolTip(
258                            tr("The max. amount of disk streams the sampler shall process "
259                               "simultaniously.")
260                    );
261    #else
262            m_ui.MaxVoicesSpinBox->setEnabled(false);
263            m_ui.MaxStreamsSpinBox->setEnabled(false);
264            m_ui.MaxVoicesSpinBox->setToolTip(
265                    tr("QSampler was built without support for this parameter.")
266            );
267            m_ui.MaxStreamsSpinBox->setToolTip(
268                    tr("QSampler was built without support for this parameter.")
269            );
270    #endif // CONFIG_MAX_VOICES
271    
272          // Done.          // Done.
273          m_iDirtySetup--;          m_iDirtySetup--;
274          stabilizeForm();          stabilizeForm();
# Line 263  void OptionsForm::accept (void) Line 312  void OptionsForm::accept (void)
312                  m_iDirtyCount = 0;                  m_iDirtyCount = 0;
313          }          }
314    
315            // if the user modified the limits, apply them to the sampler
316            // (and store it later in qsampler's configuration)
317            if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled())
318                    m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value());
319            if (bMaxStreamsModified && m_ui.MaxStreamsSpinBox->isEnabled())
320                    m_pOptions->setMaxStreams(m_ui.MaxStreamsSpinBox->value());
321    
322          // Save combobox history...          // Save combobox history...
323          m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);
324          m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);
325          m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);
326          m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox);          m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox);
327    
328            // Save/commit to disk.
329            m_pOptions->saveOptions();
330    
331          // Just go with dialog acceptance.          // Just go with dialog acceptance.
332          QDialog::accept();          QDialog::accept();
333  }  }
# Line 285  void OptionsForm::reject (void) Line 344  void OptionsForm::reject (void)
344                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
345                          tr("Some settings have been changed.\n\n"                          tr("Some settings have been changed.\n\n"
346                          "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
347                          tr("Apply"), tr("Discard"), tr("Cancel"))) {                          QMessageBox::Apply |
348                  case 0:     // Apply...                          QMessageBox::Discard |
349                            QMessageBox::Cancel)) {
350                    case QMessageBox::Apply:
351                          accept();                          accept();
352                          return;                          return;
353                  case 1:     // Discard                  case QMessageBox::Discard:
354                          break;                          break;
355                  default:    // Cancel.                  default:    // Cancel.
356                          bReject = false;                          bReject = false;
# Line 404  void OptionsForm::toggleDisplayEffect ( Line 465  void OptionsForm::toggleDisplayEffect (
465          optionsChanged();          optionsChanged();
466  }  }
467    
468  } // namespace QSampler  void OptionsForm::maxVoicesChanged(int /*iMaxVoices*/)
469    {
470            bMaxVoicesModified = true;
471            optionsChanged();
472    }
473    
474    void OptionsForm::maxStreamsChanged(int /*iMaxStreams*/)
475    {
476            bMaxStreamsModified = true;
477            optionsChanged();
478    }
479    
480    } // namespace QSampler
481    
482  // end of qsamplerOptionsForm.cpp  // end of qsamplerOptionsForm.cpp

Legend:
Removed from v.1749  
changed lines
  Added in v.2028

  ViewVC Help
Powered by ViewVC