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

Contents of /qsampler/trunk/src/qsamplerOptionsForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 920 - (show annotations) (download) (as text)
Sun Sep 24 12:47:51 2006 UTC (11 years ago) by capela
File MIME type: text/x-c++hdr
File size: 8983 byte(s)
GPL address update.

1 // qsamplerOptionsForm.ui.h
2 //
3 // ui.h extension file, included from the uic-generated form implementation.
4 /****************************************************************************
5 Copyright (C) 2004-2006, 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 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 "qsamplerAbout.h"
24 #include "qsamplerOptions.h"
25
26 #include <qvalidator.h>
27 #include <qmessagebox.h>
28 #include <qfontdialog.h>
29
30
31 // Kind of constructor.
32 void qsamplerOptionsForm::init (void)
33 {
34 // No settings descriptor initially (the caller will set it).
35 m_pOptions = NULL;
36
37 // Initialize dirty control state.
38 m_iDirtySetup = 0;
39 m_iDirtyCount = 0;
40
41 // Set dialog validators...
42 ServerPortComboBox->setValidator(new QIntValidator(ServerPortComboBox));
43
44 // Try to restore old window positioning.
45 adjustSize();
46 }
47
48
49 // Kind of destructor.
50 void qsamplerOptionsForm::destroy (void)
51 {
52 }
53
54
55 // Populate (setup) dialog controls from settings descriptors.
56 void qsamplerOptionsForm::setup ( qsamplerOptions *pOptions )
57 {
58 // Set reference descriptor.
59 m_pOptions = pOptions;
60
61 // Start clean.
62 m_iDirtyCount = 0;
63 // Avoid nested changes.
64 m_iDirtySetup++;
65
66 // Load combo box history...
67 m_pOptions->loadComboBoxHistory(ServerHostComboBox);
68 m_pOptions->loadComboBoxHistory(ServerPortComboBox);
69 m_pOptions->loadComboBoxHistory(ServerCmdLineComboBox);
70
71 // Load Server settings...
72 ServerHostComboBox->setCurrentText(m_pOptions->sServerHost);
73 ServerPortComboBox->setCurrentText(QString::number(m_pOptions->iServerPort));
74 ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);
75 ServerStartCheckBox->setChecked(m_pOptions->bServerStart);
76 ServerCmdLineComboBox->setCurrentText(m_pOptions->sServerCmdLine);
77 StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
78
79 // Load Display options...
80 QFont font;
81
82 // Display font.
83 if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont))
84 font = QFont("Sans Serif", 8);
85 DisplayFontTextLabel->setFont(font);
86 DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
87
88 // Display effect.
89 DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect);
90 toggleDisplayEffect(m_pOptions->bDisplayEffect);
91
92 // Auto-refresh and maximum volume options.
93 AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);
94 AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);
95 MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume);
96
97 // Messages font.
98 if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont))
99 font = QFont("Fixed", 8);
100 MessagesFontTextLabel->setFont(font);
101 MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
102
103 // Messages limit option.
104 MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);
105 MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);
106
107 // Other options finally.
108 ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);
109 KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop);
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().stripWhiteSpace();
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->bKeepOnTop = KeepOnTopCheckBox->isChecked();
150 m_pOptions->bStdoutCapture = StdoutCaptureCheckBox->isChecked();
151 m_pOptions->bCompletePath = CompletePathCheckBox->isChecked();
152 m_pOptions->bInstrumentNames = InstrumentNamesCheckBox->isChecked();
153 m_pOptions->iMaxRecentFiles = MaxRecentFilesSpinBox->value();
154 // Reset dirty flag.
155 m_iDirtyCount = 0;
156 }
157
158 // Save combobox history...
159 m_pOptions->saveComboBoxHistory(ServerHostComboBox);
160 m_pOptions->saveComboBoxHistory(ServerPortComboBox);
161 m_pOptions->saveComboBoxHistory(ServerCmdLineComboBox);
162
163 // Just go with dialog acceptance.
164 QDialog::accept();
165 }
166
167
168 // Reject settings (Cancel button slot).
169 void qsamplerOptionsForm::reject (void)
170 {
171 bool bReject = true;
172
173 // Check if there's any pending changes...
174 if (m_iDirtyCount > 0) {
175 switch (QMessageBox::warning(this,
176 QSAMPLER_TITLE ": " + tr("Warning"),
177 tr("Some settings have been changed.\n\n"
178 "Do you want to apply the changes?"),
179 tr("Apply"), tr("Discard"), tr("Cancel"))) {
180 case 0: // Apply...
181 accept();
182 return;
183 case 1: // Discard
184 break;
185 default: // Cancel.
186 bReject = false;
187 }
188 }
189
190 if (bReject)
191 QDialog::reject();
192 }
193
194
195 // Dirty up settings.
196 void qsamplerOptionsForm::optionsChanged (void)
197 {
198 if (m_iDirtySetup > 0)
199 return;
200
201 m_iDirtyCount++;
202 stabilizeForm();
203 }
204
205
206 // Stabilize current form state.
207 void qsamplerOptionsForm::stabilizeForm (void)
208 {
209 bool bEnabled = ServerStartCheckBox->isChecked();
210 ServerCmdLineTextLabel->setEnabled(bEnabled);
211 ServerCmdLineComboBox->setEnabled(bEnabled);
212 StartDelayTextLabel->setEnabled(bEnabled);
213 StartDelaySpinBox->setEnabled(bEnabled);
214
215 AutoRefreshTimeSpinBox->setEnabled(AutoRefreshCheckBox->isChecked());
216 MessagesLimitLinesSpinBox->setEnabled(MessagesLimitCheckBox->isChecked());
217
218 OkPushButton->setEnabled(m_iDirtyCount > 0);
219 }
220
221
222 // The channel display font selection dialog.
223 void qsamplerOptionsForm::chooseDisplayFont (void)
224 {
225 bool bOk = false;
226 QFont font = QFontDialog::getFont(&bOk, DisplayFontTextLabel->font(), this);
227 if (bOk) {
228 DisplayFontTextLabel->setFont(font);
229 DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
230 optionsChanged();
231 }
232 }
233
234
235 // The messages font selection dialog.
236 void qsamplerOptionsForm::chooseMessagesFont (void)
237 {
238 bool bOk = false;
239 QFont font = QFontDialog::getFont(&bOk, MessagesFontTextLabel->font(), this);
240 if (bOk) {
241 MessagesFontTextLabel->setFont(font);
242 MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
243 optionsChanged();
244 }
245 }
246
247
248 // The channel display effect demo changer.
249 void qsamplerOptionsForm::toggleDisplayEffect ( bool bOn )
250 {
251 QPixmap pm;
252 if (bOn)
253 pm = QPixmap::fromMimeSource("displaybg1.png");
254 DisplayFontTextLabel->setPaletteBackgroundPixmap(pm);
255
256 optionsChanged();
257 }
258
259
260 // end of qsamplerOptionsForm.ui.h
261

  ViewVC Help
Powered by ViewVC