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

ControlObject alias improvements #11973

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
refactor(controlobject): Use ControlObject::addAlias() method
Holzhaus committed Sep 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 004fc90f94dd2018774810f22cf71a75b69d2471
9 changes: 3 additions & 6 deletions src/effects/effectchain.cpp
Original file line number Diff line number Diff line change
@@ -108,17 +108,15 @@ EffectChain::EffectChain(const QString& group,
&ControlObject::valueChanged,
this,
&EffectChain::slotControlNextChainPreset);
ControlDoublePrivate::insertAlias(ConfigKey(m_group, "next_chain"),
ConfigKey(m_group, "next_chain_preset"));
m_pControlNextChainPreset->addAlias(ConfigKey(m_group, QStringLiteral("next_chain")));

m_pControlPrevChainPreset = std::make_unique<ControlPushButton>(
ConfigKey(m_group, "prev_chain_preset"));
connect(m_pControlPrevChainPreset.get(),
&ControlObject::valueChanged,
this,
&EffectChain::slotControlPrevChainPreset);
ControlDoublePrivate::insertAlias(ConfigKey(m_group, "prev_chain"),
ConfigKey(m_group, "prev_chain_preset"));
m_pControlPrevChainPreset->addAlias(ConfigKey(m_group, QStringLiteral("prev_chain")));

