diff --git a/res/qml/Mixxx/Controls/Knob.qml b/res/qml/Mixxx/Controls/Knob.qml index be4df729b653..9cc447b55cb6 100644 --- a/res/qml/Mixxx/Controls/Knob.qml +++ b/res/qml/Mixxx/Controls/Knob.qml @@ -67,8 +67,9 @@ Item { // by enabling multisampling, so we use 4xMSAA here. // // See https://www.qt.io/blog/2017/07/07/let-there-be-shapes for details. - layer.enabled: true - layer.samples: 4 + property int multiSamplingLevel: Mixxx.Config.getMultiSamplingLevel() + layer.enabled: multiSamplingLevel != 0 + layer.samples: multiSamplingLevel ShapePath { id: arcPath diff --git a/src/preferences/dialog/dlgprefinterface.cpp b/src/preferences/dialog/dlgprefinterface.cpp index c7c7ade152f8..2fc09b231edb 100644 --- a/src/preferences/dialog/dlgprefinterface.cpp +++ b/src/preferences/dialog/dlgprefinterface.cpp @@ -25,12 +25,14 @@ namespace { const QString kConfigGroup = QStringLiteral("[Config]"); const QString kControlsGroup = QStringLiteral("[Controls]"); +const QString kPreferencesGroup = QStringLiteral("[Preferences]"); const QString kScaleFactorKey = QStringLiteral("ScaleFactor"); const QString kStartInFullscreenKey = QStringLiteral("StartInFullscreen"); const QString kSchemeKey = QStringLiteral("Scheme"); const QString kResizableSkinKey = QStringLiteral("ResizableSkin"); const QString kLocaleKey = QStringLiteral("Locale"); const QString kTooltipsKey = QStringLiteral("Tooltips"); +const QString kMultiSamplingKey = QStringLiteral("multi_sampling"); } // namespace @@ -181,6 +183,31 @@ DlgPrefInterface::DlgPrefInterface( int inhibitsettings = static_cast(m_pScreensaverManager->status()); comboBoxScreensaver->setCurrentIndex(comboBoxScreensaver->findData(inhibitsettings)); + // 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), 0); + int mulitSamplingIndex = mulitSamplingComboBox->findData(m_multiSampling); + if (mulitSamplingIndex != -1) { + mulitSamplingComboBox->setCurrentIndex(mulitSamplingIndex); + } else { + mulitSamplingComboBox->setCurrentIndex(0); + m_pConfig->set(ConfigKey(kPreferencesGroup, kMultiSamplingKey), ConfigValue(0)); + } + } else +#endif + { + mulitSamplingLabel->hide(); + mulitSamplingComboBox->hide(); + } + // Tooltip configuration connect(buttonGroupTooltips, QOverload::of(&QButtonGroup::buttonClicked), @@ -319,7 +346,7 @@ void DlgPrefInterface::notifyRebootNecessary() { // make the fact that you have to restart mixxx more obvious QMessageBox::information(this, tr("Information"), - tr("Mixxx must be restarted before the new locale or scaling " + tr("Mixxx must be restarted before the new locale, scaling or multi-sampling " "settings will take effect.")); } @@ -418,11 +445,18 @@ void DlgPrefInterface::slotApply() { static_cast(screensaverComboBoxState)); } - if (locale != m_localeOnUpdate || scaleFactor != m_dScaleFactor) { + int multiSampling = mulitSamplingComboBox->itemData( + mulitSamplingComboBox->currentIndex()) + .toInt(); + m_pConfig->set(ConfigKey(kPreferencesGroup, kMultiSamplingKey), ConfigValue(multiSampling)); + + if (locale != m_localeOnUpdate || scaleFactor != m_dScaleFactor || + multiSampling != m_multiSampling) { notifyRebootNecessary(); // hack to prevent showing the notification when pressing "Okay" after "Apply" m_localeOnUpdate = locale; m_dScaleFactor = scaleFactor; + m_multiSampling = multiSampling; } // load skin/scheme if necessary diff --git a/src/preferences/dialog/dlgprefinterface.h b/src/preferences/dialog/dlgprefinterface.h index 57dbe29abd92..bd735d949c94 100644 --- a/src/preferences/dialog/dlgprefinterface.h +++ b/src/preferences/dialog/dlgprefinterface.h @@ -68,6 +68,7 @@ class DlgPrefInterface : public DlgPreferencePage, public Ui::DlgPrefControlsDlg QString m_colorScheme; QString m_colorSchemeOnUpdate; QString m_localeOnUpdate; + int 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 bf3c858f58e2..590363608b9f 100644 --- a/src/preferences/dialog/dlgprefinterfacedlg.ui +++ b/src/preferences/dialog/dlgprefinterfacedlg.ui @@ -269,7 +269,16 @@ - + + + + Multi-Sampling + + + + + + diff --git a/src/qml/qmlconfigproxy.cpp b/src/qml/qmlconfigproxy.cpp index 4bdaaccf15d0..e1ad44009aec 100644 --- a/src/qml/qmlconfigproxy.cpp +++ b/src/qml/qmlconfigproxy.cpp @@ -11,6 +11,10 @@ QVariantList paletteToQColorList(const ColorPalette& palette) { } return colors; } + +const QString kPreferencesGroup = QStringLiteral("[Preferences]"); +const QString kMultiSamplingKey = QStringLiteral("multi_sampling"); + } // namespace namespace mixxx { @@ -31,6 +35,11 @@ QVariantList QmlConfigProxy::getTrackColorPalette() { return paletteToQColorList(colorPaletteSettings.getTrackColorPalette()); } +int QmlConfigProxy::getMultiSamplingLevel() { + ColorPaletteSettings colorPaletteSettings(m_pConfig); + return m_pConfig->getValue(ConfigKey(kPreferencesGroup, kMultiSamplingKey), 0); +} + // static QmlConfigProxy* QmlConfigProxy::create(QQmlEngine* pQmlEngine, QJSEngine* pJsEngine) { // The implementation of this method is mostly taken from the code example diff --git a/src/qml/qmlconfigproxy.h b/src/qml/qmlconfigproxy.h index e8e69021f7e1..cfa4994d994b 100644 --- a/src/qml/qmlconfigproxy.h +++ b/src/qml/qmlconfigproxy.h @@ -18,8 +18,11 @@ class QmlConfigProxy : public QObject { UserSettingsPointer pConfig, QObject* parent = nullptr); + // We use method here instead of properties as there is no way to achieve property binding + // with UserSettings, since there is no synchronisation upon mutations. Q_INVOKABLE QVariantList getHotcueColorPalette(); Q_INVOKABLE QVariantList getTrackColorPalette(); + Q_INVOKABLE int getMultiSamplingLevel(); static QmlConfigProxy* create(QQmlEngine* pQmlEngine, QJSEngine* pJsEngine); static inline void registerUserSettings(UserSettingsPointer pConfig) {