From 491b43639506e5cba2330199451c599d2fad2da2 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Mon, 28 Aug 2023 16:27:47 +0200 Subject: [PATCH] refactor: remove unnecessary static_casts when storing enum values in the config --- src/engine/controls/cuecontrol.cpp | 5 +---- src/engine/enginemaster.cpp | 5 +++-- src/engine/sync/enginesync.cpp | 7 +++---- src/library/autodj/autodjprocessor.cpp | 6 ++---- src/library/dlgtagfetcher.cpp | 5 ++--- src/mixer/basetrackplayer.cpp | 2 +- src/mixer/playermanager.cpp | 6 ++---- src/mixxxmainwindow.cpp | 6 +++--- 8 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index 809b6534262d..5f474b244c6f 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -2250,10 +2250,7 @@ bool CueControl::isTrackAtIntroCue() { } SeekOnLoadMode CueControl::getSeekOnLoadPreference() { - int configValue = - getConfig()->getValue(ConfigKey("[Controls]", "CueRecall"), - static_cast(SeekOnLoadMode::IntroStart)); - return static_cast(configValue); + return getConfig()->getValue(ConfigKey("[Controls]", "CueRecall"), SeekOnLoadMode::IntroStart); } void CueControl::hotcueFocusColorPrev(double value) { diff --git a/src/engine/enginemaster.cpp b/src/engine/enginemaster.cpp index f92bd34e4833..9bf3a8cfdf2a 100644 --- a/src/engine/enginemaster.cpp +++ b/src/engine/enginemaster.cpp @@ -174,8 +174,9 @@ EngineMaster::EngineMaster( m_pXFaderReverse->setButtonMode(ControlPushButton::TOGGLE); m_pKeylockEngine = new ControlObject(ConfigKey(group, "keylock_engine"), true, false, true); - m_pKeylockEngine->set(pConfig->getValue(ConfigKey(group, "keylock_engine"), - static_cast(EngineBuffer::defaultKeylockEngine()))); + m_pKeylockEngine->set(static_cast( + pConfig->getValue(ConfigKey(group, "keylock_engine"), + EngineBuffer::defaultKeylockEngine()))); // TODO: Make this read only and make EngineMaster decide whether // processing the master mix is necessary. diff --git a/src/engine/sync/enginesync.cpp b/src/engine/sync/enginesync.cpp index 7049c35499f3..644df284a8a6 100644 --- a/src/engine/sync/enginesync.cpp +++ b/src/engine/sync/enginesync.cpp @@ -252,10 +252,9 @@ Syncable* EngineSync::pickLeader(Syncable* enabling_syncable) { stopped_deck_count++; } } - - const SyncLockAlgorithm picker = static_cast( - m_pConfig->getValue(ConfigKey("[BPM]", "sync_lock_algorithm"), - PREFER_IMPLICIT_LEADER)); + const SyncLockAlgorithm picker = m_pConfig->getValue( + ConfigKey("[BPM]", "sync_lock_algorithm"), + PREFER_IMPLICIT_LEADER); switch (picker) { case PREFER_IMPLICIT_LEADER: // Always pick a deck for a new leader. diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index 38051d0d11d9..df36e9b04c0b 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -176,10 +176,8 @@ AutoDJProcessor::AutoDJProcessor( m_transitionTime = str_autoDjTransition.toDouble(); } - int configuredTransitionMode = m_pConfig->getValue( - ConfigKey(kConfigKey, kTransitionModePreferenceName), - static_cast(TransitionMode::FullIntroOutro)); - m_transitionMode = static_cast(configuredTransitionMode); + m_transitionMode = m_pConfig->getValue( + ConfigKey(kConfigKey, kTransitionModePreferenceName), TransitionMode::FullIntroOutro); } AutoDJProcessor::~AutoDJProcessor() { diff --git a/src/library/dlgtagfetcher.cpp b/src/library/dlgtagfetcher.cpp index c12dacfbda9f..7b07d08b1183 100644 --- a/src/library/dlgtagfetcher.cpp +++ b/src/library/dlgtagfetcher.cpp @@ -544,9 +544,8 @@ void DlgTagFetcher::slotCoverFound( void DlgTagFetcher::slotStartFetchCoverArt(const QList& allUrls) { DlgPrefLibrary::CoverArtFetcherQuality fetcherQuality = - static_cast( - m_pConfig->getValue(mixxx::library::prefs::kCoverArtFetcherQualityConfigKey, - static_cast(DlgPrefLibrary::CoverArtFetcherQuality::Medium))); + m_pConfig->getValue(mixxx::library::prefs::kCoverArtFetcherQualityConfigKey, + DlgPrefLibrary::CoverArtFetcherQuality::Medium); // Cover art links task can retrieve us variable number of links with different cover art sizes // Every single successful response has 2 links. diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp index cb874e7b25e2..206a6ae9a9d9 100644 --- a/src/mixer/basetrackplayer.cpp +++ b/src/mixer/basetrackplayer.cpp @@ -578,7 +578,7 @@ void BaseTrackPlayerImpl::slotTrackLoaded(TrackPointer pNewTrack, } if (!m_pChannelToCloneFrom) { - int reset = m_pConfig->getValue( + BaseTrackPlayer::TrackLoadReset reset = m_pConfig->getValue( ConfigKey("[Controls]", "SpeedAutoReset"), RESET_PITCH); if (reset == RESET_SPEED || reset == RESET_PITCH_AND_SPEED) { // Avoid resetting speed if sync lock is enabled and other decks with sync enabled diff --git a/src/mixer/playermanager.cpp b/src/mixer/playermanager.cpp index 49971001499c..53e6a5b82d74 100644 --- a/src/mixer/playermanager.cpp +++ b/src/mixer/playermanager.cpp @@ -696,10 +696,8 @@ void PlayerManager::slotLoadLocationToPlayer( void PlayerManager::slotLoadLocationToPlayerMaybePlay( const QString& location, const QString& group) { bool play = false; - LoadWhenDeckPlaying loadWhenDeckPlaying = - static_cast( - m_pConfig->getValue(kConfigKeyLoadWhenDeckPlaying, - static_cast(kDefaultLoadWhenDeckPlaying))); + LoadWhenDeckPlaying loadWhenDeckPlaying = m_pConfig->getValue( + kConfigKeyLoadWhenDeckPlaying, kDefaultLoadWhenDeckPlaying); switch (loadWhenDeckPlaying) { case LoadWhenDeckPlaying::AllowButStopDeck: case LoadWhenDeckPlaying::Reject: diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp index df259b359dc2..1245be60c055 100644 --- a/src/mixxxmainwindow.cpp +++ b/src/mixxxmainwindow.cpp @@ -174,9 +174,9 @@ void MixxxMainWindow::initialize() { UserSettingsPointer pConfig = m_pCoreServices->getSettings(); // Set the visibility of tooltips, default "1" = ON - m_toolTipsCfg = static_cast( - pConfig->getValue(ConfigKey("[Controls]", "Tooltips"), - static_cast(mixxx::TooltipsPreference::TOOLTIPS_ON))); + m_toolTipsCfg = pConfig->getValue( + ConfigKey("[Controls]", "Tooltips"), + mixxx::TooltipsPreference::TOOLTIPS_ON); #ifdef MIXXX_USE_QOPENGL ToolTipQOpenGL::singleton().setActive(m_toolTipsCfg == mixxx::TooltipsPreference::TOOLTIPS_ON); #endif