Skip to content

Commit

Permalink
Improve limits on nudging
Browse files Browse the repository at this point in the history
Do not enable the nudging action unless exactly one clip is selected
Allow nudging forward when there is not a blank before it

As reported here:
https://forum.shotcut.org/t/beta-version-24-01-now-available-to-test/42498/2
https://forum.shotcut.org/t/beta-version-24-01-now-available-to-test/42498/24
  • Loading branch information
bmatherly committed Jan 15, 2024
1 parent 121c01b commit 058a283
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions src/docks/timelinedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,18 +638,13 @@ void TimelineDock::setupActions()
action->setEnabled(false);
connect(action, &QAction::triggered, this, [&]() {
auto selectedClips = selection();
if (!selectedClips.isEmpty()) {
if (selection().size() > 1)
setSelection({selection().first()});
int trackIndex = selection().first().y();
int clipIndex = selection().first().x();
if (selectedClips.size() == 1) {
int trackIndex = selectedClips.first().y();
int clipIndex = selectedClips.first().x();
bool valid = clipIndex > 0 && !isTransition(trackIndex, clipIndex)
&& !isBlank(trackIndex, clipIndex);
if (valid && !Settings.timelineRipple()) {
valid = isBlank(trackIndex, clipIndex - 1) && ((clipIndex == clipCount(trackIndex) - 1)
|| isBlank(trackIndex, clipIndex + 1));
} else if (valid) {
valid = clipIndex < clipCount(trackIndex) - 1;
valid = (clipIndex == clipCount(trackIndex) - 1) || isBlank(trackIndex, clipIndex + 1);
}
if (!valid) {
emit showStatusMessage(tr("Nudge Forward is not available"));
Expand All @@ -661,11 +656,11 @@ void TimelineDock::setupActions()
}
});
connect(this, &TimelineDock::selectionChanged, action, [ = ]() {
bool enabled = m_selection.selectedClips.length() > 0;
if (enabled && !selection().isEmpty()) {
int trackIndex = selection().first().y();
int clipIndex = selection().first().x();
enabled = !isBlank(trackIndex, clipIndex);
auto selectedClips = selection();
bool enabled = selectedClips.size() == 1;
if (enabled) {
enabled = !isBlank(selectedClips.first().y(), selectedClips.first().x())
&& !isTransition(selectedClips.first().y(), selectedClips.first().x());
}
action->setEnabled(enabled);
});
Expand All @@ -676,11 +671,9 @@ void TimelineDock::setupActions()
action->setEnabled(false);
connect(action, &QAction::triggered, this, [&]() {
auto selectedClips = selection();
if (!selectedClips.isEmpty()) {
if (selection().size() > 1)
setSelection({selection().first()});
int trackIndex = selection().first().y();
int clipIndex = selection().first().x();
if (selectedClips.size() == 1) {
int trackIndex = selectedClips.first().y();
int clipIndex = selectedClips.first().x();
if (clipIndex <= 0 || isTransition(trackIndex, clipIndex) || isBlank(trackIndex, clipIndex)
|| !isBlank(trackIndex, clipIndex - 1)) {
emit showStatusMessage(tr("Nudge Backward is not available"));
Expand All @@ -692,11 +685,11 @@ void TimelineDock::setupActions()
}
});
connect(this, &TimelineDock::selectionChanged, action, [ = ]() {
bool enabled = m_selection.selectedClips.length() > 0;
if (enabled && !selection().isEmpty()) {
int trackIndex = selection().first().y();
int clipIndex = selection().first().x();
enabled = !isBlank(trackIndex, clipIndex);
auto selectedClips = selection();
bool enabled = selectedClips.size() == 1;
if (enabled) {
enabled = !isBlank(selectedClips.first().y(), selectedClips.first().x())
&& !isTransition(selectedClips.first().y(), selectedClips.first().x());
}
action->setEnabled(enabled);
});
Expand Down

0 comments on commit 058a283

Please sign in to comment.