/[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 1466 by capela, Thu Nov 1 19:25:10 2007 UTC revision 1505 by capela, Wed Nov 21 18:37:40 2007 UTC
# Line 28  Line 28 
28  #include <QMessageBox>  #include <QMessageBox>
29  #include <QFontDialog>  #include <QFontDialog>
30    
31    
32  namespace QSampler {  namespace QSampler {
33    
34  OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent) {  OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent)
35      ui.setupUi(this);  {
36            ui.setupUi(this);
37    
38      // No settings descriptor initially (the caller will set it).          // No settings descriptor initially (the caller will set it).
39      m_pOptions = NULL;          m_pOptions = NULL;
40    
41      // Initialize dirty control state.          // Initialize dirty control state.
42      m_iDirtySetup = 0;          m_iDirtySetup = 0;
43      m_iDirtyCount = 0;          m_iDirtyCount = 0;
44    
45      // Set dialog validators...          // Set dialog validators...
46      ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox));          ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox));
47    
48      // Try to restore old window positioning.          // Try to restore old window positioning.
49      adjustSize();          adjustSize();
50    
51          QObject::connect(ui.ServerHostComboBox,          QObject::connect(ui.ServerHostComboBox,
52                  SIGNAL(textChanged(const QString&amp;)),                  SIGNAL(editTextChanged(const QString&)),
53                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
54          QObject::connect(ui.ServerPortComboBox,          QObject::connect(ui.ServerPortComboBox,
55                  SIGNAL(textChanged(const QString&amp;)),                  SIGNAL(editTextChanged(const QString&)),
56                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
57          QObject::connect(ui.ServerTimeoutSpinBox,          QObject::connect(ui.ServerTimeoutSpinBox,
58                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
# Line 59  OptionsForm::OptionsForm(QWidget* parent Line 61  OptionsForm::OptionsForm(QWidget* parent
61                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
62                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
63          QObject::connect(ui.ServerCmdLineComboBox,          QObject::connect(ui.ServerCmdLineComboBox,
64                  SIGNAL(textChanged(const QString&amp;)),                  SIGNAL(editTextChanged(const QString&)),
65                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
66          QObject::connect(ui.StartDelaySpinBox,          QObject::connect(ui.StartDelaySpinBox,
67                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
# Line 114  OptionsForm::OptionsForm(QWidget* parent Line 116  OptionsForm::OptionsForm(QWidget* parent
116                  SLOT(reject()));                  SLOT(reject()));
117  }  }
118    
119  OptionsForm::~OptionsForm() {  OptionsForm::~OptionsForm()
120    {
121  }  }
122    
123  // Populate (setup) dialog controls from settings descriptors.  // Populate (setup) dialog controls from settings descriptors.
# Line 134  void OptionsForm::setup ( qsamplerOption Line 137  void OptionsForm::setup ( qsamplerOption
137      m_pOptions->loadComboBoxHistory(ui.ServerCmdLineComboBox);      m_pOptions->loadComboBoxHistory(ui.ServerCmdLineComboBox);
138    
139      // Load Server settings...      // Load Server settings...
140      ui.ServerHostComboBox->setCurrentText(m_pOptions->sServerHost);          ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);
141      ui.ServerPortComboBox->setCurrentText(QString::number(m_pOptions->iServerPort));          ui.ServerPortComboBox->setEditText(QString::number(m_pOptions->iServerPort));
142      ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);      ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);
143      ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart);      ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart);
144      ui.ServerCmdLineComboBox->setCurrentText(m_pOptions->sServerCmdLine);          ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);
145      ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);      ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
146    
147      // Load Display options...      // Load Display options...
148      QFont font;      QFont font;
149            QPalette pal;
150    
151      // Display font.      // Display font.
152      if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont))      if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont))
# Line 162  void OptionsForm::setup ( qsamplerOption Line 166  void OptionsForm::setup ( qsamplerOption
166      // Messages font.      // Messages font.
167      if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont))      if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont))
168          font = QFont("Fixed", 8);          font = QFont("Fixed", 8);
169            pal = ui.MessagesFontTextLabel->palette();
170            pal.setColor(QPalette::Background, Qt::white);
171            ui.MessagesFontTextLabel->setPalette(pal);
172      ui.MessagesFontTextLabel->setFont(font);      ui.MessagesFontTextLabel->setFont(font);
173      ui.MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));      ui.MessagesFontTextLabel->setText(font.family() + ' ' + QString::number(font.pointSize()));
174    
175      // Messages limit option.      // Messages limit option.
176      ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);      ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);
# Line 193  void OptionsForm::accept (void) Line 200  void OptionsForm::accept (void)
200      // Save options...      // Save options...
201      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0) {
202          // Server settings....          // Server settings....
203          m_pOptions->sServerHost         = ui.ServerHostComboBox->currentText().stripWhiteSpace();          m_pOptions->sServerHost         = ui.ServerHostComboBox->currentText().trimmed();
204          m_pOptions->iServerPort         = ui.ServerPortComboBox->currentText().toInt();          m_pOptions->iServerPort         = ui.ServerPortComboBox->currentText().toInt();
205          m_pOptions->iServerTimeout      = ui.ServerTimeoutSpinBox->value();          m_pOptions->iServerTimeout      = ui.ServerTimeoutSpinBox->value();
206          m_pOptions->bServerStart        = ui.ServerStartCheckBox->isChecked();          m_pOptions->bServerStart        = ui.ServerStartCheckBox->isChecked();
207          m_pOptions->sServerCmdLine      = ui.ServerCmdLineComboBox->currentText().stripWhiteSpace();          m_pOptions->sServerCmdLine      = ui.ServerCmdLineComboBox->currentText().trimmed();
208          m_pOptions->iStartDelay         = ui.StartDelaySpinBox->value();          m_pOptions->iStartDelay         = ui.StartDelaySpinBox->value();
209          // Channels options...          // Channels options...
210          m_pOptions->sDisplayFont        = ui.DisplayFontTextLabel->font().toString();          m_pOptions->sDisplayFont        = ui.DisplayFontTextLabel->font().toString();
# Line 313  void OptionsForm::chooseMessagesFont (vo Line 320  void OptionsForm::chooseMessagesFont (vo
320  // The channel display effect demo changer.  // The channel display effect demo changer.
321  void OptionsForm::toggleDisplayEffect ( bool bOn )  void OptionsForm::toggleDisplayEffect ( bool bOn )
322  {  {
323      QPixmap pm;          QPalette pal;
324      if (bOn)          pal.setColor(QPalette::Foreground, Qt::green);
325          pm = QPixmap(":/qsampler/pixmaps/displaybg1.png");          if (bOn) {
326      ui.DisplayFontTextLabel->setPaletteBackgroundPixmap(pm);                  QPixmap pm(":/icons/displaybg1.png");
327                    pal.setBrush(QPalette::Background, QBrush(pm));
328            } else {
329                    pal.setColor(QPalette::Background, Qt::black);
330            }
331            ui.DisplayFontTextLabel->setPalette(pal);
332    
333      optionsChanged();          optionsChanged();
334  }  }
335    
336  } // namespace QSampler  } // namespace QSampler

Legend:
Removed from v.1466  
changed lines
  Added in v.1505

  ViewVC Help
Powered by ViewVC