/[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 1461 by schoenebeck, Sun Oct 28 23:30:36 2007 UTC revision 1505 by capela, Wed Nov 21 18:37:40 2007 UTC
# Line 1  Line 1 
1    // qsamplerOptionsForm.cpp
2    //
3    /****************************************************************************
4       Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5       Copyright (C) 2007, Christian Schoenebeck
6    
7       This program is free software; you can redistribute it and/or
8       modify it under the terms of the GNU General Public License
9       as published by the Free Software Foundation; either version 2
10       of the License, or (at your option) any later version.
11    
12       This program is distributed in the hope that it will be useful,
13       but WITHOUT ANY WARRANTY; without even the implied warranty of
14       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15       GNU General Public License for more details.
16    
17       You should have received a copy of the GNU General Public License along
18       with this program; if not, write to the Free Software Foundation, Inc.,
19       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20    
21    *****************************************************************************/
22    
23  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
24    
25  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
# Line 6  Line 28 
28  #include <QMessageBox>  #include <QMessageBox>
29  #include <QFontDialog>  #include <QFontDialog>
30    
 namespace QSampler {  
31    
32  OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent) {  namespace QSampler {
     ui.setupUi(this);  
   
     // No settings descriptor initially (the caller will set it).  
     m_pOptions = NULL;  
33    
34      // Initialize dirty control state.  OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent)
35      m_iDirtySetup = 0;  {
36      m_iDirtyCount = 0;          ui.setupUi(this);
37    
38      // Set dialog validators...          // No settings descriptor initially (the caller will set it).
39      ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox));          m_pOptions = NULL;
40    
41      // Try to restore old window positioning.          // Initialize dirty control state.
42      adjustSize();          m_iDirtySetup = 0;
43            m_iDirtyCount = 0;
44    
45            // Set dialog validators...
46            ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox));
47    
48            // Try to restore old window positioning.
49            adjustSize();
50    
51            QObject::connect(ui.ServerHostComboBox,
52                    SIGNAL(editTextChanged(const QString&)),
53                    SLOT(optionsChanged()));
54            QObject::connect(ui.ServerPortComboBox,
55                    SIGNAL(editTextChanged(const QString&)),
56                    SLOT(optionsChanged()));
57            QObject::connect(ui.ServerTimeoutSpinBox,
58                    SIGNAL(valueChanged(int)),
59                    SLOT(optionsChanged()));
60            QObject::connect(ui.ServerStartCheckBox,
61                    SIGNAL(stateChanged(int)),
62                    SLOT(optionsChanged()));
63            QObject::connect(ui.ServerCmdLineComboBox,
64                    SIGNAL(editTextChanged(const QString&)),
65                    SLOT(optionsChanged()));
66            QObject::connect(ui.StartDelaySpinBox,
67                    SIGNAL(valueChanged(int)),
68                    SLOT(optionsChanged()));
69            QObject::connect(ui.DisplayFontPushButton,
70                    SIGNAL(clicked()),
71                    SLOT(chooseDisplayFont()));
72            QObject::connect(ui.DisplayEffectCheckBox,
73                    SIGNAL(toggled(bool)),
74                    SLOT(toggleDisplayEffect(bool)));
75            QObject::connect(ui.AutoRefreshCheckBox,
76                    SIGNAL(stateChanged(int)),
77                    SLOT(optionsChanged()));
78            QObject::connect(ui.AutoRefreshTimeSpinBox,
79                    SIGNAL(valueChanged(int)),
80                    SLOT(optionsChanged()));
81            QObject::connect(ui.MaxVolumeSpinBox,
82                    SIGNAL(valueChanged(int)),
83                    SLOT(optionsChanged()));
84            QObject::connect(ui.MessagesFontPushButton,
85                    SIGNAL(clicked()),
86                    SLOT(chooseMessagesFont()));
87            QObject::connect(ui.MessagesLimitCheckBox,
88                    SIGNAL(stateChanged(int)),
89                    SLOT(optionsChanged()));
90            QObject::connect(ui.MessagesLimitLinesSpinBox,
91                    SIGNAL(valueChanged(int)),
92                    SLOT(optionsChanged()));
93            QObject::connect(ui.ConfirmRemoveCheckBox,
94                    SIGNAL(stateChanged(int)),
95                    SLOT(optionsChanged()));
96            QObject::connect(ui.KeepOnTopCheckBox,
97                    SIGNAL(stateChanged(int)),
98                    SLOT(optionsChanged()));
99            QObject::connect(ui.StdoutCaptureCheckBox,
100                    SIGNAL(stateChanged(int)),
101                    SLOT(optionsChanged()));
102            QObject::connect(ui.MaxRecentFilesSpinBox,
103                    SIGNAL(valueChanged(int)),
104                    SLOT(optionsChanged()));
105            QObject::connect(ui.CompletePathCheckBox,
106                    SIGNAL(stateChanged(int)),
107                    SLOT(optionsChanged()));
108            QObject::connect(ui.InstrumentNamesCheckBox,
109                    SIGNAL(stateChanged(int)),
110                    SLOT(optionsChanged()));
111            QObject::connect(ui.OkPushButton,
112                    SIGNAL(clicked()),
113                    SLOT(accept()));
114            QObject::connect(ui.CancelPushButton,
115                    SIGNAL(clicked()),
116                    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 45  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 73  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 104  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 224  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
337    
338    
339    // end of qsamplerOptionsForm.cpp

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

  ViewVC Help
Powered by ViewVC