Skip to content

Commit

Permalink
hide preferences::constants namespace by use of inline namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed May 16, 2024
1 parent 9a022ac commit 25f796f
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 60 deletions.
16 changes: 8 additions & 8 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ MixxxMainWindow::MixxxMainWindow(std::shared_ptr<mixxx::CoreServices> pCoreServi
#endif
m_pDeveloperToolsDlg(nullptr),
m_pPrefDlg(nullptr),
m_toolTipsCfg(mixxx::preferences::constants::Tooltips::On) {
m_toolTipsCfg(mixxx::Tooltips::On) {
DEBUG_ASSERT(pCoreServices);
// These depend on the settings
#ifdef __LINUX__
Expand Down Expand Up @@ -175,10 +175,10 @@ void MixxxMainWindow::initialize() {
// Set the visibility of tooltips, default "1" = ON
m_toolTipsCfg = pConfig->getValue(
ConfigKey("[Controls]", "Tooltips"),
mixxx::preferences::constants::Tooltips::On);
mixxx::Tooltips::On);
#ifdef MIXXX_USE_QOPENGL
ToolTipQOpenGL::singleton().setActive(
m_toolTipsCfg == mixxx::preferences::constants::Tooltips::On);
m_toolTipsCfg == mixxx::Tooltips::On);
#endif

#ifdef __ENGINEPRIME__
Expand Down Expand Up @@ -1153,11 +1153,11 @@ void MixxxMainWindow::slotShowKeywheel(bool toggle) {
}
}

void MixxxMainWindow::slotTooltipModeChanged(mixxx::preferences::constants::Tooltips tt) {
void MixxxMainWindow::slotTooltipModeChanged(mixxx::Tooltips tt) {
m_toolTipsCfg = tt;
#ifdef MIXXX_USE_QOPENGL
ToolTipQOpenGL::singleton().setActive(
m_toolTipsCfg == mixxx::preferences::constants::Tooltips::On);
m_toolTipsCfg == mixxx::Tooltips::On);
#endif
}

Expand Down Expand Up @@ -1260,14 +1260,14 @@ bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) {
"DlgPreferences") {
// return true for no tool tips
switch (m_toolTipsCfg) {
case mixxx::preferences::constants::Tooltips::OnlyInLibrary:
case mixxx::Tooltips::OnlyInLibrary:
if (dynamic_cast<WBaseWidget*>(obj) != nullptr) {
return true;
}
break;
case mixxx::preferences::constants::Tooltips::On:
case mixxx::Tooltips::On:
break;
case mixxx::preferences::constants::Tooltips::Off:
case mixxx::Tooltips::Off:
return true;
default:
DEBUG_ASSERT(!"m_toolTipsCfg value unknown");
Expand Down
10 changes: 5 additions & 5 deletions src/mixxxmainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class MixxxMainWindow : public QMainWindow {
/// creates the menu_bar and inserts the file Menu
void createMenuBar();
void connectMenuBar();
void setInhibitScreensaver(mixxx::preferences::constants::ScreenSaver inhibit);
mixxx::preferences::constants::ScreenSaver getInhibitScreensaver();
void setInhibitScreensaver(mixxx::ScreenSaver inhibit);
mixxx::ScreenSaver getInhibitScreensaver();

inline GuiTick* getGuiTick() { return m_pGuiTick; };

Expand Down Expand Up @@ -87,7 +87,7 @@ class MixxxMainWindow : public QMainWindow {
void initializationProgressUpdate(int progress, const QString& serviceName);

private slots:
void slotTooltipModeChanged(mixxx::preferences::constants::Tooltips tt);
void slotTooltipModeChanged(mixxx::Tooltips tt);

signals:
void skinLoaded();
Expand Down Expand Up @@ -148,9 +148,9 @@ class MixxxMainWindow : public QMainWindow {
std::unique_ptr<mixxx::LibraryExporter> m_pLibraryExporter;
#endif

mixxx::preferences::constants::Tooltips m_toolTipsCfg;
mixxx::Tooltips m_toolTipsCfg;

mixxx::preferences::constants::ScreenSaver m_inhibitScreensaver;
mixxx::ScreenSaver m_inhibitScreensaver;

QSet<ControlObject*> m_skinCreatedControls;
};
4 changes: 2 additions & 2 deletions src/preferences/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace mixxx {

namespace preferences {
inline namespace preferences {

namespace constants {
inline namespace constants {
Q_NAMESPACE

// In order for this Q_NAMESPACE to work, all members of the namespace must
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
void resetToDefaults();

void reloadUserInterface();
void tooltipModeChanged(mixxx::preferences::constants::Tooltips tooltipMode);
void tooltipModeChanged(mixxx::Tooltips tooltipMode);
void menuBarAutoHideChanged();

protected:
Expand Down
54 changes: 26 additions & 28 deletions src/preferences/dialog/dlgprefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const bool kHideMenuBarDefault = true;

} // namespace

using namespace mixxx::preferences;

DlgPrefInterface::DlgPrefInterface(
QWidget* parent,
std::shared_ptr<mixxx::ScreensaverManager> pScreensaverManager,
Expand Down Expand Up @@ -181,11 +179,11 @@ DlgPrefInterface::DlgPrefInterface(
// Screensaver mode
comboBoxScreensaver->clear();
comboBoxScreensaver->addItem(tr("Allow screensaver to run"),
QVariant::fromValue(constants::ScreenSaver::Off));
QVariant::fromValue(mixxx::ScreenSaver::Off));
comboBoxScreensaver->addItem(tr("Prevent screensaver from running"),
QVariant::fromValue((constants::ScreenSaver::On)));
QVariant::fromValue((mixxx::ScreenSaver::On)));
comboBoxScreensaver->addItem(tr("Prevent screensaver while playing"),
QVariant::fromValue(constants::ScreenSaver::OnPlay));
QVariant::fromValue(mixxx::ScreenSaver::OnPlay));

comboBoxScreensaver->setCurrentIndex(comboBoxScreensaver->findData(
QVariant::fromValue(m_pScreensaverManager->status())));
Expand All @@ -195,27 +193,27 @@ DlgPrefInterface::DlgPrefInterface(
if (CmdlineArgs::Instance().isQml()) {
multiSamplingComboBox->clear();
multiSamplingComboBox->addItem(tr("Disabled"),
QVariant::fromValue(constants::MultiSamplingMode::Disabled));
QVariant::fromValue(mixxx::MultiSamplingMode::Disabled));
multiSamplingComboBox->addItem(tr("2x MSAA"),
QVariant::fromValue(constants::MultiSamplingMode::Two));
QVariant::fromValue(mixxx::MultiSamplingMode::Two));
multiSamplingComboBox->addItem(tr("4x MSAA"),
QVariant::fromValue(constants::MultiSamplingMode::Four));
QVariant::fromValue(mixxx::MultiSamplingMode::Four));
multiSamplingComboBox->addItem(tr("8x MSAA"),
QVariant::fromValue(constants::MultiSamplingMode::Eight));
QVariant::fromValue(mixxx::MultiSamplingMode::Eight));
multiSamplingComboBox->addItem(tr("16x MSAA"),
QVariant::fromValue(constants::MultiSamplingMode::Sixteen));
QVariant::fromValue(mixxx::MultiSamplingMode::Sixteen));

m_multiSampling = m_pConfig->getValue<constants::MultiSamplingMode>(
m_multiSampling = m_pConfig->getValue<mixxx::MultiSamplingMode>(
ConfigKey(kPreferencesGroup, kMultiSamplingKey),
constants::MultiSamplingMode::Four);
mixxx::MultiSamplingMode::Four);
int multiSamplingIndex = multiSamplingComboBox->findData(
QVariant::fromValue((m_multiSampling)));
if (multiSamplingIndex != -1) {
multiSamplingComboBox->setCurrentIndex(multiSamplingIndex);
} else {
multiSamplingComboBox->setCurrentIndex(0); // Disabled
m_pConfig->setValue(ConfigKey(kPreferencesGroup, kMultiSamplingKey),
constants::MultiSamplingMode::Disabled);
mixxx::MultiSamplingMode::Disabled);
}
} else
#endif
Expand Down Expand Up @@ -354,12 +352,12 @@ void DlgPrefInterface::slotResetToDefaults() {

// Inhibit the screensaver
comboBoxScreensaver->setCurrentIndex(comboBoxScreensaver->findData(
QVariant::fromValue(constants::ScreenSaver::On)));
QVariant::fromValue(mixxx::ScreenSaver::On)));

#ifdef MIXXX_USE_QML
multiSamplingComboBox->setCurrentIndex(
multiSamplingComboBox->findData(QVariant::fromValue(
constants::MultiSamplingMode::Four))); // 4x MSAA
mixxx::MultiSamplingMode::Four))); // 4x MSAA
#endif

