/[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 1509 by capela, Thu Nov 22 11:10:44 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    //-------------------------------------------------------------------------
36    // QSampler::OptionsForm -- Options form implementation.
37    //
38    
39  OptionsForm::OptionsForm ( QWidget* pParent )  OptionsForm::OptionsForm ( QWidget* pParent )
40          : QDialog(pParent)          : QDialog(pParent)
41  {  {
# Line 68  OptionsForm::OptionsForm ( QWidget* pPar Line 73  OptionsForm::OptionsForm ( QWidget* pPar
73          QObject::connect(m_ui.StartDelaySpinBox,          QObject::connect(m_ui.StartDelaySpinBox,
74                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
75                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
76            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,          QObject::connect(m_ui.DisplayFontPushButton,
86                  SIGNAL(clicked()),                  SIGNAL(clicked()),
87                  SLOT(chooseDisplayFont()));                  SLOT(chooseDisplayFont()));
# Line 110  OptionsForm::OptionsForm ( QWidget* pPar Line 124  OptionsForm::OptionsForm ( QWidget* pPar
124          QObject::connect(m_ui.InstrumentNamesCheckBox,          QObject::connect(m_ui.InstrumentNamesCheckBox,
125                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
126                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
127            QObject::connect(m_ui.BaseFontSizeComboBox,
128                    SIGNAL(editTextChanged(const QString&)),
129                    SLOT(optionsChanged()));
130          QObject::connect(m_ui.OkPushButton,          QObject::connect(m_ui.OkPushButton,
131                  SIGNAL(clicked()),                  SIGNAL(clicked()),
132                  SLOT(accept()));                  SLOT(accept()));
# Line 123  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;
# Line 137  void OptionsForm::setup ( qsamplerOption Line 154  void OptionsForm::setup ( qsamplerOption
154          m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox);          m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox);
155          m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox);          m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox);
156          m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox);          m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox);
157            m_pOptions->loadComboBoxHistory(m_ui.MessagesLogPathComboBox);
158    
159          // Load Server settings...          // Load Server settings...
160          m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);          m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);
# Line 146  void OptionsForm::setup ( qsamplerOption Line 164  void OptionsForm::setup ( qsamplerOption
164          m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);          m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);
165          m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);          m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
166    
167            // Logging options...
168            m_ui.MessagesLogCheckBox->setChecked(m_pOptions->bMessagesLog);
169            m_ui.MessagesLogPathComboBox->setEditText(m_pOptions->sMessagesLogPath);
170    
171          // Load Display options...          // Load Display options...
172          QFont font;          QFont font;
173          QPalette pal;          QPalette pal;
# Line 170  void OptionsForm::setup ( qsamplerOption Line 192  void OptionsForm::setup ( qsamplerOption
192          // Messages font.          // Messages font.
193          if (m_pOptions->sMessagesFont.isEmpty()          if (m_pOptions->sMessagesFont.isEmpty()
194                  || !font.fromString(m_pOptions->sMessagesFont))                  || !font.fromString(m_pOptions->sMessagesFont))
195                  font = QFont("Fixed", 8);                  font = QFont("Monospace", 8);
196          pal = m_ui.MessagesFontTextLabel->palette();          pal = m_ui.MessagesFontTextLabel->palette();
197          pal.setColor(QPalette::Background, Qt::white);          pal.setColor(QPalette::Background, pal.base().color());
198          m_ui.MessagesFontTextLabel->setPalette(pal);          m_ui.MessagesFontTextLabel->setPalette(pal);
199          m_ui.MessagesFontTextLabel->setFont(font);          m_ui.MessagesFontTextLabel->setFont(font);
200          m_ui.MessagesFontTextLabel->setText(font.family()          m_ui.MessagesFontTextLabel->setText(font.family()
# Line 189  void OptionsForm::setup ( qsamplerOption Line 211  void OptionsForm::setup ( qsamplerOption
211          m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);          m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);
212          m_ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);          m_ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);
213          m_ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);          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          m_ui.InstrumentNamesCheckBox->setEnabled(false);          m_ui.InstrumentNamesCheckBox->setEnabled(false);
# Line 211  void OptionsForm::accept (void) Line 237  void OptionsForm::accept (void)
237                  m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value();                  m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value();
238                  m_pOptions->bServerStart   = m_ui.ServerStartCheckBox->isChecked();                  m_pOptions->bServerStart   = m_ui.ServerStartCheckBox->isChecked();
239                  m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed();                  m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed();
240                  m_pOptions->iStartDelay      = m_ui.StartDelaySpinBox->value();                  m_pOptions->iStartDelay    = m_ui.StartDelaySpinBox->value();
241                    // Logging options...
242                    m_pOptions->bMessagesLog   = m_ui.MessagesLogCheckBox->isChecked();
243                    m_pOptions->sMessagesLogPath = m_ui.MessagesLogPathComboBox->currentText();
244                  // Channels options...                  // Channels options...
245                  m_pOptions->sDisplayFont   = m_ui.DisplayFontTextLabel->font().toString();                  m_pOptions->sDisplayFont   = m_ui.DisplayFontTextLabel->font().toString();
246                  m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked();                  m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked();
# Line 229  void OptionsForm::accept (void) Line 258  void OptionsForm::accept (void)
258                  m_pOptions->bCompletePath  = m_ui.CompletePathCheckBox->isChecked();                  m_pOptions->bCompletePath  = m_ui.CompletePathCheckBox->isChecked();
259                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();
260                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();
261                    m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();
262                  // Reset dirty flag.                  // Reset dirty flag.
263                  m_iDirtyCount = 0;                  m_iDirtyCount = 0;
264          }          }
# Line 237  void OptionsForm::accept (void) Line 267  void OptionsForm::accept (void)
267          m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);
268          m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);
269          m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);          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();
# Line 284  void OptionsForm::optionsChanged (void) Line 315  void OptionsForm::optionsChanged (void)
315  // Stabilize current form state.  // Stabilize current form state.
316  void OptionsForm::stabilizeForm (void)  void OptionsForm::stabilizeForm (void)
317  {  {
318            bool bValid = (m_iDirtyCount > 0);
319    
320          bool bEnabled = m_ui.ServerStartCheckBox->isChecked();          bool bEnabled = m_ui.ServerStartCheckBox->isChecked();
321          m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled);          m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled);
322          m_ui.ServerCmdLineComboBox->setEnabled(bEnabled);          m_ui.ServerCmdLineComboBox->setEnabled(bEnabled);
323          m_ui.StartDelayTextLabel->setEnabled(bEnabled);          m_ui.StartDelayTextLabel->setEnabled(bEnabled);
324          m_ui.StartDelaySpinBox->setEnabled(bEnabled);          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(          m_ui.AutoRefreshTimeSpinBox->setEnabled(
335                  m_ui.AutoRefreshCheckBox->isChecked());                  m_ui.AutoRefreshCheckBox->isChecked());
336          m_ui.MessagesLimitLinesSpinBox->setEnabled(          m_ui.MessagesLimitLinesSpinBox->setEnabled(
337                  m_ui.MessagesLimitCheckBox->isChecked());                  m_ui.MessagesLimitCheckBox->isChecked());
338    
339          m_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    

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

  ViewVC Help
Powered by ViewVC