diff --git a/src/preferences/constants.h b/src/preferences/constants.h index 57f96a3b247..796e31e0c9d 100644 --- a/src/preferences/constants.h +++ b/src/preferences/constants.h @@ -2,6 +2,8 @@ namespace mixxx { +Q_NAMESPACE + // Don't change these constants since they are stored in user configuration // files. enum class TooltipsPreference { @@ -17,4 +19,14 @@ enum class ScreenSaverPreference { PREVENT_ON_PLAY = 2 }; +enum class MultiSamplingMode { + Disabled = 0, + Two = 2, + Four = 4, + Eight = 8, + Sixteen = 16 +}; + +Q_ENUM_NS(MultiSamplingMode); + } // namespace mixxx diff --git a/src/preferences/dialog/dlgprefinterface.cpp b/src/preferences/dialog/dlgprefinterface.cpp index 4da8e1d507b..463f9c84208 100644 --- a/src/preferences/dialog/dlgprefinterface.cpp +++ b/src/preferences/dialog/dlgprefinterface.cpp @@ -182,26 +182,35 @@ DlgPrefInterface::DlgPrefInterface( // Multi-Sampling #ifdef MIXXX_USE_QML if (CmdlineArgs::Instance().isQml()) { - mulitSamplingComboBox->clear(); - mulitSamplingComboBox->addItem(tr("Disabled"), 0); - mulitSamplingComboBox->addItem(tr("2x MSAA"), 2); - mulitSamplingComboBox->addItem(tr("4x MSAA"), 4); - mulitSamplingComboBox->addItem(tr("8x MSAA"), 8); - mulitSamplingComboBox->addItem(tr("16x MSAA"), 16); - - m_multiSampling = m_pConfig->getValue(ConfigKey(kPreferencesGroup, kMultiSamplingKey), 4); - int mulitSamplingIndex = mulitSamplingComboBox->findData(m_multiSampling); - if (mulitSamplingIndex != -1) { - mulitSamplingComboBox->setCurrentIndex(mulitSamplingIndex); + multiSamplingComboBox->clear(); + multiSamplingComboBox->addItem(tr("Disabled"), + QVariant::fromValue(mixxx::MultiSamplingMode::Disabled)); + multiSamplingComboBox->addItem(tr("2x MSAA"), + QVariant::fromValue(mixxx::MultiSamplingMode::Two)); + multiSamplingComboBox->addItem(tr("4x MSAA"), + QVariant::fromValue(mixxx::MultiSamplingMode::Four)); + multiSamplingComboBox->addItem(tr("8x MSAA"), + QVariant::fromValue(mixxx::MultiSamplingMode::Eight)); + multiSamplingComboBox->addItem(tr("16x MSAA"), + QVariant::fromValue(mixxx::MultiSamplingMode::Sixteen)); + + m_multiSampling = m_pConfig->getValue( + ConfigKey(kPreferencesGroup, kMultiSamplingKey), + mixxx::MultiSamplingMode::Four); + int multiSamplingIndex = multiSamplingComboBox->findData( + static_cast(m_multiSampling)); + if (multiSamplingIndex != -1) { + multiSamplingComboBox->setCurrentIndex(multiSamplingIndex); } else { - mulitSamplingComboBox->setCurrentIndex(0); - m_pConfig->set(ConfigKey(kPreferencesGroup, kMultiSamplingKey), ConfigValue(0)); + multiSamplingComboBox->setCurrentIndex(0); // Disabled + m_pConfig->setValue(ConfigKey(kPreferencesGroup, kMultiSamplingKey), + mixxx::MultiSamplingMode::Disabled); } } else #endif { - mulitSamplingLabel->hide(); - mulitSamplingComboBox->hide(); + multiSamplingLabel->hide(); + multiSamplingComboBox->hide(); } // Tooltip configuration @@ -325,6 +334,11 @@ void DlgPrefInterface::slotResetToDefaults() { comboBoxScreensaver->setCurrentIndex(comboBoxScreensaver->findData( static_cast(mixxx::ScreenSaverPreference::PREVENT_ON))); +#ifdef MIXXX_USE_QML + multiSamplingComboBox->setCurrentIndex(multiSamplingComboBox->findData( + static_cast(mixxx::MultiSamplingMode::Four))); // 4x MSAA +#endif + #ifdef Q_OS_IOS // Tooltips off everywhere. radioButtonTooltipsOff->setChecked(true); @@ -423,8 +437,7 @@ void DlgPrefInterface::slotApply() { m_pConfig->set(ConfigKey(kConfigGroup, kSchemeKey), m_colorScheme); } - QString locale = ComboBoxLocale->itemData( - ComboBoxLocale->currentIndex()).toString(); + QString locale = ComboBoxLocale->currentData().toString(); m_pConfig->set(ConfigKey(kConfigGroup, kLocaleKey), locale); double scaleFactor = spinBoxScaleFactor->value() / 100; @@ -438,26 +451,35 @@ void DlgPrefInterface::slotApply() { emit tooltipModeChanged(m_tooltipMode); // screensaver mode update - int screensaverComboBoxState = comboBoxScreensaver->itemData( - comboBoxScreensaver->currentIndex()).toInt(); + int screensaverComboBoxState = comboBoxScreensaver->currentData().toInt(); int screensaverConfiguredState = static_cast(m_pScreensaverManager->status()); if (screensaverComboBoxState != screensaverConfiguredState) { m_pScreensaverManager->setStatus( static_cast(screensaverComboBoxState)); } - int multiSampling = mulitSamplingComboBox->itemData( - mulitSamplingComboBox->currentIndex()) - .toInt(); - m_pConfig->set(ConfigKey(kPreferencesGroup, kMultiSamplingKey), ConfigValue(multiSampling)); +#ifdef MIXXX_USE_QML + mixxx::MultiSamplingMode multiSampling = + multiSamplingComboBox->currentData() + .value(); + // m_pConfig->setValue(ConfigKey(kPreferencesGroup, + // kMultiSamplingKey), ConfigValue(multiSampling)); + m_pConfig->setValue( + ConfigKey(kPreferencesGroup, kMultiSamplingKey), multiSampling); +#endif - if (locale != m_localeOnUpdate || scaleFactor != m_dScaleFactor || - multiSampling != m_multiSampling) { + if (locale != m_localeOnUpdate || scaleFactor != m_dScaleFactor +#ifdef MIXXX_USE_QML + || multiSampling != m_multiSampling +#endif + ) { notifyRebootNecessary(); // hack to prevent showing the notification when pressing "Okay" after "Apply" m_localeOnUpdate = locale; m_dScaleFactor = scaleFactor; +#ifdef MIXXX_USE_QML m_multiSampling = multiSampling; +#endif } // load skin/scheme if necessary diff --git a/src/preferences/dialog/dlgprefinterface.h b/src/preferences/dialog/dlgprefinterface.h index bd735d949c9..5c62b6bd9f4 100644 --- a/src/preferences/dialog/dlgprefinterface.h +++ b/src/preferences/dialog/dlgprefinterface.h @@ -68,7 +68,7 @@ class DlgPrefInterface : public DlgPreferencePage, public Ui::DlgPrefControlsDlg QString m_colorScheme; QString m_colorSchemeOnUpdate; QString m_localeOnUpdate; - int m_multiSampling; + mixxx::MultiSamplingMode m_multiSampling; mixxx::TooltipsPreference m_tooltipMode; double m_dScaleFactor; double m_minScaleFactor; diff --git a/src/preferences/dialog/dlgprefinterfacedlg.ui b/src/preferences/dialog/dlgprefinterfacedlg.ui index 590363608b9..68215939eb9 100644 --- a/src/preferences/dialog/dlgprefinterfacedlg.ui +++ b/src/preferences/dialog/dlgprefinterfacedlg.ui @@ -270,14 +270,14 @@ - + Multi-Sampling - + @@ -294,6 +294,7 @@ radioButtonTooltipsOff radioButtonTooltipsLibrary radioButtonTooltipsLibraryAndSkin + multiSamplingComboBox diff --git a/src/qml/qmlconfigproxy.cpp b/src/qml/qmlconfigproxy.cpp index 216e36d0db5..6045f1fab4a 100644 --- a/src/qml/qmlconfigproxy.cpp +++ b/src/qml/qmlconfigproxy.cpp @@ -2,6 +2,7 @@ #include "moc_qmlconfigproxy.cpp" #include "preferences/colorpalettesettings.h" +#include "preferences/constants.h" namespace { QVariantList paletteToQColorList(const ColorPalette& palette) { @@ -36,7 +37,9 @@ QVariantList QmlConfigProxy::getTrackColorPalette() { } int QmlConfigProxy::getMultiSamplingLevel() { - return m_pConfig->getValue(ConfigKey(kPreferencesGroup, kMultiSamplingKey), 0); + return m_pConfig->getValue( + ConfigKey(kPreferencesGroup, kMultiSamplingKey), + static_cast(mixxx::MultiSamplingMode::Disabled)); } // static