/[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 454 - (show annotations) (download) (as text)
Mon Mar 14 10:59:57 2005 UTC (19 years, 1 month ago) by capela
File MIME type: text/x-c++hdr
File size: 8952 byte(s)
New keep child windows always on top option; device icon retouching;

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 KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop);
111 StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);
112 CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);
113 InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);
114 MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);
115
116 #ifndef CONFIG_LIBGIG
117 InstrumentNamesCheckBox->setEnabled(false);
118 #endif
119
120 // Done.
121 m_iDirtySetup--;
122 stabilizeForm();
123 }
124
125
126 // Accept settings (OK button slot).
127 void qsamplerOptionsForm::accept (void)
128 {
129 // Save options...
130 if (m_iDirtyCount > 0) {
131 // Server settings....
132 m_pOptions->sServerHost = ServerHostComboBox->currentText().stripWhiteSpace();
133 m_pOptions->iServerPort = ServerPortComboBox->currentText().toInt();
134 m_pOptions->iServerTimeout = ServerTimeoutSpinBox->value();
135 m_pOptions->bServerStart = ServerStartCheckBox->isChecked();
136 m_pOptions->sServerCmdLine = ServerCmdLineComboBox->currentText().simplifyWhiteSpace();
137 m_pOptions->iStartDelay = StartDelaySpinBox->value();
138 // Channels options...
139 m_pOptions->sDisplayFont = DisplayFontTextLabel->font().toString();
140 m_pOptions->bDisplayEffect = DisplayEffectCheckBox->isChecked();
141 m_pOptions->bAutoRefresh = AutoRefreshCheckBox->isChecked();
142 m_pOptions->iAutoRefreshTime = AutoRefreshTimeSpinBox->value();
143 m_pOptions->iMaxVolume = MaxVolumeSpinBox->value();
144 // Messages options...
145 m_pOptions->sMessagesFont = MessagesFontTextLabel->font().toString();
146 m_pOptions->bMessagesLimit = MessagesLimitCheckBox->isChecked();
147 m_pOptions->iMessagesLimitLines = MessagesLimitLinesSpinBox->value();
148 // Other options...
149 m_pOptions->bConfirmRemove = ConfirmRemoveCheckBox->isChecked();
150 m_pOptions->bKeepOnTop = KeepOnTopCheckBox->isChecked();
151 m_pOptions->bStdoutCapture = StdoutCaptureCheckBox->isChecked();
152 m_pOptions->bCompletePath = CompletePathCheckBox->isChecked();
153 m_pOptions->bInstrumentNames = InstrumentNamesCheckBox->isChecked();
154 m_pOptions->iMaxRecentFiles = MaxRecentFilesSpinBox->value();
155 // Reset dirty flag.
156 m_iDirtyCount = 0;
157 }
158
159 // Save combobox history...
160 m_pOptions->saveComboBoxHistory(ServerHostComboBox);
161 m_pOptions->saveComboBoxHistory(ServerPortComboBox);
162 m_pOptions->saveComboBoxHistory(ServerCmdLineComboBox);
163
164 // Just go with dialog acceptance.
165 QDialog::accept();
166 }
167
168
169 // Reject settings (Cancel button slot).
170 void qsamplerOptionsForm::reject (void)
171 {
172 bool bReject = true;
173
174 // Check if there's any pending changes...
175 if (m_iDirtyCount > 0) {
176 switch (QMessageBox::warning(this, 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