// Ignoring no-ops is important since this is for +/- tickers.
m_pControlChainPresetSelector = std::make_unique<ControlEncoder>(
@@ -127,8 +125,7 @@ EffectChain::EffectChain(const QString& group,
&ControlObject::valueChanged,
this,
&EffectChain::slotControlChainPresetSelector);
ControlDoublePrivate::insertAlias(ConfigKey(m_group, "chain_selector"),
ConfigKey(m_group, "chain_preset_selector"));
m_pControlChainPresetSelector->addAlias(ConfigKey(m_group, QStringLiteral("chain_selector")));

// ControlObjects for skin <-> controller mapping interaction.
// Refer to comment in header for full explanation.
3 changes: 1 addition & 2 deletions src/engine/channels/engineaux.cpp
Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@ EngineAux::EngineAux(const ChannelHandleAndGroup& handleGroup, EffectsManager* p
m_pPregain(new ControlAudioTaperPot(ConfigKey(getGroup(), "pregain"), -12, 12, 0.5)) {
// Make input_configured read-only.
m_pInputConfigured->setReadOnly();
ControlDoublePrivate::insertAlias(ConfigKey(getGroup(), "enabled"),
ConfigKey(getGroup(), "input_configured"));
m_pInputConfigured->addAlias(ConfigKey(getGroup(), QStringLiteral("enabled")));

// by default Aux is disabled on the main and disabled on PFL. User
// can over-ride by setting the "pfl" or "main_mix" controls.
3 changes: 1 addition & 2 deletions src/engine/channels/enginechannel.cpp
Original file line number Diff line number Diff line change
@@ -22,8 +22,7 @@ EngineChannel::EngineChannel(const ChannelHandleAndGroup& handleGroup,
m_pPFL->setButtonMode(ControlPushButton::TOGGLE);
m_pMainMix = new ControlPushButton(ConfigKey(getGroup(), "main_mix"));
m_pMainMix->setButtonMode(ControlPushButton::POWERWINDOW);
ControlDoublePrivate::insertAlias(
ConfigKey(getGroup(), "master"), ConfigKey(getGroup(), "main_mix"));
m_pMainMix->addAlias(ConfigKey(getGroup(), QStringLiteral("master")));
m_pOrientation = new ControlPushButton(ConfigKey(getGroup(), "orientation"));
m_pOrientation->setButtonMode(ControlPushButton::TOGGLE);
m_pOrientation->setStates(3);
3 changes: 1 addition & 2 deletions src/engine/channels/enginemicrophone.cpp
Original file line number Diff line number Diff line change
@@ -19,8 +19,7 @@ EngineMicrophone::EngineMicrophone(const ChannelHandleAndGroup& handleGroup,
m_pPregain(new ControlAudioTaperPot(ConfigKey(getGroup(), "pregain"), -12, 12, 0.5)) {
// Make input_configured read-only.
m_pInputConfigured->setReadOnly();
ControlDoublePrivate::insertAlias(ConfigKey(getGroup(), "enabled"),
ConfigKey(getGroup(), "input_configured"));
m_pInputConfigured->addAlias(ConfigKey(getGroup(), QStringLiteral("enabled")));

setMainMix(false); // Use "talkover" button to enable microphones
}
3 changes: 1 addition & 2 deletions src/engine/controls/cuecontrol.cpp
Original file line number Diff line number Diff line change
@@ -2450,8 +2450,7 @@ HotcueControl::HotcueControl(const QString& group, int hotcueIndex)
m_pHotcueStatus->setReadOnly();

// Add an alias for the legacy hotcue_X_enabled CO
ControlDoublePrivate::insertAlias(keyForControl(QStringLiteral("enabled")),
keyForControl(QStringLiteral("status")));
m_pHotcueStatus->addAlias(keyForControl(QStringLiteral("enabled")));

m_hotcueType = std::make_unique<ControlObject>(keyForControl(QStringLiteral("type")));
m_hotcueType->setReadOnly();
3 changes: 1 addition & 2 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
@@ -96,8 +96,7 @@ LoopingControl::LoopingControl(const QString& group,
Qt::DirectConnection);
m_pReloopToggleButton->set(0);
// The old reloop_exit name was confusing. This CO does both entering and exiting.
ControlDoublePrivate::insertAlias(ConfigKey(group, "reloop_exit"),
ConfigKey(group, "reloop_toggle"));
m_pReloopToggleButton->addAlias(ConfigKey(group, QStringLiteral("reloop_exit")));

m_pReloopAndStopButton = new ControlPushButton(ConfigKey(group, "reloop_andstop"));
connect(m_pReloopAndStopButton, &ControlObject::valueChanged,
6 changes: 2 additions & 4 deletions src/engine/enginemixer.cpp
Original file line number Diff line number Diff line change
@@ -100,8 +100,7 @@ EngineMixer::EngineMixer(

// Legacy: the main "gain" control used to be named "volume" in Mixxx
// 1.11.0 and earlier. See issue #7413.
ControlDoublePrivate::insertAlias(ConfigKey(group, "volume"),
ConfigKey(group, "gain"));
m_pMainGain->addAlias(ConfigKey(group, QStringLiteral("volume")));

// VU meter:
m_pVumeter = new EngineVuMeter(group);
@@ -118,8 +117,7 @@ EngineMixer::EngineMixer(

// Legacy: the headphone "headGain" control used to be named "headVolume" in
// Mixxx 1.11.0 and earlier. See issue #7413.
ControlDoublePrivate::insertAlias(ConfigKey(group, "headVolume"),
ConfigKey(group, "headGain"));
m_pHeadGain->addAlias(ConfigKey(group, QStringLiteral("headVolume")));

// Headphone mix (left/right)
m_pHeadMix = new ControlPotmeter(ConfigKey(group, "headMix"),-1.,1.);
3 changes: 1 addition & 2 deletions src/engine/sync/internalclock.cpp
Original file line number Diff line number Diff line change
@@ -50,8 +50,7 @@ InternalClock::InternalClock(const QString& group, SyncableListener* pEngineSync
m_pSyncLeaderEnabled->setStates(3);
m_pSyncLeaderEnabled->connectValueChangeRequest(
this, &InternalClock::slotSyncLeaderEnabledChangeRequest, Qt::DirectConnection);
ControlDoublePrivate::insertAlias(ConfigKey(m_group, "sync_master"),
ConfigKey(m_group, "sync_leader"));
m_pSyncLeaderEnabled->addAlias(ConfigKey(m_group, QStringLiteral("sync_master")));
}

InternalClock::~InternalClock() {
3 changes: 1 addition & 2 deletions src/engine/sync/synccontrol.cpp
Original file line number Diff line number Diff line change
@@ -57,8 +57,7 @@ SyncControl::SyncControl(const QString& group,
m_pSyncLeaderEnabled->setStates(3);
m_pSyncLeaderEnabled->connectValueChangeRequest(
this, &SyncControl::slotSyncLeaderEnabledChangeRequest, Qt::DirectConnection);
ControlDoublePrivate::insertAlias(ConfigKey(group, "sync_master"),
ConfigKey(group, "sync_leader"));
m_pSyncLeaderEnabled->addAlias(ConfigKey(group, QStringLiteral("sync_master")));

m_pSyncEnabled.reset(
new ControlPushButton(ConfigKey(group, "sync_enabled")));
7 changes: 4 additions & 3 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
@@ -195,6 +195,8 @@ LibraryControl::LibraryControl(Library* pLibrary)

// Auto DJ controls
m_pAutoDjAddTop = std::make_unique<ControlPushButton>(ConfigKey("[Library]","AutoDjAddTop"));
m_pAutoDjAddTop->addAlias(ConfigKey(
QStringLiteral("[Playlist]"), QStringLiteral("AutoDjAddTop")));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(m_pAutoDjAddTop.get(),
&ControlPushButton::valueChanged,
@@ -203,6 +205,8 @@ LibraryControl::LibraryControl(Library* pLibrary)
#endif

m_pAutoDjAddBottom = std::make_unique<ControlPushButton>(ConfigKey("[Library]","AutoDjAddBottom"));
m_pAutoDjAddBottom->addAlias(ConfigKey(
QStringLiteral("[Playlist]"), QStringLiteral("AutoDjAddBottom")));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(m_pAutoDjAddBottom.get(),
&ControlPushButton::valueChanged,
@@ -414,9 +418,6 @@ LibraryControl::LibraryControl(Library* pLibrary)
this,
&LibraryControl::slotLoadSelectedIntoFirstStopped);

ControlDoublePrivate::insertAlias(ConfigKey("[Playlist]", "AutoDjAddTop"), ConfigKey("[Library]", "AutoDjAddTop"));
ControlDoublePrivate::insertAlias(ConfigKey("[Playlist]", "AutoDjAddBottom"), ConfigKey("[Library]", "AutoDjAddBottom"));

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QApplication* app = qApp;
// Update controls if any widget in any Mixxx window gets or loses focus
2 changes: 1 addition & 1 deletion src/test/controlobjecttest.cpp
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ TEST_F(ControlObjectTest, AliasRetrieval) {
auto co = std::make_unique<ControlObject>(ck);

// Insert the alias before it is going to be used
ControlDoublePrivate::insertAlias(ckAlias, ck);
co->addAlias(ckAlias);

// Check if getControl on alias returns us the original ControlObject
EXPECT_EQ(ControlObject::getControl(ckAlias), co.get());
Loading