/[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 1474 by schoenebeck, Mon Nov 5 20:47:38 2007 UTC revision 2074 by capela, Mon Mar 29 17:00:30 2010 UTC
# Line 1  Line 1 
1  // qsamplerOptionsForm.cpp  // qsamplerOptionsForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2010, 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 27  Line 27 
27    
28  #include <QMessageBox>  #include <QMessageBox>
29  #include <QFontDialog>  #include <QFontDialog>
30    #include <QFileDialog>
31    
32    
33  namespace QSampler {  namespace QSampler {
34    
35  OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent)  //-------------------------------------------------------------------------
36    // QSampler::OptionsForm -- Options form implementation.
37    //
38    
39    OptionsForm::OptionsForm ( QWidget* pParent )
40            : QDialog(pParent)
41  {  {
42          ui.setupUi(this);          m_ui.setupUi(this);
43    
44          // No settings descriptor initially (the caller will set it).          // No settings descriptor initially (the caller will set it).
45          m_pOptions = NULL;          m_pOptions = NULL;
# Line 42  OptionsForm::OptionsForm(QWidget* parent Line 49  OptionsForm::OptionsForm(QWidget* parent
49          m_iDirtyCount = 0;          m_iDirtyCount = 0;
50    
51          // Set dialog validators...          // Set dialog validators...
52          ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox));          m_ui.ServerPortComboBox->setValidator(
53                    new QIntValidator(m_ui.ServerPortComboBox));
54    
55          // Try to restore old window positioning.          // Try to restore old window positioning.
56          adjustSize();          adjustSize();
57    
58          QObject::connect(ui.ServerHostComboBox,          QObject::connect(m_ui.ServerHostComboBox,
59                  SIGNAL(textChanged(const QString&)),                  SIGNAL(editTextChanged(const QString&)),
60                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
61          QObject::connect(ui.ServerPortComboBox,          QObject::connect(m_ui.ServerPortComboBox,
62                  SIGNAL(textChanged(const QString&)),                  SIGNAL(editTextChanged(const QString&)),
63                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
64          QObject::connect(ui.ServerTimeoutSpinBox,          QObject::connect(m_ui.ServerTimeoutSpinBox,
65                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
66                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
67          QObject::connect(ui.ServerStartCheckBox,          QObject::connect(m_ui.ServerStartCheckBox,
68                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
69                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
70          QObject::connect(ui.ServerCmdLineComboBox,          QObject::connect(m_ui.ServerCmdLineComboBox,
71                  SIGNAL(textChanged(const QString&)),                  SIGNAL(editTextChanged(const QString&)),
72                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
73          QObject::connect(ui.StartDelaySpinBox,          QObject::connect(m_ui.StartDelaySpinBox,
74                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
75                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
76          QObject::connect(ui.DisplayFontPushButton,          QObject::connect(m_ui.MessagesLogCheckBox,
77                    SIGNAL(stateChanged(int)),
78                    SLOT(optionsChanged()));
79            QObject::connect(m_ui.MessagesLogPathComboBox,
80                    SIGNAL(editTextChanged(const QString&)),
81                    SLOT(optionsChanged()));
82            QObject::connect(m_ui.MessagesLogPathToolButton,
83                    SIGNAL(clicked()),
84                    SLOT(browseMessagesLogPath()));
85            QObject::connect(m_ui.DisplayFontPushButton,
86                  SIGNAL(clicked()),                  SIGNAL(clicked()),
87                  SLOT(chooseDisplayFont()));                  SLOT(chooseDisplayFont()));
88          QObject::connect(ui.DisplayEffectCheckBox,          QObject::connect(m_ui.DisplayEffectCheckBox,
89                  SIGNAL(toggled(bool)),                  SIGNAL(toggled(bool)),
90                  SLOT(toggleDisplayEffect(bool)));                  SLOT(toggleDisplayEffect(bool)));
91          QObject::connect(ui.AutoRefreshCheckBox,          QObject::connect(m_ui.AutoRefreshCheckBox,
92                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
93                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
94          QObject::connect(ui.AutoRefreshTimeSpinBox,          QObject::connect(m_ui.AutoRefreshTimeSpinBox,
95                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
96                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
97          QObject::connect(ui.MaxVolumeSpinBox,          QObject::connect(m_ui.MaxVolumeSpinBox,
98                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
99                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
100          QObject::connect(ui.MessagesFontPushButton,          QObject::connect(m_ui.MessagesFontPushButton,
101                  SIGNAL(clicked()),                  SIGNAL(clicked()),
102                  SLOT(chooseMessagesFont()));                  SLOT(chooseMessagesFont()));
103          QObject::connect(ui.MessagesLimitCheckBox,          QObject::connect(m_ui.MessagesLimitCheckBox,
104                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
105                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
106          QObject::connect(ui.MessagesLimitLinesSpinBox,          QObject::connect(m_ui.MessagesLimitLinesSpinBox,
107                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
108                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
109          QObject::connect(ui.ConfirmRemoveCheckBox,          QObject::connect(m_ui.ConfirmRemoveCheckBox,
110                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
111                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
112          QObject::connect(ui.KeepOnTopCheckBox,          QObject::connect(m_ui.KeepOnTopCheckBox,
113                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
114                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
115          QObject::connect(ui.StdoutCaptureCheckBox,          QObject::connect(m_ui.StdoutCaptureCheckBox,
116                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
117                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
118          QObject::connect(ui.MaxRecentFilesSpinBox,          QObject::connect(m_ui.MaxRecentFilesSpinBox,
119                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
120                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
121          QObject::connect(ui.CompletePathCheckBox,          QObject::connect(m_ui.CompletePathCheckBox,
122                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
123                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
124          QObject::connect(ui.InstrumentNamesCheckBox,          QObject::connect(m_ui.InstrumentNamesCheckBox,
125                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
126                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
127          QObject::connect(ui.OkPushButton,          QObject::connect(m_ui.BaseFontSizeComboBox,
128                    SIGNAL(editTextChanged(const QString&)),
129                    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,
137                  SIGNAL(clicked()),                  SIGNAL(clicked()),
138                  SLOT(accept()));                  SLOT(accept()));
139          QObject::connect(ui.CancelPushButton,          QObject::connect(m_ui.CancelPushButton,
140                  SIGNAL(clicked()),                  SIGNAL(clicked()),
141                  SLOT(reject()));                  SLOT(reject()));
142  }  }
# Line 120  OptionsForm::~OptionsForm() Line 146  OptionsForm::~OptionsForm()
146  }  }
147    
148  // Populate (setup) dialog controls from settings descriptors.  // Populate (setup) dialog controls from settings descriptors.
149  void OptionsForm::setup ( qsamplerOptions *pOptions )  void OptionsForm::setup ( Options *pOptions )
150  {  {
151      // Set reference descriptor.          // Set reference descriptor.
152      m_pOptions = pOptions;          m_pOptions = pOptions;
153    
154            // Start clean.
155            m_iDirtyCount = 0;
156            // Avoid nested changes.
157            m_iDirtySetup++;
158    
159      // Start clean.          // Load combo box history...
160      m_iDirtyCount = 0;          m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox);
161      // Avoid nested changes.          m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox);
162      m_iDirtySetup++;          m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox);
163            m_pOptions->loadComboBoxHistory(m_ui.MessagesLogPathComboBox);
164      // Load combo box history...  
165      m_pOptions->loadComboBoxHistory(ui.ServerHostComboBox);          // Load Server settings...
166      m_pOptions->loadComboBoxHistory(ui.ServerPortComboBox);          m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);
167      m_pOptions->loadComboBoxHistory(ui.ServerCmdLineComboBox);          m_ui.ServerPortComboBox->setEditText(QString::number(m_pOptions->iServerPort));
168            m_ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);
169      // Load Server settings...          m_ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart);
170      ui.ServerHostComboBox->setCurrentText(m_pOptions->sServerHost);          m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);
171      ui.ServerPortComboBox->setCurrentText(QString::number(m_pOptions->iServerPort));          m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
172      ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);  
173      ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart);          // Logging options...
174      ui.ServerCmdLineComboBox->setCurrentText(m_pOptions->sServerCmdLine);          m_ui.MessagesLogCheckBox->setChecked(m_pOptions->bMessagesLog);
175      ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);          m_ui.MessagesLogPathComboBox->setEditText(m_pOptions->sMessagesLogPath);
176    
177      // Load Display options...          // Load Display options...
178      QFont font;          QFont font;
179            QPalette pal;
180      // Display font.  
181      if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont))          // Display font.
182          font = QFont("Sans Serif", 8);          if (m_pOptions->sDisplayFont.isEmpty()
183      ui.DisplayFontTextLabel->setFont(font);                  || !font.fromString(m_pOptions->sDisplayFont))
184      ui.DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));                  font = QFont("Sans Serif", 8);
185            m_ui.DisplayFontTextLabel->setFont(font);
186      // Display effect.          m_ui.DisplayFontTextLabel->setText(font.family()
187      ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect);                  + ' ' + QString::number(font.pointSize()));
188      toggleDisplayEffect(m_pOptions->bDisplayEffect);  
189            // Display effect.
190      // Auto-refresh and maximum volume options.          m_ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect);
191      ui.AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);          toggleDisplayEffect(m_pOptions->bDisplayEffect);
192      ui.AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);  
193      ui.MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume);          // Auto-refresh and maximum volume options.
194            m_ui.AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);
195      // Messages font.          m_ui.AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);
196      if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont))          m_ui.MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume);
197          font = QFont("Fixed", 8);  
198      ui.MessagesFontTextLabel->setFont(font);          // Messages font.
199      ui.MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));          if (m_pOptions->sMessagesFont.isEmpty()
200                    || !font.fromString(m_pOptions->sMessagesFont))
201      // Messages limit option.                  font = QFont("Monospace", 8);
202      ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);          pal = m_ui.MessagesFontTextLabel->palette();
203      ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);          pal.setColor(QPalette::Background, pal.base().color());
204            m_ui.MessagesFontTextLabel->setPalette(pal);
205      // Other options finally.          m_ui.MessagesFontTextLabel->setFont(font);
206      ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);          m_ui.MessagesFontTextLabel->setText(font.family()
207      ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop);                  + ' ' + QString::number(font.pointSize()));
208      ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);  
209      ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);          // Messages limit option.
210      ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);          m_ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);
211      ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);          m_ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);
212    
213            // Other options finally.
214            m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);
215            m_ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop);
216            m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);
217            m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);
218            m_ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);
219            m_ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);
220            if (m_pOptions->iBaseFontSize > 0)
221                    m_ui.BaseFontSizeComboBox->setEditText(QString::number(m_pOptions->iBaseFontSize));
222            else
223                    m_ui.BaseFontSizeComboBox->setCurrentIndex(0);
224    
225  #ifndef CONFIG_LIBGIG  #ifndef CONFIG_LIBGIG
226      ui.InstrumentNamesCheckBox->setEnabled(false);          m_ui.InstrumentNamesCheckBox->setEnabled(false);
227  #endif  #endif
228    
229      // Done.          bMaxVoicesModified = bMaxStreamsModified = false;
230      m_iDirtySetup--;  #ifdef CONFIG_MAX_VOICES
231      stabilizeForm();          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.
273            m_iDirtySetup--;
274            stabilizeForm();
275  }  }
276    
277    
278  // Accept settings (OK button slot).  // Accept settings (OK button slot).
279  void OptionsForm::accept (void)  void OptionsForm::accept (void)
280  {  {
281      // Save options...          // Save options...
282      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
283          // Server settings....                  // Server settings....
284          m_pOptions->sServerHost         = ui.ServerHostComboBox->currentText().stripWhiteSpace();                  m_pOptions->sServerHost    = m_ui.ServerHostComboBox->currentText().trimmed();
285          m_pOptions->iServerPort         = ui.ServerPortComboBox->currentText().toInt();                  m_pOptions->iServerPort    = m_ui.ServerPortComboBox->currentText().toInt();
286          m_pOptions->iServerTimeout      = ui.ServerTimeoutSpinBox->value();                  m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value();
287          m_pOptions->bServerStart        = ui.ServerStartCheckBox->isChecked();                  m_pOptions->bServerStart   = m_ui.ServerStartCheckBox->isChecked();
288          m_pOptions->sServerCmdLine      = ui.ServerCmdLineComboBox->currentText().stripWhiteSpace();                  m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed();
289          m_pOptions->iStartDelay         = ui.StartDelaySpinBox->value();                  m_pOptions->iStartDelay    = m_ui.StartDelaySpinBox->value();
290          // Channels options...                  // Logging options...
291          m_pOptions->sDisplayFont        = ui.DisplayFontTextLabel->font().toString();                  m_pOptions->bMessagesLog   = m_ui.MessagesLogCheckBox->isChecked();
292          m_pOptions->bDisplayEffect      = ui.DisplayEffectCheckBox->isChecked();                  m_pOptions->sMessagesLogPath = m_ui.MessagesLogPathComboBox->currentText();
293          m_pOptions->bAutoRefresh        = ui.AutoRefreshCheckBox->isChecked();                  // Channels options...
294          m_pOptions->iAutoRefreshTime    = ui.AutoRefreshTimeSpinBox->value();                  m_pOptions->sDisplayFont   = m_ui.DisplayFontTextLabel->font().toString();
295          m_pOptions->iMaxVolume          = ui.MaxVolumeSpinBox->value();                  m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked();
296          // Messages options...                  m_pOptions->bAutoRefresh   = m_ui.AutoRefreshCheckBox->isChecked();
297          m_pOptions->sMessagesFont       = ui.MessagesFontTextLabel->font().toString();                  m_pOptions->iAutoRefreshTime = m_ui.AutoRefreshTimeSpinBox->value();
298          m_pOptions->bMessagesLimit      = ui.MessagesLimitCheckBox->isChecked();                  m_pOptions->iMaxVolume     = m_ui.MaxVolumeSpinBox->value();
299          m_pOptions->iMessagesLimitLines = ui.MessagesLimitLinesSpinBox->value();                  // Messages options...
300          // Other options...                  m_pOptions->sMessagesFont  = m_ui.MessagesFontTextLabel->font().toString();
301          m_pOptions->bConfirmRemove      = ui.ConfirmRemoveCheckBox->isChecked();                  m_pOptions->bMessagesLimit = m_ui.MessagesLimitCheckBox->isChecked();
302          m_pOptions->bKeepOnTop          = ui.KeepOnTopCheckBox->isChecked();                  m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value();
303          m_pOptions->bStdoutCapture      = ui.StdoutCaptureCheckBox->isChecked();                  // Other options...
304          m_pOptions->bCompletePath       = ui.CompletePathCheckBox->isChecked();                  m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked();
305          m_pOptions->bInstrumentNames    = ui.InstrumentNamesCheckBox->isChecked();                  m_pOptions->bKeepOnTop     = m_ui.KeepOnTopCheckBox->isChecked();
306          m_pOptions->iMaxRecentFiles     = ui.MaxRecentFilesSpinBox->value();                  m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked();
307          // Reset dirty flag.                  m_pOptions->bCompletePath  = m_ui.CompletePathCheckBox->isChecked();
308          m_iDirtyCount = 0;                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();
309      }                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();
310                    m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();
311      // Save combobox history...                  // Reset dirty flag.
312      m_pOptions->saveComboBoxHistory(ui.ServerHostComboBox);                  m_iDirtyCount = 0;
313      m_pOptions->saveComboBoxHistory(ui.ServerPortComboBox);          }
314      m_pOptions->saveComboBoxHistory(ui.ServerCmdLineComboBox);  
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...
323            m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);
324            m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);
325            m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);
326            m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox);
327    
328      // Just go with dialog acceptance.          // Save/commit to disk.
329      QDialog::accept();          m_pOptions->saveOptions();
330    
331            // Just go with dialog acceptance.
332            QDialog::accept();
333  }  }
334    
335    
336  // Reject settings (Cancel button slot).  // Reject settings (Cancel button slot).
337  void OptionsForm::reject (void)  void OptionsForm::reject (void)
338  {  {
339      bool bReject = true;          bool bReject = true;
340    
341      // Check if there's any pending changes...          // Check if there's any pending changes...
342      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
343          switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
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              accept();                          QMessageBox::Cancel)) {
350              return;                  case QMessageBox::Apply:
351          case 1:     // Discard                          accept();
352              break;                          return;
353          default:    // Cancel.                  case QMessageBox::Discard:
354              bReject = false;                          break;
355          }                  default:    // Cancel.
356      }                          bReject = false;
357                    }
358            }
359    
360      if (bReject)          if (bReject)
361          QDialog::reject();                  QDialog::reject();
362  }  }
363    
364    
365  // Dirty up settings.  // Dirty up settings.
366  void OptionsForm::optionsChanged (void)  void OptionsForm::optionsChanged (void)
367  {  {
368      if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
369          return;                  return;
370    
371      m_iDirtyCount++;          m_iDirtyCount++;
372      stabilizeForm();          stabilizeForm();
373  }  }
374    
375    
376  // Stabilize current form state.  // Stabilize current form state.
377  void OptionsForm::stabilizeForm (void)  void OptionsForm::stabilizeForm (void)
378  {  {
379      bool bEnabled = ui.ServerStartCheckBox->isChecked();          bool bValid = (m_iDirtyCount > 0);
380      ui.ServerCmdLineTextLabel->setEnabled(bEnabled);  
381      ui.ServerCmdLineComboBox->setEnabled(bEnabled);          bool bEnabled = m_ui.ServerStartCheckBox->isChecked();
382      ui.StartDelayTextLabel->setEnabled(bEnabled);          m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled);
383      ui.StartDelaySpinBox->setEnabled(bEnabled);          m_ui.ServerCmdLineComboBox->setEnabled(bEnabled);
384            m_ui.StartDelayTextLabel->setEnabled(bEnabled);
385            m_ui.StartDelaySpinBox->setEnabled(bEnabled);
386    
387            bEnabled = m_ui.MessagesLogCheckBox->isChecked();
388            m_ui.MessagesLogPathComboBox->setEnabled(bEnabled);
389            m_ui.MessagesLogPathToolButton->setEnabled(bEnabled);
390            if (bEnabled && bValid) {
391                    const QString& sPath = m_ui.MessagesLogPathComboBox->currentText();
392                    bValid = !sPath.isEmpty();
393            }
394    
395            m_ui.AutoRefreshTimeSpinBox->setEnabled(
396                    m_ui.AutoRefreshCheckBox->isChecked());
397            m_ui.MessagesLimitLinesSpinBox->setEnabled(
398                    m_ui.MessagesLimitCheckBox->isChecked());
399    
400            m_ui.OkPushButton->setEnabled(bValid);
401    }
402    
     ui.AutoRefreshTimeSpinBox->setEnabled(ui.AutoRefreshCheckBox->isChecked());  
     ui.MessagesLimitLinesSpinBox->setEnabled(ui.MessagesLimitCheckBox->isChecked());  
