1 |
// qsamplerOptionsForm.cpp |
// qsamplerOptionsForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2008, 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 |
42 |
m_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; |
109 |
QObject::connect(m_ui.ConfirmRemoveCheckBox, |
QObject::connect(m_ui.ConfirmRemoveCheckBox, |
110 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
111 |
SLOT(optionsChanged())); |
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)), |
117 |
|
SLOT(optionsChanged())); |
118 |
|
QObject::connect(m_ui.ConfirmErrorCheckBox, |
119 |
|
SIGNAL(stateChanged(int)), |
120 |
|
SLOT(optionsChanged())); |
121 |
QObject::connect(m_ui.KeepOnTopCheckBox, |
QObject::connect(m_ui.KeepOnTopCheckBox, |
122 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
123 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
136 |
QObject::connect(m_ui.BaseFontSizeComboBox, |
QObject::connect(m_ui.BaseFontSizeComboBox, |
137 |
SIGNAL(editTextChanged(const QString&)), |
SIGNAL(editTextChanged(const QString&)), |
138 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
139 |
QObject::connect(m_ui.OkPushButton, |
QObject::connect(m_ui.MaxVoicesSpinBox, |
140 |
SIGNAL(clicked()), |
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(m_ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
149 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
150 |
SLOT(reject())); |
SLOT(reject())); |
151 |
} |
} |
152 |
|
|
207 |
// Messages font. |
// Messages font. |
208 |
if (m_pOptions->sMessagesFont.isEmpty() |
if (m_pOptions->sMessagesFont.isEmpty() |
209 |
|| !font.fromString(m_pOptions->sMessagesFont)) |
|| !font.fromString(m_pOptions->sMessagesFont)) |
210 |
font = QFont("Fixed", 8); |
font = QFont("Monospace", 8); |
211 |
pal = m_ui.MessagesFontTextLabel->palette(); |
pal = m_ui.MessagesFontTextLabel->palette(); |
212 |
pal.setColor(QPalette::Background, Qt::white); |
pal.setColor(QPalette::Background, pal.base().color()); |
213 |
m_ui.MessagesFontTextLabel->setPalette(pal); |
m_ui.MessagesFontTextLabel->setPalette(pal); |
214 |
m_ui.MessagesFontTextLabel->setFont(font); |
m_ui.MessagesFontTextLabel->setFont(font); |
215 |
m_ui.MessagesFontTextLabel->setText(font.family() |
m_ui.MessagesFontTextLabel->setText(font.family() |
221 |
|
|
222 |
// Other options finally. |
// Other options finally. |
223 |
m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove); |
m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove); |
224 |
|
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); |
m_ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop); |
228 |
m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture); |
m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture); |
229 |
m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath); |
m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath); |
238 |
m_ui.InstrumentNamesCheckBox->setEnabled(false); |
m_ui.InstrumentNamesCheckBox->setEnabled(false); |
239 |
#endif |
#endif |
240 |
|
|
241 |
|
bMaxVoicesModified = bMaxStreamsModified = false; |
242 |
|
#ifdef CONFIG_MAX_VOICES |
243 |
|
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. |
// Done. |
285 |
m_iDirtySetup--; |
m_iDirtySetup--; |
286 |
stabilizeForm(); |
stabilizeForm(); |
314 |
m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value(); |
m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value(); |
315 |
// Other options... |
// Other options... |
316 |
m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked(); |
m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked(); |
317 |
|
m_pOptions->bConfirmRestart = m_ui.ConfirmRestartCheckBox->isChecked(); |
318 |
|
m_pOptions->bConfirmReset = m_ui.ConfirmResetCheckBox->isChecked(); |
319 |
|
m_pOptions->bConfirmError = m_ui.ConfirmErrorCheckBox->isChecked(); |
320 |
m_pOptions->bKeepOnTop = m_ui.KeepOnTopCheckBox->isChecked(); |
m_pOptions->bKeepOnTop = m_ui.KeepOnTopCheckBox->isChecked(); |
321 |
m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked(); |
m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked(); |
322 |
m_pOptions->bCompletePath = m_ui.CompletePathCheckBox->isChecked(); |
m_pOptions->bCompletePath = m_ui.CompletePathCheckBox->isChecked(); |
327 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
328 |
} |
} |
329 |
|
|
330 |
|
// if the user modified the limits, apply them to the sampler |
331 |
|
// (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... |
// Save combobox history... |
338 |
m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox); |
m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox); |
339 |
m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox); |
m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox); |
340 |
m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox); |
m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox); |
341 |
m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox); |
m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox); |
342 |
|
|
343 |
|
// Save/commit to disk. |
344 |
|
m_pOptions->saveOptions(); |
345 |
|
|
346 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |
347 |
QDialog::accept(); |
QDialog::accept(); |
348 |
} |
} |
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 |
|
QMessageBox::Cancel)) { |
365 |
|
case QMessageBox::Apply: |
366 |
accept(); |
accept(); |
367 |
return; |
return; |
368 |
case 1: // Discard |
case QMessageBox::Discard: |
369 |
break; |
break; |
370 |
default: // Cancel. |
default: // Cancel. |
371 |
bReject = false; |
bReject = false; |
412 |
m_ui.MessagesLimitLinesSpinBox->setEnabled( |
m_ui.MessagesLimitLinesSpinBox->setEnabled( |
413 |
m_ui.MessagesLimitCheckBox->isChecked()); |
m_ui.MessagesLimitCheckBox->isChecked()); |
414 |
|
|
415 |
m_ui.OkPushButton->setEnabled(bValid); |
m_ui.DialogButtonBox->button(QDialogButtonBox::Ok)->setEnabled(bValid); |
416 |
} |
} |
417 |
|
|
418 |
|
|
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); |
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 |