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