/[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 267 - (show annotations) (download) (as text)
Wed Oct 6 15:42:59 2004 UTC (15 years, 6 months ago) by capela
File MIME type: text/x-c++hdr
File size: 8603 byte(s)
* Channel strip display glass effect is now an option.

1 // qsamplerOptionsForm.ui.h
2 //
3 // ui.h extension file, included from the uic-generated form implementation.
4 /****************************************************************************
5 Copyright (C) 2004, 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 MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);
113
114 // Done.
115 m_iDirtySetup--;
116 stabilizeForm();
117 }
118
119
120 // Accept settings (OK button slot).
121 void qsamplerOptionsForm::accept (void)
122 {
123 // Save options...
124 if (m_iDirtyCount > 0) {
125 // Server settings....
126 m_pOptions->sServerHost = ServerHostComboBox->currentText().stripWhiteSpace();
127 m_pOptions->iServerPort = ServerPortComboBox->currentText().toInt();
128 m_pOptions->iServerTimeout = ServerTimeoutSpinBox->value();
129 m_pOptions->bServerStart = ServerStartCheckBox->isChecked();
130 m_pOptions->sServerCmdLine = ServerCmdLineComboBox->currentText().simplifyWhiteSpace();
131 m_pOptions->iStartDelay = StartDelaySpinBox->value();
132 // Channels options...
133 m_pOptions->sDisplayFont = DisplayFontTextLabel->font().toString();
134 m_pOptions->bDisplayEffect = DisplayEffectCheckBox->isChecked();
135 m_pOptions->bAutoRefresh = AutoRefreshCheckBox->isChecked();
136 m_pOptions->iAutoRefreshTime = AutoRefreshTimeSpinBox->value();
137 m_pOptions->iMaxVolume = MaxVolumeSpinBox->value();
138 // Messages options...
139 m_pOptions->sMessagesFont = MessagesFontTextLabel->font().toString();
140 m_pOptions->bMessagesLimit = MessagesLimitCheckBox->isChecked();
141 m_pOptions->iMessagesLimitLines = MessagesLimitLinesSpinBox->value();
142 // Other options...
143 m_pOptions->bConfirmRemove = ConfirmRemoveCheckBox->isChecked();
144 m_pOptions->bStdoutCapture = StdoutCaptureCheckBox->isChecked();
145 m_pOptions->bCompletePath = CompletePathCheckBox->isChecked();
146 m_pOptions->iMaxRecentFiles = MaxRecentFilesSpinBox->value();
147 // Reset dirty flag.
148 m_iDirtyCount = 0;
149 }
150
151 // Save combobox history...
152 m_pOptions->saveComboBoxHistory(ServerHostComboBox);
153 m_pOptions->saveComboBoxHistory(ServerPortComboBox);
154 m_pOptions->saveComboBoxHistory(ServerCmdLineComboBox);
155
156 // Just go with dialog acceptance.
157 QDialog::accept();
158 }
159
160
161 // Reject settings (Cancel button slot).
162 void qsamplerOptionsForm::reject (void)
163 {
164 bool bReject = true;
165
166 // Check if there's any pending changes...
167 if (m_iDirtyCount > 0) {
168 switch (QMessageBox::warning(this, tr("Warning"),
169 tr("Some settings have been changed.\n\n"
170 "Do you want to apply the changes?"),
171 tr("Apply"), tr("Discard"), tr("Cancel"))) {
172 case 0: // Apply...
173 accept();
174 return;
175 case 1: // Discard
176 break;
177 default: // Cancel.
178 bReject = false;
179 }
180 }
181
182 if (bReject)
183 QDialog::reject();
184 }
185
186
187 // Dirty up settings.
188 void qsamplerOptionsForm::optionsChanged (void)
189 {
190 if (m_iDirtySetup > 0)
191 return;
192
193 m_iDirtyCount++;
194 stabilizeForm();
195 }
196
197
198 // Stabilize current form state.
199 void qsamplerOptionsForm::stabilizeForm (void)
200 {
201 bool bEnabled = ServerStartCheckBox->isChecked();
202 ServerCmdLineTextLabel->setEnabled(bEnabled);
203 ServerCmdLineComboBox->setEnabled(bEnabled);
204 StartDelayTextLabel->setEnabled(bEnabled);
205 StartDelaySpinBox->setEnabled(bEnabled);
206
207 AutoRefreshTimeSpinBox->setEnabled(AutoRefreshCheckBox->isChecked());
208 MessagesLimitLinesSpinBox->setEnabled(MessagesLimitCheckBox->isChecked());
209
210 OkPushButton->setEnabled(m_iDirtyCount > 0);
211 }
212
213
214 // The channel display font selection dialog.
215 void qsamplerOptionsForm::chooseDisplayFont (void)
216 {
217 bool bOk = false;
218 QFont font = QFontDialog::getFont(&bOk, DisplayFontTextLabel->font(), this);
219 if (bOk) {
220 DisplayFontTextLabel->setFont(font);
221 DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
222 optionsChanged();
223 }
224 }
225
226
227 // The messages font selection dialog.
228 void qsamplerOptionsForm::chooseMessagesFont (void)
229 {
230 bool bOk = false;
231 QFont font = QFontDialog::getFont(&bOk, MessagesFontTextLabel->font(), this);
232 if (bOk) {
233 MessagesFontTextLabel->setFont(font);
234 MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
235 optionsChanged();
236 }
237 }
238
239
240 // The channel display effect demo changer.
241 void qsamplerOptionsForm::toggleDisplayEffect ( bool bOn )
242 {
243 QPixmap pm;
244 if (bOn)
245 pm = QPixmap::fromMimeSource("displaybg1.png");
246 DisplayFontTextLabel->setPaletteBackgroundPixmap(pm);
247
248 optionsChanged();
249 }
250
251
252 // end of qsamplerOptionsForm.ui.h
253

  ViewVC Help
Powered by ViewVC