Skip to content

Commit

Permalink
refactor: remove unnecessary static_casts when storing enum values in…
Browse files Browse the repository at this point in the history
… the config
  • Loading branch information
Swiftb0y committed Aug 28, 2023
1 parent 820811c commit 491b436
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 25 deletions.
5 changes: 1 addition & 4 deletions src/engine/controls/cuecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,10 +2250,7 @@ bool CueControl::isTrackAtIntroCue() {
}

SeekOnLoadMode CueControl::getSeekOnLoadPreference() {
int configValue =
getConfig()->getValue(ConfigKey("[Controls]", "CueRecall"),
static_cast<int>(SeekOnLoadMode::IntroStart));
return static_cast<SeekOnLoadMode>(configValue);
return getConfig()->getValue(ConfigKey("[Controls]", "CueRecall"), SeekOnLoadMode::IntroStart);
}

void CueControl::hotcueFocusColorPrev(double value) {
Expand Down
5 changes: 3 additions & 2 deletions src/engine/enginemaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(EngineBuffer::defaultKeylockEngine())));
m_pKeylockEngine->set(static_cast<double>(
pConfig->getValue(ConfigKey(group, "keylock_engine"),
EngineBuffer::defaultKeylockEngine())));

// TODO: Make this read only and make EngineMaster decide whether
// processing the master mix is necessary.
Expand Down
7 changes: 3 additions & 4 deletions src/engine/sync/enginesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ Syncable* EngineSync::pickLeader(Syncable* enabling_syncable) {
stopped_deck_count++;
}
}

const SyncLockAlgorithm picker = static_cast<SyncLockAlgorithm>(
m_pConfig->getValue<int>(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.
Expand Down
6 changes: 2 additions & 4 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ AutoDJProcessor::AutoDJProcessor(
m_transitionTime = str_autoDjTransition.toDouble();
}

int configuredTransitionMode = m_pConfig->getValue(
ConfigKey(kConfigKey, kTransitionModePreferenceName),
static_cast<int>(TransitionMode::FullIntroOutro));
m_transitionMode = static_cast<TransitionMode>(configuredTransitionMode);
m_transitionMode = m_pConfig->getValue(
ConfigKey(kConfigKey, kTransitionModePreferenceName), TransitionMode::FullIntroOutro);
}

AutoDJProcessor::~AutoDJProcessor() {
Expand Down
5 changes: 2 additions & 3 deletions src/library/dlgtagfetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,8 @@ void DlgTagFetcher::slotCoverFound(

void DlgTagFetcher::slotStartFetchCoverArt(const QList<QString>& allUrls) {
DlgPrefLibrary::CoverArtFetcherQuality fetcherQuality =
static_cast<DlgPrefLibrary::CoverArtFetcherQuality>(
m_pConfig->getValue(mixxx::library::prefs::kCoverArtFetcherQualityConfigKey,
static_cast<int>(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.
Expand Down
2 changes: 1 addition & 1 deletion src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ void BaseTrackPlayerImpl::slotTrackLoaded(TrackPointer pNewTrack,
}

if (!m_pChannelToCloneFrom) {
int reset = m_pConfig->getValue<int>(
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
Expand Down
6 changes: 2 additions & 4 deletions src/mixer/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,8 @@ void PlayerManager::slotLoadLocationToPlayer(
void PlayerManager::slotLoadLocationToPlayerMaybePlay(
const QString& location, const QString& group) {
bool play = false;
LoadWhenDeckPlaying loadWhenDeckPlaying =
static_cast<LoadWhenDeckPlaying>(
m_pConfig->getValue(kConfigKeyLoadWhenDeckPlaying,
static_cast<int>(kDefaultLoadWhenDeckPlaying)));
LoadWhenDeckPlaying loadWhenDeckPlaying = m_pConfig->getValue(
kConfigKeyLoadWhenDeckPlaying, kDefaultLoadWhenDeckPlaying);
switch (loadWhenDeckPlaying) {
case LoadWhenDeckPlaying::AllowButStopDeck:
case LoadWhenDeckPlaying::Reject:
Expand Down
6 changes: 3 additions & 3 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ void MixxxMainWindow::initialize() {
UserSettingsPointer pConfig = m_pCoreServices->getSettings();

// Set the visibility of tooltips, default "1" = ON
m_toolTipsCfg = static_cast<mixxx::TooltipsPreference>(
pConfig->getValue(ConfigKey("[Controls]", "Tooltips"),
static_cast<int>(mixxx::TooltipsPreference::TOOLTIPS_ON)));
m_toolTipsCfg = pConfig->getValue<mixxx::TooltipsPreference>(
ConfigKey("[Controls]", "Tooltips"),
mixxx::TooltipsPreference::TOOLTIPS_ON);
#ifdef MIXXX_USE_QOPENGL
ToolTipQOpenGL::singleton().setActive(m_toolTipsCfg == mixxx::TooltipsPreference::TOOLTIPS_ON);
#endif
Expand Down

0 comments on commit 491b436

Please sign in to comment.