1 |
// qsamplerOptionsForm.cpp |
// qsamplerOptionsForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2022, 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 |
25 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
26 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
27 |
|
|
28 |
|
#include "qsamplerPaletteForm.h" |
29 |
|
|
30 |
#include <QMessageBox> |
#include <QMessageBox> |
31 |
#include <QFontDialog> |
#include <QFontDialog> |
32 |
#include <QFileDialog> |
#include <QFileDialog> |
33 |
|
|
34 |
|
#include <QStyleFactory> |
35 |
|
|
36 |
|
|
37 |
|
// Default (empty/blank) name. |
38 |
|
static const char *g_pszDefName = QT_TRANSLATE_NOOP("qsamplerOptionsForm", "(default)"); |
39 |
|
|
40 |
|
|
41 |
namespace QSampler { |
namespace QSampler { |
42 |
|
|
48 |
: QDialog(pParent) |
: QDialog(pParent) |
49 |
{ |
{ |
50 |
m_ui.setupUi(this); |
m_ui.setupUi(this); |
51 |
|
#if QT_VERSION < QT_VERSION_CHECK(6, 1, 0) |
52 |
|
QDialog::setWindowIcon(QIcon(":/images/qsampler.png")); |
53 |
|
#endif |
54 |
// No settings descriptor initially (the caller will set it). |
// No settings descriptor initially (the caller will set it). |
55 |
m_pOptions = NULL; |
m_pOptions = nullptr; |
56 |
|
|
57 |
// Initialize dirty control state. |
// Initialize dirty control state. |
58 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
119 |
QObject::connect(m_ui.ConfirmRemoveCheckBox, |
QObject::connect(m_ui.ConfirmRemoveCheckBox, |
120 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
121 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
122 |
|
QObject::connect(m_ui.ConfirmResetCheckBox, |
123 |
|
SIGNAL(stateChanged(int)), |
124 |
|
SLOT(optionsChanged())); |
125 |
|
QObject::connect(m_ui.ConfirmRestartCheckBox, |
126 |
|
SIGNAL(stateChanged(int)), |
127 |
|
SLOT(optionsChanged())); |
128 |
|
QObject::connect(m_ui.ConfirmErrorCheckBox, |
129 |
|
SIGNAL(stateChanged(int)), |
130 |
|
SLOT(optionsChanged())); |
131 |
QObject::connect(m_ui.KeepOnTopCheckBox, |
QObject::connect(m_ui.KeepOnTopCheckBox, |
132 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
133 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
143 |
QObject::connect(m_ui.InstrumentNamesCheckBox, |
QObject::connect(m_ui.InstrumentNamesCheckBox, |
144 |
SIGNAL(stateChanged(int)), |
SIGNAL(stateChanged(int)), |
145 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
146 |
|
QObject::connect(m_ui.CustomColorThemeComboBox, |
147 |
|
SIGNAL(activated(int)), |
148 |
|
SLOT(optionsChanged())); |
149 |
|
QObject::connect(m_ui.CustomColorThemeToolButton, |
150 |
|
SIGNAL(clicked()), |
151 |
|
SLOT(editCustomColorThemes())); |
152 |
|
QObject::connect(m_ui.CustomStyleThemeComboBox, |
153 |
|
SIGNAL(activated(int)), |
154 |
|
SLOT(optionsChanged())); |
155 |
QObject::connect(m_ui.BaseFontSizeComboBox, |
QObject::connect(m_ui.BaseFontSizeComboBox, |
156 |
SIGNAL(editTextChanged(const QString&)), |
SIGNAL(editTextChanged(const QString&)), |
157 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
228 |
|| !font.fromString(m_pOptions->sMessagesFont)) |
|| !font.fromString(m_pOptions->sMessagesFont)) |
229 |
font = QFont("Monospace", 8); |
font = QFont("Monospace", 8); |
230 |
pal = m_ui.MessagesFontTextLabel->palette(); |
pal = m_ui.MessagesFontTextLabel->palette(); |
231 |
pal.setColor(QPalette::Background, pal.base().color()); |
pal.setColor(QPalette::Window, pal.base().color()); |
232 |
m_ui.MessagesFontTextLabel->setPalette(pal); |
m_ui.MessagesFontTextLabel->setPalette(pal); |
233 |
m_ui.MessagesFontTextLabel->setFont(font); |
m_ui.MessagesFontTextLabel->setFont(font); |
234 |
m_ui.MessagesFontTextLabel->setText(font.family() |
m_ui.MessagesFontTextLabel->setText(font.family() |
240 |
|
|
241 |
// Other options finally. |
// Other options finally. |
242 |
m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove); |
m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove); |
243 |
|
m_ui.ConfirmRestartCheckBox->setChecked(m_pOptions->bConfirmRestart); |
244 |
|
m_ui.ConfirmResetCheckBox->setChecked(m_pOptions->bConfirmReset); |
245 |
|
m_ui.ConfirmErrorCheckBox->setChecked(m_pOptions->bConfirmError); |
246 |
m_ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop); |
m_ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop); |
247 |
m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture); |
m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture); |
248 |
m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath); |
m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath); |
274 |
else |
else |
275 |
m_ui.MaxVoicesSpinBox->setToolTip( |
m_ui.MaxVoicesSpinBox->setToolTip( |
276 |
tr("The max. amount of voices the sampler shall process " |
tr("The max. amount of voices the sampler shall process " |
277 |
"simultaniously.") |
"simultaneously.") |
278 |
); |
); |
279 |
|
|
280 |
m_ui.MaxStreamsSpinBox->setEnabled(bMaxStreamsSupported); |
m_ui.MaxStreamsSpinBox->setEnabled(bMaxStreamsSupported); |
287 |
else |
else |
288 |
m_ui.MaxStreamsSpinBox->setToolTip( |
m_ui.MaxStreamsSpinBox->setToolTip( |
289 |
tr("The max. amount of disk streams the sampler shall process " |
tr("The max. amount of disk streams the sampler shall process " |
290 |
"simultaniously.") |
"simultaneously.") |
291 |
); |
); |
292 |
#else |
#else |
293 |
m_ui.MaxVoicesSpinBox->setEnabled(false); |
m_ui.MaxVoicesSpinBox->setEnabled(false); |
300 |
); |
); |
301 |
#endif // CONFIG_MAX_VOICES |
#endif // CONFIG_MAX_VOICES |
302 |
|
|
303 |
|
// Custom display options... |
304 |
|
resetCustomColorThemes(m_pOptions->sCustomColorTheme); |
305 |
|
resetCustomStyleThemes(m_pOptions->sCustomStyleTheme); |
306 |
|
|
307 |
// Done. |
// Done. |
308 |
m_iDirtySetup--; |
m_iDirtySetup--; |
309 |
stabilizeForm(); |
stabilizeForm(); |
337 |
m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value(); |
m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value(); |
338 |
// Other options... |
// Other options... |
339 |
m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked(); |
m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked(); |
340 |
|
m_pOptions->bConfirmRestart = m_ui.ConfirmRestartCheckBox->isChecked(); |
341 |
|
m_pOptions->bConfirmReset = m_ui.ConfirmResetCheckBox->isChecked(); |
342 |
|
m_pOptions->bConfirmError = m_ui.ConfirmErrorCheckBox->isChecked(); |
343 |
m_pOptions->bKeepOnTop = m_ui.KeepOnTopCheckBox->isChecked(); |
m_pOptions->bKeepOnTop = m_ui.KeepOnTopCheckBox->isChecked(); |
344 |
m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked(); |
m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked(); |
345 |
m_pOptions->bCompletePath = m_ui.CompletePathCheckBox->isChecked(); |
m_pOptions->bCompletePath = m_ui.CompletePathCheckBox->isChecked(); |
346 |
m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked(); |
m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked(); |
347 |
m_pOptions->iMaxRecentFiles = m_ui.MaxRecentFilesSpinBox->value(); |
m_pOptions->iMaxRecentFiles = m_ui.MaxRecentFilesSpinBox->value(); |
348 |
m_pOptions->iBaseFontSize = m_ui.BaseFontSizeComboBox->currentText().toInt(); |
m_pOptions->iBaseFontSize = m_ui.BaseFontSizeComboBox->currentText().toInt(); |
349 |
|
// Custom color/style theme options... |
350 |
|
if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0) |
351 |
|
m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText(); |
352 |
|
else |
353 |
|
m_pOptions->sCustomStyleTheme.clear(); |
354 |
|
if (m_ui.CustomColorThemeComboBox->currentIndex() > 0) |
355 |
|
m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText(); |
356 |
|
else |
357 |
|
m_pOptions->sCustomColorTheme.clear(); |
358 |
// Reset dirty flag. |
// Reset dirty flag. |
359 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
360 |
} |
} |
361 |
|
|
362 |
// if the user modified the limits, apply them to the sampler |
// If the user modified the limits, apply them to the sampler |
363 |
// (and store it later in qsampler's configuration) |
// (and store it later in qsampler's configuration) |
364 |
if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled()) |
if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled()) |
365 |
m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value()); |
m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value()); |
388 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
389 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
390 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
391 |
QSAMPLER_TITLE ": " + tr("Warning"), |
tr("Warning"), |
392 |
tr("Some settings have been changed.\n\n" |
tr("Some settings have been changed.\n\n" |
393 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
394 |
QMessageBox::Apply | |
QMessageBox::Apply | |
500 |
void OptionsForm::toggleDisplayEffect ( bool bOn ) |
void OptionsForm::toggleDisplayEffect ( bool bOn ) |
501 |
{ |
{ |
502 |
QPalette pal; |
QPalette pal; |
503 |
pal.setColor(QPalette::Foreground, Qt::green); |
pal.setColor(QPalette::WindowText, Qt::green); |
504 |
if (bOn) { |
if (bOn) { |
505 |
QPixmap pm(":/images/displaybg1.png"); |
QPixmap pm(":/images/displaybg1.png"); |
506 |
pal.setBrush(QPalette::Background, QBrush(pm)); |
pal.setBrush(QPalette::Window, QBrush(pm)); |
507 |
} else { |
} else { |
508 |
pal.setColor(QPalette::Background, Qt::black); |
pal.setColor(QPalette::Window, Qt::black); |
509 |
} |
} |
510 |
m_ui.DisplayFontTextLabel->setPalette(pal); |
m_ui.DisplayFontTextLabel->setPalette(pal); |
511 |
|
|
524 |
optionsChanged(); |
optionsChanged(); |
525 |
} |
} |
526 |
|
|
527 |
|
|
528 |
|
// Custom color palette theme manager. |
529 |
|
void OptionsForm::editCustomColorThemes (void) |
530 |
|
{ |
531 |
|
PaletteForm form(this); |
532 |
|
form.setSettings(&m_pOptions->settings()); |
533 |
|
|
534 |
|
QString sCustomColorTheme; |
535 |
|
int iDirtyCustomColorTheme = 0; |
536 |
|
|
537 |
|
const int iCustomColorTheme |
538 |
|
= m_ui.CustomColorThemeComboBox->currentIndex(); |
539 |
|
if (iCustomColorTheme > 0) { |
540 |
|
sCustomColorTheme = m_ui.CustomColorThemeComboBox->itemText( |
541 |
|
iCustomColorTheme); |
542 |
|
form.setPaletteName(sCustomColorTheme); |
543 |
|
} |
544 |
|
|
545 |
|
if (form.exec() == QDialog::Accepted) { |
546 |
|
sCustomColorTheme = form.paletteName(); |
547 |
|
++iDirtyCustomColorTheme; |
548 |
|
} |
549 |
|
|
550 |
|
if (iDirtyCustomColorTheme > 0 || form.isDirty()) { |
551 |
|
resetCustomColorThemes(sCustomColorTheme); |
552 |
|
optionsChanged(); |
553 |
|
} |
554 |
|
} |
555 |
|
|
556 |
|
|
557 |
|
// Custom color palette themes settler. |
558 |
|
void OptionsForm::resetCustomColorThemes ( |
559 |
|
const QString& sCustomColorTheme ) |
560 |
|
{ |
561 |
|
m_ui.CustomColorThemeComboBox->clear(); |
562 |
|
m_ui.CustomColorThemeComboBox->addItem( |
563 |
|
tr(g_pszDefName)); |
564 |
|
m_ui.CustomColorThemeComboBox->addItems( |
565 |
|
PaletteForm::namedPaletteList(&m_pOptions->settings())); |
566 |
|
|
567 |
|
int iCustomColorTheme = 0; |
568 |
|
if (!sCustomColorTheme.isEmpty()) { |
569 |
|
iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText( |
570 |
|
sCustomColorTheme); |
571 |
|
if (iCustomColorTheme < 0) |
572 |
|
iCustomColorTheme = 0; |
573 |
|
} |
574 |
|
m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme); |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
|
// Custom widget style themes settler. |
579 |
|
void OptionsForm::resetCustomStyleThemes ( |
580 |
|
const QString& sCustomStyleTheme ) |
581 |
|
{ |
582 |
|
m_ui.CustomStyleThemeComboBox->clear(); |
583 |
|
m_ui.CustomStyleThemeComboBox->addItem( |
584 |
|
tr(g_pszDefName)); |
585 |
|
m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys()); |
586 |
|
|
587 |
|
int iCustomStyleTheme = 0; |
588 |
|
if (!sCustomStyleTheme.isEmpty()) { |
589 |
|
iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText( |
590 |
|
sCustomStyleTheme); |
591 |
|
if (iCustomStyleTheme < 0) |
592 |
|
iCustomStyleTheme = 0; |
593 |
|
} |
594 |
|
m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme); |
595 |
|
} |
596 |
|
|
597 |
|
|
598 |
} // namespace QSampler |
} // namespace QSampler |
599 |
|
|
600 |
// end of qsamplerOptionsForm.cpp |
// end of qsamplerOptionsForm.cpp |