#ifdef Q_OS_IOS
Expand All @@ -372,11 +370,11 @@ void DlgPrefInterface::slotResetToDefaults() {
}

void DlgPrefInterface::slotSetTooltips() {
m_tooltipMode = constants::Tooltips::On;
m_tooltipMode = mixxx::Tooltips::On;
if (radioButtonTooltipsOff->isChecked()) {
m_tooltipMode = constants::Tooltips::Off;
m_tooltipMode = mixxx::Tooltips::Off;
} else if (radioButtonTooltipsLibrary->isChecked()) {
m_tooltipMode = constants::Tooltips::OnlyInLibrary;
m_tooltipMode = mixxx::Tooltips::OnlyInLibrary;
}
}

Expand Down Expand Up @@ -479,17 +477,17 @@ void DlgPrefInterface::slotApply() {

// screensaver mode update
const auto screensaverComboBoxState =
comboBoxScreensaver->currentData().value<constants::ScreenSaver>();
comboBoxScreensaver->currentData().value<mixxx::ScreenSaver>();
const auto screensaverConfiguredState = m_pScreensaverManager->status();
if (screensaverComboBoxState != screensaverConfiguredState) {
m_pScreensaverManager->setStatus(screensaverComboBoxState);
}

#ifdef MIXXX_USE_QML
constants::MultiSamplingMode multiSampling =
mixxx::MultiSamplingMode multiSampling =
multiSamplingComboBox->currentData()
.value<constants::MultiSamplingMode>();
m_pConfig->setValue<constants::MultiSamplingMode>(
.value<mixxx::MultiSamplingMode>();
m_pConfig->setValue<mixxx::MultiSamplingMode>(
ConfigKey(kPreferencesGroup, kMultiSamplingKey), multiSampling);
#endif

Expand Down Expand Up @@ -520,20 +518,20 @@ void DlgPrefInterface::slotApply() {

void DlgPrefInterface::loadTooltipPreferenceFromConfig() {
const auto tooltipMode =
m_pConfig->getValue<constants::Tooltips>(ConfigKey(kControlsGroup, kTooltipsKey),
m_pConfig->getValue<mixxx::Tooltips>(ConfigKey(kControlsGroup, kTooltipsKey),
#ifdef Q_OS_IOS
constants::Tooltips::Off);
mixxx::Tooltips::Off);
#else
constants::Tooltips::On);
mixxx::Tooltips::On);
#endif
switch (tooltipMode) {
case constants::Tooltips::Off:
case mixxx::Tooltips::Off:
radioButtonTooltipsOff->setChecked(true);
break;
case constants::Tooltips::OnlyInLibrary:
case mixxx::Tooltips::OnlyInLibrary:
radioButtonTooltipsLibrary->setChecked(true);
break;
case constants::Tooltips::On:
case mixxx::Tooltips::On:
default:
radioButtonTooltipsLibraryAndSkin->setChecked(true);
break;
Expand Down
8 changes: 4 additions & 4 deletions src/preferences/dialog/dlgprefinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DlgPrefInterface : public DlgPreferencePage, public Ui::DlgPrefControlsDlg
signals:
void reloadUserInterface();
void menuBarAutoHideChanged();
void tooltipModeChanged(mixxx::preferences::constants::Tooltips tooltipMode);
void tooltipModeChanged(mixxx::Tooltips tooltipMode);

private:
void notifyRebootNecessary();
Expand All @@ -69,10 +69,10 @@ class DlgPrefInterface : public DlgPreferencePage, public Ui::DlgPrefControlsDlg
QString m_colorScheme;
QString m_colorSchemeOnUpdate;
QString m_localeOnUpdate;
mixxx::preferences::constants::MultiSamplingMode m_multiSampling;
mixxx::preferences::constants::Tooltips m_tooltipMode;
mixxx::MultiSamplingMode m_multiSampling;
mixxx::Tooltips m_tooltipMode;
double m_dScaleFactor;
double m_minScaleFactor;
double m_dDevicePixelRatio;
mixxx::preferences::constants::ScreenSaver m_screensaverMode;
mixxx::ScreenSaver m_screensaverMode;
};
2 changes: 1 addition & 1 deletion src/qml/qmlconfigproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ QVariantList QmlConfigProxy::getTrackColorPalette() {
int QmlConfigProxy::getMultiSamplingLevel() {
return static_cast<int>(m_pConfig->getValue(
ConfigKey(kPreferencesGroup, kMultiSamplingKey),
mixxx::preferences::constants::MultiSamplingMode::Disabled));
mixxx::MultiSamplingMode::Disabled));
}

// static
Expand Down
16 changes: 8 additions & 8 deletions src/util/screensavermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ ScreensaverManager::ScreensaverManager(UserSettingsPointer pConfig, QObject* pPa
: QObject(pParent), m_pConfig(pConfig) {
m_inhibitScreensaver =
pConfig->getValue(ConfigKey("[Config]", "InhibitScreensaver"),
mixxx::preferences::constants::ScreenSaver::On);
mixxx::ScreenSaver::On);
pConfig->setValue(ConfigKey("[Config]", "InhibitScreensaver"), m_inhibitScreensaver);
if (m_inhibitScreensaver == mixxx::preferences::constants::ScreenSaver::On) {
if (m_inhibitScreensaver == mixxx::ScreenSaver::On) {
mixxx::ScreenSaverHelper::inhibit();
}
}

ScreensaverManager::~ScreensaverManager() {
if (m_inhibitScreensaver != mixxx::preferences::constants::ScreenSaver::Off) {
if (m_inhibitScreensaver != mixxx::ScreenSaver::Off) {
mixxx::ScreenSaverHelper::uninhibit();
}
}

void ScreensaverManager::setStatus(mixxx::preferences::constants::ScreenSaver newInhibit) {
if (m_inhibitScreensaver != mixxx::preferences::constants::ScreenSaver::Off) {
void ScreensaverManager::setStatus(mixxx::ScreenSaver newInhibit) {
if (m_inhibitScreensaver != mixxx::ScreenSaver::Off) {
mixxx::ScreenSaverHelper::uninhibit();
}

if (newInhibit == mixxx::preferences::constants::ScreenSaver::On ||
(newInhibit == mixxx::preferences::constants::ScreenSaver::OnPlay &&
if (newInhibit == mixxx::ScreenSaver::On ||
(newInhibit == mixxx::ScreenSaver::OnPlay &&
PlayerInfo::instance().getCurrentPlayingDeck() != -1)) {
mixxx::ScreenSaverHelper::inhibit();
}
Expand All @@ -37,7 +37,7 @@ void ScreensaverManager::setStatus(mixxx::preferences::constants::ScreenSaver ne
}

void ScreensaverManager::slotCurrentPlayingDeckChanged(int deck) {
if (m_inhibitScreensaver != mixxx::preferences::constants::ScreenSaver::OnPlay) {
if (m_inhibitScreensaver != mixxx::ScreenSaver::OnPlay) {
return;
}
if (deck == -1) {
Expand Down
6 changes: 3 additions & 3 deletions src/util/screensavermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class ScreensaverManager : public QObject {
ScreensaverManager(UserSettingsPointer pConfig, QObject* pParent = nullptr);
~ScreensaverManager();

void setStatus(mixxx::preferences::constants::ScreenSaver status);
void setStatus(mixxx::ScreenSaver status);

mixxx::preferences::constants::ScreenSaver status() {
mixxx::ScreenSaver status() {
return m_inhibitScreensaver;
}
public slots:
void slotCurrentPlayingDeckChanged(int deck);

private:
const UserSettingsPointer m_pConfig;
mixxx::preferences::constants::ScreenSaver m_inhibitScreensaver;
mixxx::ScreenSaver m_inhibitScreensaver;
};

} // namespace mixxx

0 comments on commit 25f796f

Please sign in to comment.