/[svn]/qsampler/branches/qsampler_0_0/src/qsamplerOptionsForm.ui.h
ViewVC logotype

Contents of /qsampler/branches/qsampler_0_0/src/qsamplerOptionsForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 422 - (show annotations) (download) (as text)
Fri Mar 4 00:23:07 2005 UTC (19 years, 1 month ago) by (unknown author)
File MIME type: text/x-c++hdr
File size: 8838 byte(s)
This commit was manufactured by cvs2svn to create branch 'qsampler_0_0'.
1 // qsamplerOptionsForm.ui.h
2 //
3 // ui.h extension file, included from the uic-generated form implementation.
4 /****************************************************************************
5 Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
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
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 *****************************************************************************/
22
23 #include <qvalidator.h>
24 #include <qmessagebox.h>
25 #include <qfontdialog.h>
26
27 #include "qsamplerOptions.h"
28
29 #include "config.h"
30
31
32 // Kind of constructor.
33 void qsamplerOptionsForm::init (void)
34 {
35 // No settings descriptor initially (the caller will set it).
36 m_pOptions = NULL;
37
38 // Initialize dirty control state.
39 m_iDirtySetup = 0;
40 m_iDirtyCount = 0;
41
42 // Set dialog validators...
43 ServerPortComboBox->setValidator(new QIntValidator(ServerPortComboBox));
44
45 // Try to restore old window positioning.
46 adjustSize();
47 }
48
49
50 // Kind of destructor.
51 void qsamplerOptionsForm::destroy (void)
52 {
53 }
54
55
56 // Populate (setup) dialog controls from settings descriptors.
57 void qsamplerOptionsForm::setup ( qsamplerOptions *pOptions )
58 {
59 // Set reference descriptor.
60 m_pOptions = pOptions;
61
62 // Start clean.
63 m_iDirtyCount = 0;
64 // Avoid nested changes.
65 m_iDirtySetup++;
66
67 // Load combo box history...
68 m_pOptions->loadComboBoxHistory(ServerHostComboBox);
69 m_pOptions->loadComboBoxHistory(ServerPortComboBox);
70 m_pOptions->loadComboBoxHistory(ServerCmdLineComboBox);
71
72 // Load Server settings...
73 ServerHostComboBox->setCurrentText(m_pOptions->sServerHost);
74 ServerPortComboBox->setCurrentText(QString::number(m_pOptions->iServerPort));
75 ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);
76 ServerStartCheckBox->setChecked(m_pOptions->bServerStart);
77 ServerCmdLineComboBox->setCurrentText(m_pOptions->sServerCmdLine);
78 StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
79
80 // Load Display options...
81 QFont font;
82
83 // Display font.
84 if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont))
85 font = QFont("Sans Serif", 8);
86 DisplayFontTextLabel->setFont(font);
87 DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
88
89 // Display effect.
90 DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect);
91 toggleDisplayEffect(m_pOptions->bDisplayEffect);
92
93 // Auto-refresh and maximum volume options.
94 AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);
95 AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);
96 MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume);
97
98 // Messages font.
99 if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont))
100 font = QFont("Fixed", 8);
101 MessagesFontTextLabel->setFont(font);
102 MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
103
104 // Messages limit option.
105 MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);
106 MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);
107
108 // Other options finally.
109 ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);
110 StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);
111 CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);
112 InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);
113 MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);
114
115 #ifndef CONFIG_LIBGIG
116 InstrumentNamesCheckBox->setEnabled(false);
117 #endif
118
119 // Done.
120 m_iDirtySetup--;
121 stabilizeForm();
122 }
123
124
125 // Accept settings (OK button slot).
126 void qsamplerOptionsForm::accept (void)
127 {
128 // Save options...
129 if (m_iDirtyCount > 0) {
130 // Server settings....
131 m_pOptions->sServerHost = ServerHostComboBox->currentText().stripWhiteSpace();
132 m_pOptions->iServerPort = ServerPortComboBox->currentText().toInt();
133 m_pOptions->iServerTimeout = ServerTimeoutSpinBox->value();
134 m_pOptions->bServerStart = ServerStartCheckBox->isChecked();
135 m_pOptions->sServerCmdLine = ServerCmdLineComboBox->currentText().simplifyWhiteSpace();
136 m_pOptions->iStartDelay = StartDelaySpinBox->value();
137 // Channels options...
138 m_pOptions->sDisplayFont = DisplayFontTextLabel->font().toString();
139 m_pOptions->bDisplayEffect = DisplayEffectCheckBox->isChecked();
140 m_pOptions->bAutoRefresh = AutoRefreshCheckBox->isChecked();
141 m_pOptions->iAutoRefreshTime = AutoRefreshTimeSpinBox->value();
142 m_pOptions->iMaxVolume = MaxVolumeSpinBox->value();
143 // Messages options...
144 m_pOptions->sMessagesFont = MessagesFontTextLabel->font().toString();
145 m_pOptions->bMessagesLimit = MessagesLimitCheckBox->isChecked();
146 m_pOptions->iMessagesLimitLines = MessagesLimitLinesSpinBox->value();
147 // Other options...
148 m_pOptions->bConfirmRemove = ConfirmRemoveCheckBox->isChecked();
149 m_pOptions->bStdoutCapture = StdoutCaptureCheckBox->isChecked();
150 m_pOptions->bCompletePath = CompletePathCheckBox->isChecked();
151 m_pOptions->bInstrumentNames = InstrumentNamesCheckBox->isChecked();
152 m_pOptions->iMaxRecentFiles = MaxRecentFilesSpinBox->value();
153 // Reset dirty flag.
154 m_iDirtyCount = 0;
155 }
156
157 // Save combobox history...
158 m_pOptions->saveComboBoxHistory(ServerHostComboBox);
159 m_pOptions->saveComboBoxHistory(ServerPortComboBox);
160 m_pOptions->saveComboBoxHistory(ServerCmdLineComboBox);
161
162 // Just go with dialog acceptance.
163 QDialog::accept();
164 }
165
166
167 // Reject settings (Cancel button slot).
168 void qsamplerOptionsForm::reject (void)
169 {
170 bool bReject = true;
171
172 // Check if there's any pending changes...
173 if (m_iDirtyCount > 0) {
174 switch (QMessageBox::warning(this, tr("Warning"),
175 tr("Some settings have been changed.\n\n"
176 "Do you want to apply the changes?"),
177 tr("Apply"), tr("Discard"), tr("Cancel"))) {
178 case 0: // Apply...
179 accept();
180 return;
181 case 1: // Discard
182 break;
183 default: // Cancel.
184 bReject = false;
185 }
186 }
187
188 if (bReject)
189 QDialog::reject();
190 }
191
192
193 // Dirty up settings.
194 void qsamplerOptionsForm::optionsChanged (void)
195 {
196 if (m_iDirtySetup > 0)
197 return;
198
199 m_iDirtyCount++;
200 stabilizeForm();
201 }
202
203
204 // Stabilize current form state.
205 void qsamplerOptionsForm::stabilizeForm (void)
206 {
207 bool bEnabled = ServerStartCheckBox->isChecked();
208 ServerCmdLineTextLabel->setEnabled(bEnabled);
209 ServerCmdLineComboBox->setEnabled(bEnabled);
210 StartDelayTextLabel->setEnabled(bEnabled);
211 StartDelaySpinBox->setEnabled(bEnabled);
212
213 AutoRefreshTimeSpinBox->setEnabled(AutoRefreshCheckBox->isChecked());
214 MessagesLimitLinesSpinBox->setEnabled(MessagesLimitCheckBox->isChecked());
215
216 OkPushButton->setEnabled(m_iDirtyCount > 0);
217 }
218
219
220 // The channel display font selection dialog.
221 void qsamplerOptionsForm::chooseDisplayFont (void)
222 {
223 bool bOk = false;
224 QFont font = QFontDialog::getFont(&bOk, DisplayFontTextLabel->font(), this);
225 if (bOk) {
226 DisplayFontTextLabel->setFont(font);
227 DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
228 optionsChanged();
229 }
230 }
231
232
233 // The messages font selection dialog.
234 void qsamplerOptionsForm::chooseMessagesFont (void)
235 {
236 bool bOk = false;
237 QFont font = QFontDialog::getFont(&bOk, MessagesFontTextLabel->font(), this);
238 if (bOk) {
239 MessagesFontTextLabel->setFont(font);
240 MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
241 optionsChanged();
242 }
243 }
244
245
246 // The channel display effect demo changer.
247 void qsamplerOptionsForm::toggleDisplayEffect ( bool bOn )
248 {
249 QPixmap pm;
250 if (bOn)
251 pm = QPixmap::fromMimeSource("displaybg1.png");
252 DisplayFontTextLabel->setPaletteBackgroundPixmap(pm);
253
254 optionsChanged();
255 }
256
257
258 // end of qsamplerOptionsForm.ui.h
259

  ViewVC Help
Powered by ViewVC