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

Slice shortcuts #3447

Merged
merged 3 commits into from
May 9, 2020
Merged

Slice shortcuts #3447

merged 3 commits into from
May 9, 2020

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented May 4, 2020

This PR adds slight variations on the "Slice All: (mode)" actions, named "Slice Selected: (mode)", which just like "Slice All" use the playhead as the slice point. However, where "Slice All..." acts on all intersecting clips, "Slice Selected" slices only the intersecting clips which are also currently selected.

As requested, "Slice Selected: Keep Both Sides" is bound to the s key by default (modifiable in the Preferences). For symmetry with the "Slice All" bindings, the other two modes are therefore bound to a and d.

These actions are currently keyboard-shortcut-only, they do not appear on any context menu. (TBH I'm just not sure where they could go, having context menu choices that operate on the active selection — even multi-selection, possibly — and also depend on the playhead positioning... it just feels like it could get pretty messy.)

Fixes #1764

@ferdnyc ferdnyc added interface GUI / user interface issues (i.e. windows, buttons, scrolling, pop-ups, etc...) closer This PR fixes one or more reported Issues labels May 4, 2020
@SuslikV
Copy link
Contributor

SuslikV commented May 4, 2020

not sure where they could go...

Menu entries already exist - they should work for single selected file as for multiply selections. What's wrong here? It is just bug that it doesn't slices all selected files.
Of course, selections itself (like Ctrl + mouse) has additional PR (#3317)

@SuslikV
Copy link
Contributor

SuslikV commented May 4, 2020

...and what is:

self.selected_transitons

?

@ferdnyc
Copy link
Contributor Author

ferdnyc commented May 4, 2020

Menu entries already exist - they should work for single selected file as for multiply selections. What's wrong here? It is just bug that it doesn't slices all selected files.

That's a fair point, the Align actions already do operate on multiple selected clips so there's some precedent there. Of course, whether that works correctly right now will depend on whether the selection list is accurate, but that's equally true of the keyboard shortcuts.

I wonder whether just changing the Clip context menu "Slice" to operate on multiple selected items would be OK, or if it risks screwing up users expecting the existing functionality. Arguably it's just making Slice function in a way that's closer to what a typical user would expect. (After all, why would you select multiple clips if you only want to slice one of them?)

But if there are users who regularly slice a single clip while having multiple selected, having come to expect that Slice works that way, then to avoid screwing up those users these new Slice options should have a separate context menu subsection that, like Align, only shows up when two or more items have been selected.

(Edit: Continuing a half-thought, from a keyboard perspective it doesn't matter. Slice Selected is equivalent to Slice when only one clip is selected, so the keyboard shortcuts for Slice Selected will cover all of the different possible combinations of selection-slicing, including the reductive one where only a single clip is selected.)

Of course, selections itself (like Ctrl + mouse) has additional PR (#3317)

Aha, that's right. I mentioned in #1764 that there might already be a fix pending for that.

...and what is:

self.selected_transitons

?

...I guess, proof that I KAN SPEL? I'll fix that, thanks.

@SuslikV
Copy link
Contributor

SuslikV commented May 4, 2020

if there are users who regularly slice a single clip while having multiple selected, having come to expect that Slice works that way...

Unfortunately, right now they are clicking twice and more times the same option just to complete the intended slicing task.

@ferdnyc
Copy link
Contributor Author

ferdnyc commented May 4, 2020

Unfortunately, right now they are clicking twice and more times the same option just to complete the intended slicing task.

Depends how they select. "Draw-a-box" group selection works fine, and there are definitely some users who do all of their multi-selection that way.

@SuslikV
Copy link
Contributor

SuslikV commented May 4, 2020

No, I mean slicing: click clip - slice one. Multiply selections doesn't works in any way (rectangle selections or not). Only Slice All is doing its job right now, but that may slice clip at background...

@ferdnyc
Copy link
Contributor Author

ferdnyc commented May 4, 2020

@SuslikV Aha! Yeah, gotcha.

@SuslikV
Copy link
Contributor

SuslikV commented May 4, 2020

Your code adapted to timeline_webview.py ShowClipMenu() section, similar code should apply to the ShowTransitionMenu()

...
        # Get list of intercepting clips with position (if any)
        intersecting_clips = Clip.filter(intersect=playhead_position)
        intersecting_trans = Transition.filter(intersect=playhead_position)

        if intersecting_clips or intersecting_trans:
            # Get list of clip ids
            clip_ids = [c.id for c in intersecting_clips if c.id in get_app().window.selected_clips]
            trans_ids = [t.id for t in intersecting_trans if t.id in get_app().window.selected_transitions]

            # Add split clip menu
            Slice_Menu = QMenu(_("Slice"), self)
            Slice_Keep_Both = Slice_Menu.addAction(_("Keep Both Sides"))
            Slice_Keep_Both.setShortcut(QKeySequence(self.window.getShortcutByName("sliceSelectedKeepBothSides")))
            Slice_Keep_Both.triggered.connect(partial(self.Slice_Triggered, MENU_SLICE_KEEP_BOTH, clip_ids, trans_ids, playhead_position))
            Slice_Keep_Left = Slice_Menu.addAction(_("Keep Left Side"))
            Slice_Keep_Left.setShortcut(QKeySequence(self.window.getShortcutByName("sliceSelectedKeepLeftSide")))
            Slice_Keep_Left.triggered.connect(partial(self.Slice_Triggered, MENU_SLICE_KEEP_LEFT, clip_ids, trans_ids, playhead_position))
            Slice_Keep_Right = Slice_Menu.addAction(_("Keep Right Side"))
            #Slice_Keep_Right.setShortcut(QKeySequence(self.window.getShortcutByName("sliceSelectedKeepRightSide")))
            Slice_Keep_Right.triggered.connect(partial(self.Slice_Triggered, MENU_SLICE_KEEP_RIGHT, clip_ids, trans_ids, playhead_position))
            menu.addMenu(Slice_Menu)
...

@SuslikV
Copy link
Contributor

SuslikV commented May 4, 2020

Razor Tool works for single item only. This may be leaved unchanged.

@ferdnyc
Copy link
Contributor Author

ferdnyc commented May 4, 2020

Razor Tool works for single item only. This may be leaved unchanged.

Agreed, not even considering a trip down that road. If the user wants to slice multiple clips at once, they need to use the playhead and Slice All or Slice Selected.

In fact, nearly every function of the Razor Tool now has a viable-if-not-superior alternative using the playhead "razor" functions. If not for the tool's ability to quickly slice single UN-selected clips, I'd say there's no longer any reason for it to even exist.

But, it still is the quickest/best way to slice a single clip without having to worry about selection or playhead position, so I guess it lives to slice another day.

@jonoomph
Copy link
Member

jonoomph commented May 9, 2020

so I guess it lives to slice another day.

LOL 😆

@jonoomph
Copy link
Member

jonoomph commented May 9, 2020

LGTM! Thanks for this one!

@jonoomph jonoomph merged commit ddf3d1e into OpenShot:develop May 9, 2020
@ferdnyc
Copy link
Contributor Author

ferdnyc commented May 9, 2020

Hmm. We never resolved the menu-selection issue. I'm sort of leaning more towards @SuslikV 's suggestion that the Clip/Transition context-menu Slice functions become SliceSelected, replacing the current slice options. (If they only have one selected item, SliceSelected will be equivalent to the current single-item slice anyway. The only thing it'll affect is what happens when you activate Slice on a clip while you also have additional clips selected. And that just doesn't feel like a case we should be losing sleep over.)

...Still, I can slap that change into a separate PR, this works just fine for now in its current keyboard-only mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closer This PR fixes one or more reported Issues interface GUI / user interface issues (i.e. windows, buttons, scrolling, pop-ups, etc...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard shotcut to slice just the selected clip
3 participants