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

Track menu: enable Lock BPM action if any selected track BPM is unlocked #12385

Merged
merged 1 commit into from Dec 2, 2023

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Dec 1, 2023

BPM > Lock was not enabled if any of the selected track is locked.

@github-actions github-actions bot added the ui label Dec 1, 2023
@ronso0
Copy link
Member Author

ronso0 commented Dec 1, 2023

There's probably a smarter solution, but it does the job 🤷

Copy link
Member

@JoergAtGithub JoergAtGithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except the code duplication issue, it's fine for me.

Comment on lines 682 to 686
bool WTrackMenu::isAnyTrackBpmUnlocked() const {
if (m_pTrackModel) {
const int column =
m_pTrackModel->fieldIndex(LIBRARYTABLE_BPM_LOCK);
for (const auto& trackIndex : m_trackIndexList) {
QModelIndex bpmLockedIndex =
trackIndex.sibling(trackIndex.row(), column);
if (!bpmLockedIndex.data().toBool()) {
return true;
}
}
} else {
if (m_pTrack && !m_pTrack->isBpmLocked()) {
return true;
}
}
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool WTrackMenu::isAnyTrackBpmUnlocked() const {
if (m_pTrackModel) {
const int column =
m_pTrackModel->fieldIndex(LIBRARYTABLE_BPM_LOCK);
for (const auto& trackIndex : m_trackIndexList) {
QModelIndex bpmLockedIndex =
trackIndex.sibling(trackIndex.row(), column);
if (!bpmLockedIndex.data().toBool()) {
return true;
}
}
} else {
if (m_pTrack && !m_pTrack->isBpmLocked()) {
return true;
}
}
return false;
}
void WTrackMenu::accumulateBpmLockStates(bool* anyBpmLocked, bool* anyBpmNotLocked) const {
VERIFY_OR_DEBUG_ASSERT(anyBpmLocked && anyBpmNotLocked) {
return;
}
*anyBpmLocked = false;
*anyBpmNotLocked = false;
if (m_pTrackModel) {
const int column =
m_pTrackModel->fieldIndex(LIBRARYTABLE_BPM_LOCK);
for (const auto& trackIndex : m_trackIndexList) {
QModelIndex bpmLockedIndex =
trackIndex.sibling(trackIndex.row(), column);
if (bpmLockedIndex.data().toBool()) {
*anyBpmLocked = true;
} else {
*anyBpmNotLocked = true;
}
}
} else {
if (m_pTrack) {
if (m_pTrack->isBpmLocked()) {
*anyBpmLocked = true;
} else {
*anyBpmNotLocked = true;
}
}
}
}

Otherwise it's a lot of code duplication, and this code would be also executed twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, something like, I was just too lazy last night ; )

Co-authored-by: JoergAtGithub <64457745+JoergAtGithub@users.noreply.github.com>
Copy link
Member

@JoergAtGithub JoergAtGithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM now! Works as expected on local Windows11 build. Thank you!

@JoergAtGithub JoergAtGithub merged commit ef072ae into mixxxdj:2.4 Dec 2, 2023
12 checks passed
@ronso0 ronso0 deleted the trackmenu-fix-unlock-bpm branch December 2, 2023 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants