1 |
// qsamplerOptionsForm.cpp |
// qsamplerOptionsForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
27 |
|
|
28 |
#include <QMessageBox> |
#include <QMessageBox> |
29 |
#include <QFontDialog> |
#include <QFontDialog> |
30 |
|
#include <QFileDialog> |
31 |
|
|
32 |
|
|
33 |
namespace QSampler { |
namespace QSampler { |
34 |
|
|
35 |
OptionsForm::OptionsForm(QWidget* parent) : QDialog(parent) |
//------------------------------------------------------------------------- |
36 |
|
// QSampler::OptionsForm -- Options form implementation. |
37 |
|
// |
38 |
|
|
39 |
|
OptionsForm::OptionsForm ( QWidget* pParent ) |
40 |
|
: QDialog(pParent) |
41 |
{ |
{ |
42 |
ui.setupUi(this); |
m_ui.setupUi(this); |
43 |
|
|
44 |
// No settings descriptor initially (the caller will set it). |
// No settings descriptor initially (the caller will set it). |
45 |
m_pOptions = NULL; |
m_pOptions = nullptr; |
46 |
|
|
47 |
// Initialize dirty control state. |
// Initialize dirty control state. |
48 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
49 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
50 |
|
|
51 |
// Set dialog validators... |
// Set dialog validators... |
52 |
ui.ServerPortComboBox->setValidator(new QIntValidator(ui.ServerPortComboBox)); |
m_ui.ServerPortComboBox->setValidator( |
53 |
|
new QIntValidator(m_ui.ServerPortComboBox)); |
54 |
|
|
55 |
// Try to restore old window positioning. |
// Try to restore old window positioning. |
56 |
adjustSize(); |
adjustSize(); |
57 |
|
|
58 |
QObject::connect(ui.ServerHostComboBox, |
QObject::connect(m_ui.ServerHostComboBox, |
59 |
SIGNAL(editTextChanged(const QString&)), |
SIGNAL(editTextChanged(const QString&)), |
60 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
61 |
QObject::connect(ui.ServerPortComboBox, |
QObject::connect(m_ui.ServerPortComboBox, |
62 |
SIGNAL(editTextChanged(const QString&)), |
SIGNAL(editTextChanged(const QString&)), |
63 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
64 |
QObject::connect(ui.ServerTimeoutSpinBox, |
QObject::connect(m_ui.ServerTimeoutSpinBox, |
65 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
66 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
67 |
QObject::connect(ui.ServerStartCheckBox, |
QObject::connect(m_ui.ServerStartCheckBox, |
68 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
69 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
70 |
QObject::connect(ui.ServerCmdLineComboBox, |
QObject::connect(m_ui.ServerCmdLineComboBox, |
71 |
SIGNAL(editTextChanged(const QString&)), |
SIGNAL(editTextChanged(const QString&)), |
72 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
73 |
QObject::connect(ui.StartDelaySpinBox, |
QObject::connect(m_ui.StartDelaySpinBox, |
74 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
75 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
76 |
QObject::connect(ui.DisplayFontPushButton, |
QObject::connect(m_ui.MessagesLogCheckBox, |
77 |
|
SIGNAL(stateChanged(int)), |
78 |
|
SLOT(optionsChanged())); |
79 |
|
QObject::connect(m_ui.MessagesLogPathComboBox, |
80 |
|
SIGNAL(editTextChanged(const QString&)), |
81 |
|
SLOT(optionsChanged())); |
82 |
|
QObject::connect(m_ui.MessagesLogPathToolButton, |
83 |
|
SIGNAL(clicked()), |
84 |
|
SLOT(browseMessagesLogPath())); |
85 |
|
QObject::connect(m_ui.DisplayFontPushButton, |
86 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
87 |
SLOT(chooseDisplayFont())); |
SLOT(chooseDisplayFont())); |
88 |
QObject::connect(ui.DisplayEffectCheckBox, |
QObject::connect(m_ui.DisplayEffectCheckBox, |
89 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
90 |
SLOT(toggleDisplayEffect(bool))); |
SLOT(toggleDisplayEffect(bool))); |
91 |
QObject::connect(ui.AutoRefreshCheckBox, |
QObject::connect(m_ui.AutoRefreshCheckBox, |
92 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
93 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
94 |
QObject::connect(ui.AutoRefreshTimeSpinBox, |
QObject::connect(m_ui.AutoRefreshTimeSpinBox, |
95 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
96 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
97 |
QObject::connect(ui.MaxVolumeSpinBox, |
QObject::connect(m_ui.MaxVolumeSpinBox, |
98 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
99 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
100 |
QObject::connect(ui.MessagesFontPushButton, |
QObject::connect(m_ui.MessagesFontPushButton, |
101 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
102 |
SLOT(chooseMessagesFont())); |
SLOT(chooseMessagesFont())); |
103 |
QObject::connect(ui.MessagesLimitCheckBox, |
QObject::connect(m_ui.MessagesLimitCheckBox, |
104 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
105 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
106 |
QObject::connect(ui.MessagesLimitLinesSpinBox, |
QObject::connect(m_ui.MessagesLimitLinesSpinBox, |
107 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
108 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
109 |
QObject::connect(ui.ConfirmRemoveCheckBox, |
QObject::connect(m_ui.ConfirmRemoveCheckBox, |
110 |
|
SIGNAL(stateChanged(int)), |
111 |
|
SLOT(optionsChanged())); |
112 |
|
QObject::connect(m_ui.ConfirmResetCheckBox, |
113 |
|
SIGNAL(stateChanged(int)), |
114 |
|
SLOT(optionsChanged())); |
115 |
|
QObject::connect(m_ui.ConfirmRestartCheckBox, |
116 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
117 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
118 |
QObject::connect(ui.KeepOnTopCheckBox, |
QObject::connect(m_ui.ConfirmErrorCheckBox, |
119 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
120 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
121 |
QObject::connect(ui.StdoutCaptureCheckBox, |
QObject::connect(m_ui.KeepOnTopCheckBox, |
122 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
123 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
124 |
QObject::connect(ui.MaxRecentFilesSpinBox, |
QObject::connect(m_ui.StdoutCaptureCheckBox, |
125 |
|
SIGNAL(stateChanged(int)), |
126 |
|
SLOT(optionsChanged())); |
127 |
|
QObject::connect(m_ui.MaxRecentFilesSpinBox, |
128 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
129 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
130 |
QObject::connect(ui.CompletePathCheckBox, |
QObject::connect(m_ui.CompletePathCheckBox, |
131 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
132 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
133 |
QObject::connect(ui.InstrumentNamesCheckBox, |
QObject::connect(m_ui.InstrumentNamesCheckBox, |
134 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
135 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
136 |
QObject::connect(ui.OkPushButton, |
QObject::connect(m_ui.BaseFontSizeComboBox, |
137 |
SIGNAL(clicked()), |
SIGNAL(editTextChanged(const QString&)), |
138 |
|
SLOT(optionsChanged())); |
139 |
|
QObject::connect(m_ui.MaxVoicesSpinBox, |
140 |
|
SIGNAL(valueChanged(int)), |
141 |
|
SLOT(maxVoicesChanged(int))); |
142 |
|
QObject::connect(m_ui.MaxStreamsSpinBox, |
143 |
|
SIGNAL(valueChanged(int)), |
144 |
|
SLOT(maxStreamsChanged(int))); |
145 |
|
QObject::connect(m_ui.DialogButtonBox, |
146 |
|
SIGNAL(accepted()), |
147 |
SLOT(accept())); |
SLOT(accept())); |
148 |
QObject::connect(ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
149 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
150 |
SLOT(reject())); |
SLOT(reject())); |
151 |
} |
} |
152 |
|
|
155 |
} |
} |
156 |
|
|
157 |
// Populate (setup) dialog controls from settings descriptors. |
// Populate (setup) dialog controls from settings descriptors. |
158 |
void OptionsForm::setup ( qsamplerOptions *pOptions ) |
void OptionsForm::setup ( Options *pOptions ) |
159 |
{ |
{ |
160 |
// Set reference descriptor. |
// Set reference descriptor. |
161 |
m_pOptions = pOptions; |
m_pOptions = pOptions; |
162 |
|
|
163 |
// Start clean. |
// Start clean. |
164 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
165 |
// Avoid nested changes. |
// Avoid nested changes. |
166 |
m_iDirtySetup++; |
m_iDirtySetup++; |
|
|
|
|
// Load combo box history... |
|
|
m_pOptions->loadComboBoxHistory(ui.ServerHostComboBox); |
|
|
m_pOptions->loadComboBoxHistory(ui.ServerPortComboBox); |
|
|
m_pOptions->loadComboBoxHistory(ui.ServerCmdLineComboBox); |
|
|
|
|
|
// Load Server settings... |
|
|
ui.ServerHostComboBox->setItemText( |
|
|
ui.ServerHostComboBox->currentIndex(), |
|
|
m_pOptions->sServerHost); |
|
|
ui.ServerPortComboBox->setItemText( |
|
|
ui.ServerPortComboBox->currentIndex(), |
|
|
QString::number(m_pOptions->iServerPort)); |
|
|
ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout); |
|
|
ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart); |
|
|
ui.ServerCmdLineComboBox->setItemText( |
|
|
ui.ServerCmdLineComboBox->currentIndex(), |
|
|
m_pOptions->sServerCmdLine); |
|
|
ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay); |
|
167 |
|
|
168 |
// Load Display options... |
// Load combo box history... |
169 |
QFont font; |
m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox); |
170 |
|
m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox); |
171 |
|
m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox); |
172 |
|
m_pOptions->loadComboBoxHistory(m_ui.MessagesLogPathComboBox); |
173 |
|
|
174 |
|
// Load Server settings... |
175 |
|
m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost); |
176 |
|
m_ui.ServerPortComboBox->setEditText(QString::number(m_pOptions->iServerPort)); |
177 |
|
m_ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout); |
178 |
|
m_ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart); |
179 |
|
m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine); |
180 |
|
m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay); |
181 |
|
|
182 |
|
// Logging options... |
183 |
|
m_ui.MessagesLogCheckBox->setChecked(m_pOptions->bMessagesLog); |
184 |
|
m_ui.MessagesLogPathComboBox->setEditText(m_pOptions->sMessagesLogPath); |
185 |
|
|
186 |
|
// Load Display options... |
187 |
|
QFont font; |
188 |
QPalette pal; |
QPalette pal; |
189 |
|
|
190 |
// Display font. |
// Display font. |
191 |
if (m_pOptions->sDisplayFont.isEmpty() || !font.fromString(m_pOptions->sDisplayFont)) |
if (m_pOptions->sDisplayFont.isEmpty() |
192 |
font = QFont("Sans Serif", 8); |
|| !font.fromString(m_pOptions->sDisplayFont)) |
193 |
ui.DisplayFontTextLabel->setFont(font); |
font = QFont("Sans Serif", 8); |
194 |
ui.DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize())); |
m_ui.DisplayFontTextLabel->setFont(font); |
195 |
|
m_ui.DisplayFontTextLabel->setText(font.family() |
196 |
// Display effect. |
+ ' ' + QString::number(font.pointSize())); |
197 |
ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect); |
|
198 |
toggleDisplayEffect(m_pOptions->bDisplayEffect); |
// Display effect. |
199 |
|
m_ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect); |
200 |
// Auto-refresh and maximum volume options. |
toggleDisplayEffect(m_pOptions->bDisplayEffect); |
201 |
ui.AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh); |
|
202 |
ui.AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime); |
// Auto-refresh and maximum volume options. |
203 |
ui.MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume); |
m_ui.AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh); |
204 |
|
m_ui.AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime); |
205 |
// Messages font. |
m_ui.MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume); |
206 |
if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont)) |
|
207 |
font = QFont("Fixed", 8); |
// Messages font. |
208 |
pal = ui.MessagesFontTextLabel->palette(); |
if (m_pOptions->sMessagesFont.isEmpty() |
209 |
pal.setColor(QPalette::Background, Qt::white); |
|| !font.fromString(m_pOptions->sMessagesFont)) |
210 |
ui.MessagesFontTextLabel->setPalette(pal); |
font = QFont("Monospace", 8); |
211 |
ui.MessagesFontTextLabel->setFont(font); |
pal = m_ui.MessagesFontTextLabel->palette(); |
212 |
ui.MessagesFontTextLabel->setText(font.family() + ' ' + QString::number(font.pointSize())); |
pal.setColor(QPalette::Background, pal.base().color()); |
213 |
|
m_ui.MessagesFontTextLabel->setPalette(pal); |
214 |
// Messages limit option. |
m_ui.MessagesFontTextLabel->setFont(font); |
215 |
ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit); |
m_ui.MessagesFontTextLabel->setText(font.family() |
216 |
ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines); |
+ ' ' + QString::number(font.pointSize())); |
217 |
|
|
218 |
// Other options finally. |
// Messages limit option. |
219 |
ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove); |
m_ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit); |
220 |
ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop); |
m_ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines); |
221 |
ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture); |
|
222 |
ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath); |
// Other options finally. |
223 |
ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames); |
m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove); |
224 |
ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles); |
m_ui.ConfirmRestartCheckBox->setChecked(m_pOptions->bConfirmRestart); |
225 |
|
m_ui.ConfirmResetCheckBox->setChecked(m_pOptions->bConfirmReset); |
226 |
|
m_ui.ConfirmErrorCheckBox->setChecked(m_pOptions->bConfirmError); |
227 |
|
m_ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop); |
228 |
|
m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture); |
229 |
|
m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath); |
230 |
|
m_ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames); |
231 |
|
m_ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles); |
232 |
|
if (m_pOptions->iBaseFontSize > 0) |
233 |
|
m_ui.BaseFontSizeComboBox->setEditText(QString::number(m_pOptions->iBaseFontSize)); |
234 |
|
else |
235 |
|
m_ui.BaseFontSizeComboBox->setCurrentIndex(0); |
236 |
|
|
237 |
#ifndef CONFIG_LIBGIG |
#ifndef CONFIG_LIBGIG |
238 |
ui.InstrumentNamesCheckBox->setEnabled(false); |
m_ui.InstrumentNamesCheckBox->setEnabled(false); |
239 |
#endif |
#endif |
240 |
|
|
241 |
// Done. |
bMaxVoicesModified = bMaxStreamsModified = false; |
242 |
m_iDirtySetup--; |
#ifdef CONFIG_MAX_VOICES |
243 |
stabilizeForm(); |
const bool bMaxVoicesSupported = |
244 |
|
m_pOptions->getEffectiveMaxVoices() >= 0; |
245 |
|
const bool bMaxStreamsSupported = |
246 |
|
m_pOptions->getEffectiveMaxStreams() >= 0; |
247 |
|
|
248 |
|
m_ui.MaxVoicesSpinBox->setEnabled(bMaxVoicesSupported); |
249 |
|
m_ui.MaxVoicesSpinBox->setValue(m_pOptions->getMaxVoices()); |
250 |
|
if (!bMaxVoicesSupported) |
251 |
|
m_ui.MaxVoicesSpinBox->setToolTip( |
252 |
|
tr("This parameter is not supported by the current sampler " |
253 |
|
"version in use.") |
254 |
|
); |
255 |
|
else |
256 |
|
m_ui.MaxVoicesSpinBox->setToolTip( |
257 |
|
tr("The max. amount of voices the sampler shall process " |
258 |
|
"simultaneously.") |
259 |
|
); |
260 |
|
|
261 |
|
m_ui.MaxStreamsSpinBox->setEnabled(bMaxStreamsSupported); |
262 |
|
m_ui.MaxStreamsSpinBox->setValue(m_pOptions->getMaxStreams()); |
263 |
|
if (!bMaxStreamsSupported) |
264 |
|
m_ui.MaxStreamsSpinBox->setToolTip( |
265 |
|
tr("This parameter is not supported by the current sampler " |
266 |
|
"version in use.") |
267 |
|
); |
268 |
|
else |
269 |
|
m_ui.MaxStreamsSpinBox->setToolTip( |
270 |
|
tr("The max. amount of disk streams the sampler shall process " |
271 |
|
"simultaneously.") |
272 |
|
); |
273 |
|
#else |
274 |
|
m_ui.MaxVoicesSpinBox->setEnabled(false); |
275 |
|
m_ui.MaxStreamsSpinBox->setEnabled(false); |
276 |
|
m_ui.MaxVoicesSpinBox->setToolTip( |
277 |
|
tr("QSampler was built without support for this parameter.") |
278 |
|
); |
279 |
|
m_ui.MaxStreamsSpinBox->setToolTip( |
280 |
|
tr("QSampler was built without support for this parameter.") |
281 |
|
); |
282 |
|
#endif // CONFIG_MAX_VOICES |
283 |
|
|
284 |
|
// Done. |
285 |
|
m_iDirtySetup--; |
286 |
|
stabilizeForm(); |
287 |
} |
} |
288 |
|
|
289 |
|
|
290 |
// Accept settings (OK button slot). |
// Accept settings (OK button slot). |
291 |
void OptionsForm::accept (void) |
void OptionsForm::accept (void) |
292 |
{ |
{ |
293 |
// Save options... |
// Save options... |
294 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
295 |
// Server settings.... |
// Server settings.... |
296 |
m_pOptions->sServerHost = ui.ServerHostComboBox->currentText().trimmed(); |
m_pOptions->sServerHost = m_ui.ServerHostComboBox->currentText().trimmed(); |
297 |
m_pOptions->iServerPort = ui.ServerPortComboBox->currentText().toInt(); |
m_pOptions->iServerPort = m_ui.ServerPortComboBox->currentText().toInt(); |
298 |
m_pOptions->iServerTimeout = ui.ServerTimeoutSpinBox->value(); |
m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value(); |
299 |
m_pOptions->bServerStart = ui.ServerStartCheckBox->isChecked(); |
m_pOptions->bServerStart = m_ui.ServerStartCheckBox->isChecked(); |
300 |
m_pOptions->sServerCmdLine = ui.ServerCmdLineComboBox->currentText().trimmed(); |
m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed(); |
301 |
m_pOptions->iStartDelay = ui.StartDelaySpinBox->value(); |
m_pOptions->iStartDelay = m_ui.StartDelaySpinBox->value(); |
302 |
// Channels options... |
// Logging options... |
303 |
m_pOptions->sDisplayFont = ui.DisplayFontTextLabel->font().toString(); |
m_pOptions->bMessagesLog = m_ui.MessagesLogCheckBox->isChecked(); |
304 |
m_pOptions->bDisplayEffect = ui.DisplayEffectCheckBox->isChecked(); |
m_pOptions->sMessagesLogPath = m_ui.MessagesLogPathComboBox->currentText(); |
305 |
m_pOptions->bAutoRefresh = ui.AutoRefreshCheckBox->isChecked(); |
// Channels options... |
306 |
m_pOptions->iAutoRefreshTime = ui.AutoRefreshTimeSpinBox->value(); |
m_pOptions->sDisplayFont = m_ui.DisplayFontTextLabel->font().toString(); |
307 |
m_pOptions->iMaxVolume = ui.MaxVolumeSpinBox->value(); |
m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked(); |
308 |
// Messages options... |
m_pOptions->bAutoRefresh = m_ui.AutoRefreshCheckBox->isChecked(); |
309 |
m_pOptions->sMessagesFont = ui.MessagesFontTextLabel->font().toString(); |
m_pOptions->iAutoRefreshTime = m_ui.AutoRefreshTimeSpinBox->value(); |
310 |
m_pOptions->bMessagesLimit = ui.MessagesLimitCheckBox->isChecked(); |
m_pOptions->iMaxVolume = m_ui.MaxVolumeSpinBox->value(); |
311 |
m_pOptions->iMessagesLimitLines = ui.MessagesLimitLinesSpinBox->value(); |
// Messages options... |
312 |
// Other options... |
m_pOptions->sMessagesFont = m_ui.MessagesFontTextLabel->font().toString(); |
313 |
m_pOptions->bConfirmRemove = ui.ConfirmRemoveCheckBox->isChecked(); |
m_pOptions->bMessagesLimit = m_ui.MessagesLimitCheckBox->isChecked(); |
314 |
m_pOptions->bKeepOnTop = ui.KeepOnTopCheckBox->isChecked(); |
m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value(); |
315 |
m_pOptions->bStdoutCapture = ui.StdoutCaptureCheckBox->isChecked(); |
// Other options... |
316 |
m_pOptions->bCompletePath = ui.CompletePathCheckBox->isChecked(); |
m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked(); |
317 |
m_pOptions->bInstrumentNames = ui.InstrumentNamesCheckBox->isChecked(); |
m_pOptions->bConfirmRestart = m_ui.ConfirmRestartCheckBox->isChecked(); |
318 |
m_pOptions->iMaxRecentFiles = ui.MaxRecentFilesSpinBox->value(); |
m_pOptions->bConfirmReset = m_ui.ConfirmResetCheckBox->isChecked(); |
319 |
// Reset dirty flag. |
m_pOptions->bConfirmError = m_ui.ConfirmErrorCheckBox->isChecked(); |
320 |
m_iDirtyCount = 0; |
m_pOptions->bKeepOnTop = m_ui.KeepOnTopCheckBox->isChecked(); |
321 |
} |
m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked(); |
322 |
|
m_pOptions->bCompletePath = m_ui.CompletePathCheckBox->isChecked(); |
323 |
// Save combobox history... |
m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked(); |
324 |
m_pOptions->saveComboBoxHistory(ui.ServerHostComboBox); |
m_pOptions->iMaxRecentFiles = m_ui.MaxRecentFilesSpinBox->value(); |
325 |
m_pOptions->saveComboBoxHistory(ui.ServerPortComboBox); |
m_pOptions->iBaseFontSize = m_ui.BaseFontSizeComboBox->currentText().toInt(); |
326 |
m_pOptions->saveComboBoxHistory(ui.ServerCmdLineComboBox); |
// Reset dirty flag. |
327 |
|
m_iDirtyCount = 0; |
328 |
|
} |
329 |
|
|
330 |
// Just go with dialog acceptance. |
// if the user modified the limits, apply them to the sampler |
331 |
QDialog::accept(); |
// (and store it later in qsampler's configuration) |
332 |
|
if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled()) |
333 |
|
m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value()); |
334 |
|
if (bMaxStreamsModified && m_ui.MaxStreamsSpinBox->isEnabled()) |
335 |
|
m_pOptions->setMaxStreams(m_ui.MaxStreamsSpinBox->value()); |
336 |
|
|
337 |
|
// Save combobox history... |
338 |
|
m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox); |
339 |
|
m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox); |
340 |
|
m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox); |
341 |
|
m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox); |
342 |
|
|
343 |
|
// Save/commit to disk. |
344 |
|
m_pOptions->saveOptions(); |
345 |
|
|
346 |
|
// Just go with dialog acceptance. |
347 |
|
QDialog::accept(); |
348 |
} |
} |
349 |
|
|
350 |
|
|
351 |
// Reject settings (Cancel button slot). |
// Reject settings (Cancel button slot). |
352 |
void OptionsForm::reject (void) |
void OptionsForm::reject (void) |
353 |
{ |
{ |
354 |
bool bReject = true; |
bool bReject = true; |
355 |
|
|
356 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
357 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
358 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
359 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
360 |
tr("Some settings have been changed.\n\n" |
tr("Some settings have been changed.\n\n" |
361 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
362 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
363 |
case 0: // Apply... |
QMessageBox::Discard | |
364 |
accept(); |
QMessageBox::Cancel)) { |
365 |
return; |
case QMessageBox::Apply: |
366 |
case 1: // Discard |
accept(); |
367 |
break; |
return; |
368 |
default: // Cancel. |
case QMessageBox::Discard: |
369 |
bReject = false; |
break; |
370 |
} |
default: // Cancel. |
371 |
} |
bReject = false; |
372 |
|
} |
373 |
|
} |
374 |
|
|
375 |
if (bReject) |
if (bReject) |
376 |
QDialog::reject(); |
QDialog::reject(); |
377 |
} |
} |
378 |
|
|
379 |
|
|
380 |
// Dirty up settings. |
// Dirty up settings. |
381 |
void OptionsForm::optionsChanged (void) |
void OptionsForm::optionsChanged (void) |
382 |
{ |
{ |
383 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
384 |
return; |
return; |
385 |
|
|
386 |
m_iDirtyCount++; |
m_iDirtyCount++; |
387 |
stabilizeForm(); |
stabilizeForm(); |
388 |
} |
} |
389 |
|
|
390 |
|
|
391 |
// Stabilize current form state. |
// Stabilize current form state. |
392 |
void OptionsForm::stabilizeForm (void) |
void OptionsForm::stabilizeForm (void) |
393 |
{ |
{ |
394 |
bool bEnabled = ui.ServerStartCheckBox->isChecked(); |
bool bValid = (m_iDirtyCount > 0); |
|
ui.ServerCmdLineTextLabel->setEnabled(bEnabled); |
|
|
ui.ServerCmdLineComboBox->setEnabled(bEnabled); |
|
|
ui.StartDelayTextLabel->setEnabled(bEnabled); |
|
|
ui.StartDelaySpinBox->setEnabled(bEnabled); |
|
395 |
|
|
396 |
ui.AutoRefreshTimeSpinBox->setEnabled(ui.AutoRefreshCheckBox->isChecked()); |
bool bEnabled = m_ui.ServerStartCheckBox->isChecked(); |
397 |
ui.MessagesLimitLinesSpinBox->setEnabled(ui.MessagesLimitCheckBox->isChecked()); |
m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled); |
398 |
|
m_ui.ServerCmdLineComboBox->setEnabled(bEnabled); |
399 |
|
m_ui.StartDelayTextLabel->setEnabled(bEnabled); |
400 |
|
m_ui.StartDelaySpinBox->setEnabled(bEnabled); |
401 |
|
|
402 |
|
bEnabled = m_ui.MessagesLogCheckBox->isChecked(); |
403 |
|
m_ui.MessagesLogPathComboBox->setEnabled(bEnabled); |
404 |
|
m_ui.MessagesLogPathToolButton->setEnabled(bEnabled); |
405 |
|
if (bEnabled && bValid) { |
406 |
|
const QString& sPath = m_ui.MessagesLogPathComboBox->currentText(); |
407 |
|
bValid = !sPath.isEmpty(); |
408 |
|
} |
409 |
|
|
410 |
|
m_ui.AutoRefreshTimeSpinBox->setEnabled( |
411 |
|
m_ui.AutoRefreshCheckBox->isChecked()); |
412 |
|
m_ui.MessagesLimitLinesSpinBox->setEnabled( |
413 |
|
m_ui.MessagesLimitCheckBox->isChecked()); |
414 |
|
|
415 |
ui.OkPushButton->setEnabled(m_iDirtyCount > 0); |
m_ui.DialogButtonBox->button(QDialogButtonBox::Ok)->setEnabled(bValid); |
416 |
|
} |
417 |
|
|
418 |
|
|
419 |
|
// Messages log path browse slot. |
420 |
|
void OptionsForm::browseMessagesLogPath (void) |
421 |
|
{ |
422 |
|
QString sFileName = QFileDialog::getSaveFileName( |
423 |
|
this, // Parent. |
424 |
|
tr("Messages Log"), // Caption. |
425 |
|
m_ui.MessagesLogPathComboBox->currentText(), // Start here. |
426 |
|
tr("Log files") + " (*.log)" // Filter (log files) |
427 |
|
); |
428 |
|
|
429 |
|
if (!sFileName.isEmpty()) { |
430 |
|
m_ui.MessagesLogPathComboBox->setEditText(sFileName); |
431 |
|
m_ui.MessagesLogPathComboBox->setFocus(); |
432 |
|
optionsChanged(); |
433 |
|
} |
434 |
} |
} |
435 |
|
|
436 |
|
|
437 |
// The channel display font selection dialog. |
// The channel display font selection dialog. |
438 |
void OptionsForm::chooseDisplayFont (void) |
void OptionsForm::chooseDisplayFont (void) |
439 |
{ |
{ |
440 |
bool bOk = false; |
bool bOk = false; |
441 |
QFont font = QFontDialog::getFont(&bOk, ui.DisplayFontTextLabel->font(), this); |
QFont font = QFontDialog::getFont(&bOk, |
442 |
if (bOk) { |
m_ui.DisplayFontTextLabel->font(), this); |
443 |
ui.DisplayFontTextLabel->setFont(font); |
if (bOk) { |
444 |
ui.DisplayFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize())); |
m_ui.DisplayFontTextLabel->setFont(font); |
445 |
optionsChanged(); |
m_ui.DisplayFontTextLabel->setText(font.family() |
446 |
} |
+ ' ' + QString::number(font.pointSize())); |
447 |
|
optionsChanged(); |
448 |
|
} |
449 |
} |
} |
450 |
|
|
451 |
|
|
452 |
// The messages font selection dialog. |
// The messages font selection dialog. |
453 |
void OptionsForm::chooseMessagesFont (void) |
void OptionsForm::chooseMessagesFont (void) |
454 |
{ |
{ |
455 |
bool bOk = false; |
bool bOk = false; |
456 |
QFont font = QFontDialog::getFont(&bOk, ui.MessagesFontTextLabel->font(), this); |
QFont font = QFontDialog::getFont(&bOk, |
457 |
if (bOk) { |
m_ui.MessagesFontTextLabel->font(), this); |
458 |
ui.MessagesFontTextLabel->setFont(font); |
if (bOk) { |
459 |
ui.MessagesFontTextLabel->setText(font.family() + " " + QString::number(font.pointSize())); |
m_ui.MessagesFontTextLabel->setFont(font); |
460 |
optionsChanged(); |
m_ui.MessagesFontTextLabel->setText(font.family() |
461 |
} |
+ ' ' + QString::number(font.pointSize())); |
462 |
|
optionsChanged(); |
463 |
|
} |
464 |
} |
} |
465 |
|
|
466 |
|
|
470 |
QPalette pal; |
QPalette pal; |
471 |
pal.setColor(QPalette::Foreground, Qt::green); |
pal.setColor(QPalette::Foreground, Qt::green); |
472 |
if (bOn) { |
if (bOn) { |
473 |
QPixmap pm(":/icons/displaybg1.png"); |
QPixmap pm(":/images/displaybg1.png"); |
474 |
pal.setBrush(QPalette::Background, QBrush(pm)); |
pal.setBrush(QPalette::Background, QBrush(pm)); |
475 |
} else { |
} else { |
476 |
pal.setColor(QPalette::Background, Qt::black); |
pal.setColor(QPalette::Background, Qt::black); |
477 |
} |
} |
478 |
ui.DisplayFontTextLabel->setPalette(pal); |
m_ui.DisplayFontTextLabel->setPalette(pal); |
479 |
|
|
480 |
optionsChanged(); |
optionsChanged(); |
481 |
} |
} |
482 |
|
|
483 |
} // namespace QSampler |
void OptionsForm::maxVoicesChanged(int /*iMaxVoices*/) |
484 |
|
{ |
485 |
|
bMaxVoicesModified = true; |
486 |
|
optionsChanged(); |
487 |
|
} |
488 |
|
|
489 |
|
void OptionsForm::maxStreamsChanged(int /*iMaxStreams*/) |
490 |
|
{ |
491 |
|
bMaxStreamsModified = true; |
492 |
|
optionsChanged(); |
493 |
|
} |
494 |
|
|
495 |
|
} // namespace QSampler |
496 |
|
|
497 |
// end of qsamplerOptionsForm.cpp |
// end of qsamplerOptionsForm.cpp |