Skip to content

Add Ctrl+C/V/X/D keyboard shortcuts for Song Editor clips - #8428

Open
BernardoMalheiro wants to merge 1 commit into
LMMS:masterfrom
BernardoMalheiro:issue#7630
Open

BernardoMalheiro wants to merge 1 commit into
LMMS:masterfrom
BernardoMalheiro:issue#7630

Conversation

@BernardoMalheiro

Copy link
Copy Markdown
Contributor

Closes #7630

LMMS had no keyboard clipboard shortcuts for clips in the Song Editor. This adds Ctrl+C (copy), Ctrl+V (paste at cursor or default to playhead), Ctrl+X (cut), and Ctrl+D (duplicate in place).

Reuses existing ClipView serialization and TrackContentWidget::pasteSelection infrastructure. createClipDataFiles is promoted from protected to public to allow direct use in SongEditor::keyPressEvent.

Closes LMMS#7630

LMMS had no keyboard clipboard shortcuts for clips in the Song
Editor. This adds Ctrl+C (copy), Ctrl+V (paste at cursor or
playhead), Ctrl+X (cut), and Ctrl+D (duplicate in place).

Reuses existing ClipView serialization and
TrackContentWidget::pasteSelection infrastructure.
createClipDataFiles is promoted from protected to public to
allow direct use in SongEditor::keyPressEvent.

Co-authored-by: Diogo Carreira <diogo.f.carreira@tecnico.ulisboa.pt>
@BernardoMalheiro

Copy link
Copy Markdown
Contributor Author

Hi @yohannd1, sorry to bother you. I saw you've recently reviewed changes to SongEditor.cpp (#8385), which is the main file this PR touches. Would you be able to take a look when you have a moment? It's been open a couple of weeks and me and @DiogopC05 are happy to address any feedback. Thanks for your time!

@yohannd1 yohannd1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This generally looks good, and I really like this change!
Note however that we are currently in a feature freeze (see #8259), and as such this will probably take a while until it's properly reviewed.
I did some preliminary testing and reviewing, however:

Comment thread include/ClipView.h
QVector<ClipView *> getClickedClips();

// Methods to remove, copy, cut, paste and mute a QVector of Clip views
DataFile createClipDataFiles(const QVector<ClipView *> & clips) const;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
DataFile createClipDataFiles(const QVector<ClipView *> & clips) const;
DataFile createClipDataFiles(const QVector<ClipView*>& clips) const;

return;
}

std::sort(so.begin(), so.end(), [](ClipView* a, ClipView* b)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be a good idea to move refactor out this lambda, as it's used 3 times in the code. Maybe something like const auto sortClipByStart = ....

return a->getClip()->startPosition() < b->getClip()->startPosition();
});

so.first()->copy(so);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a ClipView::cut method. Have you tried that out?


TextFloat::displayMessage(
tr("Clipboard"),
tr("%n clip(s) copied", "", so.size()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I imagine this should be "cut" instead of "copied"?

tcw->pasteSelection(pastePos, &md, true);
TextFloat::displayMessage(
tr("Clipboard"),
tr("%n clip(s) pasted at cursor", "", clipCount),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Likewise, here and in line 718 the term "pasted" might be a bit off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding Ctrl+V to paste song segments

2 participants