403    
404      ui.OkPushButton->setEnabled(m_iDirtyCount > 0);  // Messages log path browse slot.
405    void OptionsForm::browseMessagesLogPath (void)
406    {
407            QString sFileName = QFileDialog::getSaveFileName(
408                    this,                                                                                   // Parent.
409                    tr("Messages Log"),                                             // Caption.
410                    m_ui.MessagesLogPathComboBox->currentText(),    // Start here.
411                    tr("Log files") + " (*.log)"                    // Filter (log files)
412            );
413    
414            if (!sFileName.isEmpty()) {
415                    m_ui.MessagesLogPathComboBox->setEditText(sFileName);
416                    m_ui.MessagesLogPathComboBox->setFocus();
417                    optionsChanged();
418            }
419  }  }
420    
421    
422  // The channel display font selection dialog.  // The channel display font selection dialog.
423  void OptionsForm::chooseDisplayFont (void)  void OptionsForm::chooseDisplayFont (void)
424  {  {
425      bool  bOk  = false;          bool  bOk  = false;
426      QFont font = QFontDialog::getFont(&bOk, ui.DisplayFontTextLabel->font(), this);          QFont font = QFontDialog::getFont(&bOk,
427      if (bOk) {                  m_ui.DisplayFontTextLabel->font(), this);
428          ui.DisplayFontTextLabel->setFont(font);          if (bOk) {
429          ui.DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));                  m_ui.DisplayFontTextLabel->setFont(font);
430          optionsChanged();                  m_ui.DisplayFontTextLabel->setText(font.family()
431      }                          + ' ' + QString::number(font.pointSize()));
432                    optionsChanged();
433            }
434  }  }
435    
436    
437  // The messages font selection dialog.  // The messages font selection dialog.
438  void OptionsForm::chooseMessagesFont (void)  void OptionsForm::chooseMessagesFont (void)
439  {  {
440      bool  bOk  = false;          bool  bOk  = false;
441      QFont font = QFontDialog::getFont(&bOk, ui.MessagesFontTextLabel->font(), this);          QFont font = QFontDialog::getFont(&bOk,
442      if (bOk) {                  m_ui.MessagesFontTextLabel->font(), this);
443          ui.MessagesFontTextLabel->setFont(font);          if (bOk) {
444          ui.MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));                  m_ui.MessagesFontTextLabel->setFont(font);
445          optionsChanged();                  m_ui.MessagesFontTextLabel->setText(font.family()
446      }                          + ' ' + QString::number(font.pointSize()));
447                    optionsChanged();
448            }
449  }  }
450    
451    
452  // The channel display effect demo changer.  // The channel display effect demo changer.
453  void OptionsForm::toggleDisplayEffect ( bool bOn )  void OptionsForm::toggleDisplayEffect ( bool bOn )
454  {  {
455      QPixmap pm;          QPalette pal;
456      if (bOn)          pal.setColor(QPalette::Foreground, Qt::green);
457          pm = QPixmap(":/qsampler/pixmaps/displaybg1.png");          if (bOn) {
458      ui.DisplayFontTextLabel->setPaletteBackgroundPixmap(pm);                  QPixmap pm(":/images/displaybg1.png");
459                    pal.setBrush(QPalette::Background, QBrush(pm));
460            } else {
461                    pal.setColor(QPalette::Background, Qt::black);
462            }
463            m_ui.DisplayFontTextLabel->setPalette(pal);
464    
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.1474  
changed lines
  Added in v.2074

  ViewVC Help
Powered by ViewVC