/[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 102 - (show annotations) (download) (as text)
Fri Jun 4 10:30:56 2004 UTC (14 years ago) by capela
File MIME type: text/x-c++hdr
File size: 7976 byte(s)
Initial alpha release.

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 // Auto-refresh option.
90 AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);
91 AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);
92
93 // Messages font.
94 if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont))
95 font = QFont("Fixed", 8);
96 MessagesFontTextLabel->setFont(font);
97 MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
98
99 // Messages limit option.
100 MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);
101 MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);
102
103 // Other options finally.
104 ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);
105 StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);
106 CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);
107 MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);
108
109 // Done.
110 m_iDirtySetup--;
111 stabilizeForm();
112 }
113
114
115 // Accept settings (OK button slot).
116 void qsamplerOptionsForm::accept (void)
117 {
118 // Save options...
119 if (m_iDirtyCount > 0) {
120 // Server settings....
121 m_pOptions->sServerHost = ServerHostComboBox->currentText().stripWhiteSpace();
122 m_pOptions->iServerPort = ServerPortComboBox->currentText().toInt();
123 m_pOptions->iServerTimeout = ServerTimeoutSpinBox->value();
124 m_pOptions->bServerStart = ServerStartCheckBox->isChecked();
125 m_pOptions->sServerCmdLine = ServerCmdLineComboBox->currentText().simplifyWhiteSpace();
126 m_pOptions->iStartDelay = StartDelaySpinBox->value();
127 // Channel display options...
128 m_pOptions->sDisplayFont = DisplayFontTextLabel->font().toString();
129 m_pOptions->bAutoRefresh = AutoRefreshCheckBox->isChecked();
130 m_pOptions->iAutoRefreshTime = AutoRefreshTimeSpinBox->value();
131 // Message window options...
132 m_pOptions->sMessagesFont = MessagesFontTextLabel->font().toString();
133 m_pOptions->bMessagesLimit = MessagesLimitCheckBox->isChecked();
134 m_pOptions->iMessagesLimitLines = MessagesLimitLinesSpinBox->value();
135 // Other options...
136 m_pOptions->bConfirmRemove = ConfirmRemoveCheckBox->isChecked();
137 m_pOptions->bStdoutCapture = StdoutCaptureCheckBox->isChecked();
138 m_pOptions->bCompletePath = CompletePathCheckBox->isChecked();
139 m_pOptions->iMaxRecentFiles = MaxRecentFilesSpinBox->value();
140 // Reset dirty flag.
141 m_iDirtyCount = 0;
142 }
143
144 // Save combobox history...
145 m_pOptions->saveComboBoxHistory(ServerHostComboBox);
146 m_pOptions->saveComboBoxHistory(ServerPortComboBox);
147 m_pOptions->saveComboBoxHistory(ServerCmdLineComboBox);
148
149 // Just go with dialog acceptance.
150 QDialog::accept();
151 }
152
153
154 // Reject settings (Cancel button slot).
155 void qsamplerOptionsForm::reject (void)
156 {
157 bool bReject = true;
158
159 // Check if there's any pending changes...
160 if (m_iDirtyCount > 0) {
161 switch (QMessageBox::warning(this, tr("Warning"),
162 tr("Some settings have been changed.\n\n"
163 "Do you want to apply the changes?"),
164 tr("Apply"), tr("Discard"), tr("Cancel"))) {
165 case 0: // Apply...
166 accept();
167 return;
168 case 1: // Discard
169 break;
170 default: // Cancel.
171 bReject = false;
172 }
173 }
174
175 if (bReject)
176 QDialog::reject();
177 }
178
179
180 // Dirty up settings.
181 void qsamplerOptionsForm::optionsChanged (void)
182 {
183 if (m_iDirtySetup > 0)
184 return;
185
186 m_iDirtyCount++;
187 stabilizeForm();
188 }
189
190
191 // Stabilize current form state.
192 void qsamplerOptionsForm::stabilizeForm (void)
193 {
194 bool bEnabled = ServerStartCheckBox->isChecked();
195 ServerCmdLineTextLabel->setEnabled(bEnabled);
196 ServerCmdLineComboBox->setEnabled(bEnabled);
197 StartDelayTextLabel->setEnabled(bEnabled);
198 StartDelaySpinBox->setEnabled(bEnabled);
199
200 AutoRefreshTimeSpinBox->setEnabled(AutoRefreshCheckBox->isChecked());
201 MessagesLimitLinesSpinBox->setEnabled(MessagesLimitCheckBox->isChecked());
202
203 OkPushButton->setEnabled(m_iDirtyCount > 0);
204 }
205
206
207 // The channel display font selection dialog.
208 void qsamplerOptionsForm::chooseDisplayFont (void)
209 {
210 bool bOk = false;
211 QFont font = QFontDialog::getFont(&bOk, DisplayFontTextLabel->font(), this);
212 if (bOk) {
213 DisplayFontTextLabel->setFont(font);
214 DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
215 optionsChanged();
216 }
217 }
218
219
220 // The messages font selection dialog.
221 void qsamplerOptionsForm::chooseMessagesFont (void)
222 {
223 bool bOk = false;
224 QFont font = QFontDialog::getFont(&bOk, MessagesFontTextLabel->font(), this);
225 if (bOk) {
226 MessagesFontTextLabel->setFont(font);
227 MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize()));
228 optionsChanged();
229 }
230 }
231
232
233 // end of qsamplerOptionsForm.ui.h
234

  ViewVC Help
Powered by ViewVC