/[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 1558 by capela, Thu Dec 6 09:35:33 2007 UTC revision 1738 by capela, Wed May 14 15:24:22 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 {
# Line 72  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 141  void OptionsForm::setup ( Options *pOpti Line 151  void OptionsForm::setup ( Options *pOpti
151          m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox);          m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox);
152          m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox);          m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox);
153          m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox);          m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox);
154            m_pOptions->loadComboBoxHistory(m_ui.MessagesLogPathComboBox);
155    
156          // Load Server settings...          // Load Server settings...
157          m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);          m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);
# Line 150  void OptionsForm::setup ( Options *pOpti Line 161  void OptionsForm::setup ( Options *pOpti
161          m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);          m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);
162          m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);          m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
163    
164            // Logging options...
165            m_ui.MessagesLogCheckBox->setChecked(m_pOptions->bMessagesLog);
166            m_ui.MessagesLogPathComboBox->setEditText(m_pOptions->sMessagesLogPath);
167    
168          // Load Display options...          // Load Display options...
169          QFont font;          QFont font;
170          QPalette pal;          QPalette pal;
# Line 215  void OptionsForm::accept (void) Line 230  void OptionsForm::accept (void)
230                  m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value();                  m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value();
231                  m_pOptions->bServerStart   = m_ui.ServerStartCheckBox->isChecked();                  m_pOptions->bServerStart   = m_ui.ServerStartCheckBox->isChecked();
232                  m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed();                  m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed();
233                  m_pOptions->iStartDelay      = m_ui.StartDelaySpinBox->value();                  m_pOptions->iStartDelay    = m_ui.StartDelaySpinBox->value();
234                    // Logging options...
235                    m_pOptions->bMessagesLog   = m_ui.MessagesLogCheckBox->isChecked();
236                    m_pOptions->sMessagesLogPath = m_ui.MessagesLogPathComboBox->currentText();
237                  // Channels options...                  // Channels options...
238                  m_pOptions->sDisplayFont   = m_ui.DisplayFontTextLabel->font().toString();                  m_pOptions->sDisplayFont   = m_ui.DisplayFontTextLabel->font().toString();
239                  m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked();                  m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked();
# Line 241  void OptionsForm::accept (void) Line 259  void OptionsForm::accept (void)
259          m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);
260          m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);
261          m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);          m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);
262            m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox);
263    
264          // Just go with dialog acceptance.          // Just go with dialog acceptance.
265          QDialog::accept();          QDialog::accept();
# Line 288  void OptionsForm::optionsChanged (void) Line 307  void OptionsForm::optionsChanged (void)
307  // Stabilize current form state.  // Stabilize current form state.
308  void OptionsForm::stabilizeForm (void)  void OptionsForm::stabilizeForm (void)
309  {  {
310            bool bValid = (m_iDirtyCount > 0);
311    
312          bool bEnabled = m_ui.ServerStartCheckBox->isChecked();          bool bEnabled = m_ui.ServerStartCheckBox->isChecked();
313          m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled);          m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled);
314          m_ui.ServerCmdLineComboBox->setEnabled(bEnabled);          m_ui.ServerCmdLineComboBox->setEnabled(bEnabled);
315          m_ui.StartDelayTextLabel->setEnabled(bEnabled);          m_ui.StartDelayTextLabel->setEnabled(bEnabled);
316          m_ui.StartDelaySpinBox->setEnabled(bEnabled);          m_ui.StartDelaySpinBox->setEnabled(bEnabled);
317    
318            bEnabled = m_ui.MessagesLogCheckBox->isChecked();
319            m_ui.MessagesLogPathComboBox->setEnabled(bEnabled);
320            m_ui.MessagesLogPathToolButton->setEnabled(bEnabled);
321            if (bEnabled && bValid) {
322                    const QString& sPath = m_ui.MessagesLogPathComboBox->currentText();
323                    bValid = !sPath.isEmpty();
324            }
325    
326          m_ui.AutoRefreshTimeSpinBox->setEnabled(          m_ui.AutoRefreshTimeSpinBox->setEnabled(
327                  m_ui.AutoRefreshCheckBox->isChecked());                  m_ui.AutoRefreshCheckBox->isChecked());
328          m_ui.MessagesLimitLinesSpinBox->setEnabled(          m_ui.MessagesLimitLinesSpinBox->setEnabled(
329                  m_ui.MessagesLimitCheckBox->isChecked());                  m_ui.MessagesLimitCheckBox->isChecked());
330    
331          m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0);          m_ui.OkPushButton->setEnabled(bValid);
332    }
333    
334    
335    // Messages log path browse slot.
336    void OptionsForm::browseMessagesLogPath (void)
337    {
338            QString sFileName = QFileDialog::getSaveFileName(
339                    this,                                                                                   // Parent.
340                    tr("Messages Log"),                                             // Caption.
341                    m_ui.MessagesLogPathComboBox->currentText(),    // Start here.
342                    tr("Log files") + " (*.log)"                    // Filter (log files)
343            );
344    
345            if (!sFileName.isEmpty()) {
346                    m_ui.MessagesLogPathComboBox->setEditText(sFileName);
347                    m_ui.MessagesLogPathComboBox->setFocus();
348                    optionsChanged();
349            }
350  }  }
351    
352    

Legend:
Removed from v.1558  
changed lines
  Added in v.1738

  ViewVC Help
Powered by ViewVC