--- qsampler/trunk/src/qsamplerOptionsForm.cpp 2008/07/02 13:19:09 1749 +++ qsampler/trunk/src/qsamplerOptionsForm.cpp 2010/03/29 17:00:30 2074 @@ -1,7 +1,7 @@ // qsamplerOptionsForm.cpp // /**************************************************************************** - Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2007, Christian Schoenebeck This program is free software; you can redistribute it and/or @@ -127,6 +127,12 @@ QObject::connect(m_ui.BaseFontSizeComboBox, SIGNAL(editTextChanged(const QString&)), SLOT(optionsChanged())); + QObject::connect(m_ui.MaxVoicesSpinBox, + SIGNAL(valueChanged(int)), + SLOT(maxVoicesChanged(int))); + QObject::connect(m_ui.MaxStreamsSpinBox, + SIGNAL(valueChanged(int)), + SLOT(maxStreamsChanged(int))); QObject::connect(m_ui.OkPushButton, SIGNAL(clicked()), SLOT(accept())); @@ -192,9 +198,9 @@ // Messages font. if (m_pOptions->sMessagesFont.isEmpty() || !font.fromString(m_pOptions->sMessagesFont)) - font = QFont("Fixed", 8); + font = QFont("Monospace", 8); pal = m_ui.MessagesFontTextLabel->palette(); - pal.setColor(QPalette::Background, Qt::white); + pal.setColor(QPalette::Background, pal.base().color()); m_ui.MessagesFontTextLabel->setPalette(pal); m_ui.MessagesFontTextLabel->setFont(font); m_ui.MessagesFontTextLabel->setText(font.family() @@ -220,6 +226,49 @@ m_ui.InstrumentNamesCheckBox->setEnabled(false); #endif + bMaxVoicesModified = bMaxStreamsModified = false; +#ifdef CONFIG_MAX_VOICES + const bool bMaxVoicesSupported = + m_pOptions->getEffectiveMaxVoices() >= 0; + const bool bMaxStreamsSupported = + m_pOptions->getEffectiveMaxStreams() >= 0; + + m_ui.MaxVoicesSpinBox->setEnabled(bMaxVoicesSupported); + m_ui.MaxVoicesSpinBox->setValue(m_pOptions->getMaxVoices()); + if (!bMaxVoicesSupported) + m_ui.MaxVoicesSpinBox->setToolTip( + tr("This parameter is not supported by the current sampler " + "version in use.") + ); + else + m_ui.MaxVoicesSpinBox->setToolTip( + tr("The max. amount of voices the sampler shall process " + "simultaniously.") + ); + + m_ui.MaxStreamsSpinBox->setEnabled(bMaxStreamsSupported); + m_ui.MaxStreamsSpinBox->setValue(m_pOptions->getMaxStreams()); + if (!bMaxStreamsSupported) + m_ui.MaxStreamsSpinBox->setToolTip( + tr("This parameter is not supported by the current sampler " + "version in use.") + ); + else + m_ui.MaxStreamsSpinBox->setToolTip( + tr("The max. amount of disk streams the sampler shall process " + "simultaniously.") + ); +#else + m_ui.MaxVoicesSpinBox->setEnabled(false); + m_ui.MaxStreamsSpinBox->setEnabled(false); + m_ui.MaxVoicesSpinBox->setToolTip( + tr("QSampler was built without support for this parameter.") + ); + m_ui.MaxStreamsSpinBox->setToolTip( + tr("QSampler was built without support for this parameter.") + ); +#endif // CONFIG_MAX_VOICES + // Done. m_iDirtySetup--; stabilizeForm(); @@ -263,12 +312,22 @@ m_iDirtyCount = 0; } + // if the user modified the limits, apply them to the sampler + // (and store it later in qsampler's configuration) + if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled()) + m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value()); + if (bMaxStreamsModified && m_ui.MaxStreamsSpinBox->isEnabled()) + m_pOptions->setMaxStreams(m_ui.MaxStreamsSpinBox->value()); + // Save combobox history... m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox); m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox); m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox); m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox); + // Save/commit to disk. + m_pOptions->saveOptions(); + // Just go with dialog acceptance. QDialog::accept(); } @@ -285,11 +344,13 @@ QSAMPLER_TITLE ": " + tr("Warning"), tr("Some settings have been changed.\n\n" "Do you want to apply the changes?"), - tr("Apply"), tr("Discard"), tr("Cancel"))) { - case 0: // Apply... + QMessageBox::Apply | + QMessageBox::Discard | + QMessageBox::Cancel)) { + case QMessageBox::Apply: accept(); return; - case 1: // Discard + case QMessageBox::Discard: break; default: // Cancel. bReject = false; @@ -394,7 +455,7 @@ QPalette pal; pal.setColor(QPalette::Foreground, Qt::green); if (bOn) { - QPixmap pm(":/icons/displaybg1.png"); + QPixmap pm(":/images/displaybg1.png"); pal.setBrush(QPalette::Background, QBrush(pm)); } else { pal.setColor(QPalette::Background, Qt::black); @@ -404,7 +465,18 @@ optionsChanged(); } -} // namespace QSampler +void OptionsForm::maxVoicesChanged(int /*iMaxVoices*/) +{ + bMaxVoicesModified = true; + optionsChanged(); +} +void OptionsForm::maxStreamsChanged(int /*iMaxStreams*/) +{ + bMaxStreamsModified = true; + optionsChanged(); +} + +} // namespace QSampler // end of qsamplerOptionsForm.cpp