/[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 1788 by capela, Sun Oct 26 15:44:42 2008 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-2008, 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.OkPushButton,
131                  SIGNAL(clicked()),                  SIGNAL(clicked()),
132                  SLOT(accept()));                  SLOT(accept()));
133          QObject::connect(ui.CancelPushButton,          QObject::connect(m_ui.CancelPushButton,
134                  SIGNAL(clicked()),                  SIGNAL(clicked()),
135                  SLOT(reject()));                  SLOT(reject()));
136  }  }
# Line 120  OptionsForm::~OptionsForm() Line 140  OptionsForm::~OptionsForm()
140  }  }
141    
142  // Populate (setup) dialog controls from settings descriptors.  // Populate (setup) dialog controls from settings descriptors.
143  void OptionsForm::setup ( qsamplerOptions *pOptions )  void OptionsForm::setup ( Options *pOptions )
144  {  {
145      // Set reference descriptor.          // Set reference descriptor.
146      m_pOptions = pOptions;          m_pOptions = pOptions;
147    
148            // Start clean.
149            m_iDirtyCount = 0;
150            // Avoid nested changes.
151            m_iDirtySetup++;
152    
153      // Start clean.          // Load combo box history...
154      m_iDirtyCount = 0;          m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox);
155      // Avoid nested changes.          m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox);
156      m_iDirtySetup++;          m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox);
157            m_pOptions->loadComboBoxHistory(m_ui.MessagesLogPathComboBox);
158      // Load combo box history...  
159      m_pOptions->loadComboBoxHistory(ui.ServerHostComboBox);          // Load Server settings...
160      m_pOptions->loadComboBoxHistory(ui.ServerPortComboBox);          m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);
161      m_pOptions->loadComboBoxHistory(ui.ServerCmdLineComboBox);          m_ui.ServerPortComboBox->setEditText(QString::number(m_pOptions->iServerPort));
162            m_ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);
163      // Load Server settings...          m_ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart);
164      ui.ServerHostComboBox->setCurrentText(m_pOptions->sServerHost);          m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);
165      ui.ServerPortComboBox->setCurrentText(QString::number(m_pOptions->iServerPort));          m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
166      ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);  
167      ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart);          // Logging options...
168      ui.ServerCmdLineComboBox->setCurrentText(m_pOptions->sServerCmdLine);          m_ui.MessagesLogCheckBox->setChecked(m_pOptions->bMessagesLog);
169      ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);          m_ui.MessagesLogPathComboBox->setEditText(m_pOptions->sMessagesLogPath);
170    
171      // Load Display options...          // Load Display options...
172      QFont font;          QFont font;
173            QPalette pal;
174      // Display font.  
175      if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont))          // Display font.
176          font = QFont("Sans Serif", 8);          if (m_pOptions->sDisplayFont.isEmpty()
177      ui.DisplayFontTextLabel->setFont(font);                  || !font.fromString(m_pOptions->sDisplayFont))
178      ui.DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));                  font = QFont("Sans Serif", 8);
179            m_ui.DisplayFontTextLabel->setFont(font);
180      // Display effect.          m_ui.DisplayFontTextLabel->setText(font.family()
181      ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect);                  + ' ' + QString::number(font.pointSize()));
182      toggleDisplayEffect(m_pOptions->bDisplayEffect);  
183            // Display effect.
184      // Auto-refresh and maximum volume options.          m_ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect);
185      ui.AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);          toggleDisplayEffect(m_pOptions->bDisplayEffect);
186      ui.AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);  
187      ui.MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume);          // Auto-refresh and maximum volume options.
188            m_ui.AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);
189      // Messages font.          m_ui.AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);
190      if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont))          m_ui.MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume);
191          font = QFont("Fixed", 8);  
192      ui.MessagesFontTextLabel->setFont(font);          // Messages font.
193      ui.MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));          if (m_pOptions->sMessagesFont.isEmpty()
194                    || !font.fromString(m_pOptions->sMessagesFont))
195      // Messages limit option.                  font = QFont("Monospace", 8);
196      ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);          pal = m_ui.MessagesFontTextLabel->palette();
197      ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);          pal.setColor(QPalette::Background, pal.base().color());
198            m_ui.MessagesFontTextLabel->setPalette(pal);
199      // Other options finally.          m_ui.MessagesFontTextLabel->setFont(font);
200      ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);          m_ui.MessagesFontTextLabel->setText(font.family()
201      ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop);                  + ' ' + QString::number(font.pointSize()));
202      ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);  
203      ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);          // Messages limit option.
204      ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);          m_ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);
205      ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);          m_ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);
206    
207            // Other options finally.
208            m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);
209            m_ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop);
210            m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);
211            m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);
212            m_ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);
213            m_ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);
214            if (m_pOptions->iBaseFontSize > 0)
215                    m_ui.BaseFontSizeComboBox->setEditText(QString::number(m_pOptions->iBaseFontSize));
216            else
217                    m_ui.BaseFontSizeComboBox->setCurrentIndex(0);
218    
219  #ifndef CONFIG_LIBGIG  #ifndef CONFIG_LIBGIG
220      ui.InstrumentNamesCheckBox->setEnabled(false);          m_ui.InstrumentNamesCheckBox->setEnabled(false);
221  #endif  #endif
222    
223      // Done.          // Done.
224      m_iDirtySetup--;          m_iDirtySetup--;
225      stabilizeForm();          stabilizeForm();
226  }  }
227    
228    
229  // Accept settings (OK button slot).  // Accept settings (OK button slot).
230  void OptionsForm::accept (void)  void OptionsForm::accept (void)
231  {  {
232      // Save options...          // Save options...
233      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
234          // Server settings....                  // Server settings....
235          m_pOptions->sServerHost         = ui.ServerHostComboBox->currentText().stripWhiteSpace();                  m_pOptions->sServerHost    = m_ui.ServerHostComboBox->currentText().trimmed();
236          m_pOptions->iServerPort         = ui.ServerPortComboBox->currentText().toInt();                  m_pOptions->iServerPort    = m_ui.ServerPortComboBox->currentText().toInt();
237          m_pOptions->iServerTimeout      = ui.ServerTimeoutSpinBox->value();                  m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value();
238          m_pOptions->bServerStart        = ui.ServerStartCheckBox->isChecked();                  m_pOptions->bServerStart   = m_ui.ServerStartCheckBox->isChecked();
239          m_pOptions->sServerCmdLine      = ui.ServerCmdLineComboBox->currentText().stripWhiteSpace();                  m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed();
240          m_pOptions->iStartDelay         = ui.StartDelaySpinBox->value();                  m_pOptions->iStartDelay    = m_ui.StartDelaySpinBox->value();
241          // Channels options...                  // Logging options...
242          m_pOptions->sDisplayFont        = ui.DisplayFontTextLabel->font().toString();                  m_pOptions->bMessagesLog   = m_ui.MessagesLogCheckBox->isChecked();
243          m_pOptions->bDisplayEffect      = ui.DisplayEffectCheckBox->isChecked();                  m_pOptions->sMessagesLogPath = m_ui.MessagesLogPathComboBox->currentText();
244          m_pOptions->bAutoRefresh        = ui.AutoRefreshCheckBox->isChecked();                  // Channels options...
245          m_pOptions->iAutoRefreshTime    = ui.AutoRefreshTimeSpinBox->value();                  m_pOptions->sDisplayFont   = m_ui.DisplayFontTextLabel->font().toString();
246          m_pOptions->iMaxVolume          = ui.MaxVolumeSpinBox->value();                  m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked();
247          // Messages options...                  m_pOptions->bAutoRefresh   = m_ui.AutoRefreshCheckBox->isChecked();
248          m_pOptions->sMessagesFont       = ui.MessagesFontTextLabel->font().toString();                  m_pOptions->iAutoRefreshTime = m_ui.AutoRefreshTimeSpinBox->value();
249          m_pOptions->bMessagesLimit      = ui.MessagesLimitCheckBox->isChecked();                  m_pOptions->iMaxVolume     = m_ui.MaxVolumeSpinBox->value();
250          m_pOptions->iMessagesLimitLines = ui.MessagesLimitLinesSpinBox->value();                  // Messages options...
251          // Other options...                  m_pOptions->sMessagesFont  = m_ui.MessagesFontTextLabel->font().toString();
252          m_pOptions->bConfirmRemove      = ui.ConfirmRemoveCheckBox->isChecked();                  m_pOptions->bMessagesLimit = m_ui.MessagesLimitCheckBox->isChecked();
253          m_pOptions->bKeepOnTop          = ui.KeepOnTopCheckBox->isChecked();                  m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value();
254          m_pOptions->bStdoutCapture      = ui.StdoutCaptureCheckBox->isChecked();                  // Other options...
255          m_pOptions->bCompletePath       = ui.CompletePathCheckBox->isChecked();                  m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked();
256          m_pOptions->bInstrumentNames    = ui.InstrumentNamesCheckBox->isChecked();                  m_pOptions->bKeepOnTop     = m_ui.KeepOnTopCheckBox->isChecked();
257          m_pOptions->iMaxRecentFiles     = ui.MaxRecentFilesSpinBox->value();                  m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked();
258          // Reset dirty flag.                  m_pOptions->bCompletePath  = m_ui.CompletePathCheckBox->isChecked();
259          m_iDirtyCount = 0;                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();
260      }                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();
261                    m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();
262      // Save combobox history...                  // Reset dirty flag.
263      m_pOptions->saveComboBoxHistory(ui.ServerHostComboBox);                  m_iDirtyCount = 0;
264      m_pOptions->saveComboBoxHistory(ui.ServerPortComboBox);          }
265      m_pOptions->saveComboBoxHistory(ui.ServerCmdLineComboBox);  
266            // Save combobox history...
267            m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);
268            m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);
269            m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);
270            m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox);
271    
272      // Just go with dialog acceptance.          // Just go with dialog acceptance.
273      QDialog::accept();          QDialog::accept();
274  }  }
275    
276    
277  // Reject settings (Cancel button slot).  // Reject settings (Cancel button slot).
278  void OptionsForm::reject (void)  void OptionsForm::reject (void)
279  {  {
280      bool bReject = true;          bool bReject = true;
281    
282      // Check if there's any pending changes...          // Check if there's any pending changes...
283      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
284          switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
285                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
286              tr("Some settings have been changed.\n\n"                          tr("Some settings have been changed.\n\n"
287                 "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
288              tr("Apply"), tr("Discard"), tr("Cancel"))) {                          tr("Apply"), tr("Discard"), tr("Cancel"))) {
289          case 0:     // Apply...                  case 0:     // Apply...
290              accept();                          accept();
291              return;                          return;
292          case 1:     // Discard                  case 1:     // Discard
293              break;                          break;
294          default:    // Cancel.                  default:    // Cancel.
295              bReject = false;                          bReject = false;
296          }                  }
297      }          }
298    
299      if (bReject)          if (bReject)
300          QDialog::reject();                  QDialog::reject();
301  }  }
302    
303    
304  // Dirty up settings.  // Dirty up settings.
305  void OptionsForm::optionsChanged (void)  void OptionsForm::optionsChanged (void)
306  {  {
307      if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
308          return;                  return;
309    
310      m_iDirtyCount++;          m_iDirtyCount++;
311      stabilizeForm();          stabilizeForm();
312  }  }
313    
314    
315  // Stabilize current form state.  // Stabilize current form state.
316  void OptionsForm::stabilizeForm (void)  void OptionsForm::stabilizeForm (void)
317  {  {
318      bool bEnabled = ui.ServerStartCheckBox->isChecked();          bool bValid = (m_iDirtyCount > 0);
     ui.ServerCmdLineTextLabel->setEnabled(bEnabled);  
     ui.ServerCmdLineComboBox->setEnabled(bEnabled);  
     ui.StartDelayTextLabel->setEnabled(bEnabled);  
     ui.StartDelaySpinBox->setEnabled(bEnabled);  
319    
320      ui.AutoRefreshTimeSpinBox->setEnabled(ui.AutoRefreshCheckBox->isChecked());          bool bEnabled = m_ui.ServerStartCheckBox->isChecked();
321      ui.MessagesLimitLinesSpinBox->setEnabled(ui.MessagesLimitCheckBox->isChecked());          m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled);
322            m_ui.ServerCmdLineComboBox->setEnabled(bEnabled);
323            m_ui.StartDelayTextLabel->setEnabled(bEnabled);
324            m_ui.StartDelaySpinBox->setEnabled(bEnabled);
325    
326            bEnabled = m_ui.MessagesLogCheckBox->isChecked();
327            m_ui.MessagesLogPathComboBox->setEnabled(bEnabled);
328            m_ui.MessagesLogPathToolButton->setEnabled(bEnabled);
329            if (bEnabled && bValid) {
330                    const QString& sPath = m_ui.MessagesLogPathComboBox->currentText();
331                    bValid = !sPath.isEmpty();
332            }
333    
334            m_ui.AutoRefreshTimeSpinBox->setEnabled(
335                    m_ui.AutoRefreshCheckBox->isChecked());
336            m_ui.MessagesLimitLinesSpinBox->setEnabled(
337                    m_ui.MessagesLimitCheckBox->isChecked());
338    
339      ui.OkPushButton->setEnabled(m_iDirtyCount > 0);          m_ui.OkPushButton->setEnabled(bValid);
340    }
341    
342    
343    // Messages log path browse slot.
344    void OptionsForm::browseMessagesLogPath (void)
345    {
346            QString sFileName = QFileDialog::getSaveFileName(
347                    this,                                                                                   // Parent.
348                    tr("Messages Log"),                                             // Caption.
349                    m_ui.MessagesLogPathComboBox->currentText(),    // Start here.
350                    tr("Log files") + " (*.log)"                    // Filter (log files)
351            );
352    
353            if (!sFileName.isEmpty()) {
354                    m_ui.MessagesLogPathComboBox->setEditText(sFileName);
355                    m_ui.MessagesLogPathComboBox->setFocus();
356                    optionsChanged();
357            }
358  }  }
359    
360    
361  // The channel display font selection dialog.  // The channel display font selection dialog.
362  void OptionsForm::chooseDisplayFont (void)  void OptionsForm::chooseDisplayFont (void)
363  {  {
364      bool  bOk  = false;          bool  bOk  = false;
365      QFont font = QFontDialog::getFont(&bOk, ui.DisplayFontTextLabel->font(), this);          QFont font = QFontDialog::getFont(&bOk,
366      if (bOk) {                  m_ui.DisplayFontTextLabel->font(), this);
367          ui.DisplayFontTextLabel->setFont(font);          if (bOk) {
368          ui.DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));                  m_ui.DisplayFontTextLabel->setFont(font);
369          optionsChanged();                  m_ui.DisplayFontTextLabel->setText(font.family()
370      }                          + ' ' + QString::number(font.pointSize()));
371                    optionsChanged();
372            }
373  }  }
374    
375    
376  // The messages font selection dialog.  // The messages font selection dialog.
377  void OptionsForm::chooseMessagesFont (void)  void OptionsForm::chooseMessagesFont (void)
378  {  {
379      bool  bOk  = false;          bool  bOk  = false;
380      QFont font = QFontDialog::getFont(&bOk, ui.MessagesFontTextLabel->font(), this);          QFont font = QFontDialog::getFont(&bOk,
381      if (bOk) {                  m_ui.MessagesFontTextLabel->font(), this);
382          ui.MessagesFontTextLabel->setFont(font);          if (bOk) {
383          ui.MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));                  m_ui.MessagesFontTextLabel->setFont(font);
384          optionsChanged();                  m_ui.MessagesFontTextLabel->setText(font.family()
385      }                          + ' ' + QString::number(font.pointSize()));
386                    optionsChanged();
387            }
388  }  }
389    
390    
391  // The channel display effect demo changer.  // The channel display effect demo changer.
392  void OptionsForm::toggleDisplayEffect ( bool bOn )  void OptionsForm::toggleDisplayEffect ( bool bOn )
393  {  {
394      QPixmap pm;          QPalette pal;
395      if (bOn)          pal.setColor(QPalette::Foreground, Qt::green);
396          pm = QPixmap(":/qsampler/pixmaps/displaybg1.png");          if (bOn) {
397      ui.DisplayFontTextLabel->setPaletteBackgroundPixmap(pm);                  QPixmap pm(":/icons/displaybg1.png");
398                    pal.setBrush(QPalette::Background, QBrush(pm));
399            } else {
400                    pal.setColor(QPalette::Background, Qt::black);
401            }
402            m_ui.DisplayFontTextLabel->setPalette(pal);
403    
404      optionsChanged();          optionsChanged();
405  }  }
406    
407  } // namespace QSampler  } // namespace QSampler

Legend:
Removed from v.1474  
changed lines
  Added in v.1788

  ViewVC Help
Powered by ViewVC