Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add multi-sampling settings for QML #12546

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions res/qml/Mixxx/Controls/Knob.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 > 1
layer.samples: multiSamplingLevel

ShapePath {
id: arcPath
Expand Down
38 changes: 36 additions & 2 deletions src/preferences/dialog/dlgprefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,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");
acolombier marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we don't call it "multi_sampling" instead of "msaa" everywhere? The latter is much less ambiguous IMHO.


} // namespace

Expand Down Expand Up @@ -182,6 +184,31 @@ DlgPrefInterface::DlgPrefInterface(
int inhibitsettings = static_cast<int>(m_pScreensaverManager->status());
comboBoxScreensaver->setCurrentIndex(comboBoxScreensaver->findData(inhibitsettings));

// Multi-Sampling
#ifdef MIXXX_USE_QML
if (CmdlineArgs::Instance().isQml()) {
mulitSamplingComboBox->clear();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn... why did CI not catch this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codespell uses a dictionary of common misspellings and does not support camelcase at the moment. The chance that "mulitsamplingcombobox" is in the dict is rather small :)

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);
} else {
mulitSamplingComboBox->setCurrentIndex(0);
m_pConfig->set(ConfigKey(kPreferencesGroup, kMultiSamplingKey), ConfigValue(0));
}
} else
#endif
{
mulitSamplingLabel->hide();
mulitSamplingComboBox->hide();
}

// Tooltip configuration
connect(buttonGroupTooltips,
QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked),
Expand Down Expand Up @@ -325,7 +352,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."));
}

Expand Down Expand Up @@ -424,11 +451,18 @@ void DlgPrefInterface::slotApply() {
static_cast<mixxx::ScreenSaverPreference>(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
Expand Down
1 change: 1 addition & 0 deletions src/preferences/dialog/dlgprefinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion src/preferences/dialog/dlgprefinterfacedlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,16 @@
<item row="4" column="1" colspan="2">
<widget class="QComboBox" name="comboBoxScreensaver"/>
</item>

<item row="5" column="0">
<widget class="QLabel" name="mulitSamplingLabel">
<property name="text">
<string>Multi-Sampling</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="mulitSamplingComboBox"/>
</item>
</layout>
</widget>
</item>
Expand Down
8 changes: 8 additions & 0 deletions src/qml/qmlconfigproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -31,6 +35,10 @@ QVariantList QmlConfigProxy::getTrackColorPalette() {
return paletteToQColorList(colorPaletteSettings.getTrackColorPalette());
}

int QmlConfigProxy::getMultiSamplingLevel() {
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
Expand Down
3 changes: 3 additions & 0 deletions src/qml/qmlconfigproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
acolombier marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down
Loading