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

Pref multi sampling enum #12796

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 12 additions & 0 deletions src/preferences/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace mixxx {

Q_NAMESPACE

// Don't change these constants since they are stored in user configuration
// files.
enum class TooltipsPreference {
Expand All @@ -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
72 changes: 47 additions & 25 deletions src/preferences/dialog/dlgprefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mixxx::MultiSamplingMode>(
ConfigKey(kPreferencesGroup, kMultiSamplingKey),
mixxx::MultiSamplingMode::Four);
int multiSamplingIndex = multiSamplingComboBox->findData(
static_cast<int>(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
Expand Down Expand Up @@ -325,6 +334,11 @@ void DlgPrefInterface::slotResetToDefaults() {
comboBoxScreensaver->setCurrentIndex(comboBoxScreensaver->findData(
static_cast<int>(mixxx::ScreenSaverPreference::PREVENT_ON)));

#ifdef MIXXX_USE_QML
multiSamplingComboBox->setCurrentIndex(multiSamplingComboBox->findData(
static_cast<int>(mixxx::MultiSamplingMode::Four))); // 4x MSAA
#endif

#ifdef Q_OS_IOS
// Tooltips off everywhere.
radioButtonTooltipsOff->setChecked(true);
Expand Down Expand Up @@ -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;
Expand All @@ -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<int>(m_pScreensaverManager->status());
if (screensaverComboBoxState != screensaverConfiguredState) {
m_pScreensaverManager->setStatus(
static_cast<mixxx::ScreenSaverPreference>(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<mixxx::MultiSamplingMode>();
// m_pConfig->setValue<mixxx::MultiSamplingMode>(ConfigKey(kPreferencesGroup,
// kMultiSamplingKey), ConfigValue(multiSampling));
m_pConfig->setValue<mixxx::MultiSamplingMode>(
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
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgprefinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/preferences/dialog/dlgprefinterfacedlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@
<widget class="QComboBox" name="comboBoxScreensaver"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="mulitSamplingLabel">
<widget class="QLabel" name="multiSamplingLabel">
<property name="text">
<string>Multi-Sampling</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="mulitSamplingComboBox"/>
<widget class="QComboBox" name="multiSamplingComboBox"/>
</item>
</layout>
</widget>
Expand All @@ -294,6 +294,7 @@
<tabstop>radioButtonTooltipsOff</tabstop>
<tabstop>radioButtonTooltipsLibrary</tabstop>
<tabstop>radioButtonTooltipsLibraryAndSkin</tabstop>
<tabstop>multiSamplingComboBox</tabstop>
</tabstops>
<resources/>
<connections/>
Expand Down
5 changes: 4 additions & 1 deletion src/qml/qmlconfigproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "moc_qmlconfigproxy.cpp"
#include "preferences/colorpalettesettings.h"
#include "preferences/constants.h"

namespace {
QVariantList paletteToQColorList(const ColorPalette& palette) {
Expand Down Expand Up @@ -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<int>(mixxx::MultiSamplingMode::Disabled));
}

// static
Expand Down
Loading