Skip to content

Add keyboard navigation shortcuts and click to pause in VideoViewer (#47, #1979, #1753) - #2002

Open
BerryUIKI wants to merge 1 commit into
QL-Win:masterfrom
BerryUIKI:feat/video-viewer-shortcuts-and-click
Open

BerryUIKI wants to merge 1 commit into
QL-Win:masterfrom
BerryUIKI:feat/video-viewer-shortcuts-and-click

Conversation

@BerryUIKI

@BerryUIKI BerryUIKI commented Sep 18, 2026

Copy link
Copy Markdown

PR Checklist

  • Functionality has been tested, no obvious bugs
  • Code style follows project conventions
  • Documentation/comments updated (if applicable)

Brief Description of Changes

  1. Keyboard navigation:
    • Enabled Focusable = true, requested focus on Loaded, and attached PreviewKeyDown handler in ViewerPanel.xaml.cs.
    • Left / Right arrow keys: rewind / fast-forward playback by 5 seconds.
    • Up / Down arrow keys: increase / decrease volume by 5%.
  2. Video display area click interaction:
    • Enhanced Panel_MouseLeftButtonDown to differentiate between a click and a drag operation.
    • A single click on the video area toggles Play/Pause.
    • Holding and dragging still initiates window moving (DragMove()), ensuring window repositioning remains fully functional.

Related Issue (if any)

Fixes #47
Fixes #1979
Fixes #1753

Additional Notes

Tested video playback, seeking with arrow keys, volume adjustment with Up/Down arrows, clicking to play/pause, and dragging the preview window.

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

ViewerPanel now supports focused keyboard navigation—five-second seeking and volume adjustments—and toggles playback on clicks that do not move the window, including direct click handling in borderless mode.

Sequence diagram for VideoViewer keyboard and click controls

sequenceDiagram
    actor User
    participant ViewerPanel
    participant MediaElement
    participant Window

    User->>ViewerPanel: PreviewKeyDown
    alt Left or Right arrow
        ViewerPanel->>ViewerPanel: Seek(deltaTicks)
        ViewerPanel->>MediaElement: MediaPosition = clamped target
    else Up or Down arrow
        ViewerPanel->>ViewerPanel: ChangeVolume(delta)
    end

    User->>ViewerPanel: MouseLeftButtonDown
    ViewerPanel->>ViewerPanel: Focus()
    alt Borderless window
        ViewerPanel->>ViewerPanel: TogglePlayPause(this, EventArgs.Empty)
    else Window drag does not move window
        ViewerPanel->>Window: DragMove()
        ViewerPanel->>ViewerPanel: TogglePlayPause(this, EventArgs.Empty)
    else Window moves
        ViewerPanel->>Window: DragMove()
    end
Loading

File-Level Changes

Change Details Files
Adds keyboard shortcuts for seeking and volume control.
  • Makes the viewer focusable and focuses it when loaded.
  • Handles Left/Right arrows to seek five seconds backward or forward.
  • Handles Up/Down arrows to adjust volume by five percent.
  • Clamps seek targets to the media duration and zero.
QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
Adds click-to-toggle playback while preserving window dragging.
  • Focuses the panel on mouse press.
  • Toggles playback in borderless mode on click.
  • Uses the post-drag window position to distinguish a click from a window move.
QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs

Possibly linked issues

  • #unknown: The PR adds left/right arrow handlers that seek video playback by five seconds when the viewer is focused.
  • #unknown: The PR directly implements clicking the video area to toggle play/pause, exactly addressing the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs" line_range="227-230" />
<code_context>
+                wnd.DragMove();
+
+                // If the window was not moved, treat this interaction as a click to toggle play/pause
+                if (Math.Abs(wnd.Left - startLeft) < 2 && Math.Abs(wnd.Top - startTop) < 2)
+                {
+                    TogglePlayPause(this, EventArgs.Empty);
+                }
+            }
+        }
</code_context>
<issue_to_address>
**nitpick (bug_risk):** A drag that moves the window away from its starting point and then back within two pixels is treated as a click, so the video is paused or resumed even though the user performed a drag.

**Triggers:** When the user drags the preview window back to approximately its original position.

**Suggested fix:** Track whether the pointer moved beyond the drag threshold during the interaction, rather than comparing only the final window position with the starting position.
</issue_to_address>

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +227 to +230
if (Math.Abs(wnd.Left - startLeft) < 2 && Math.Abs(wnd.Top - startTop) < 2)
{
TogglePlayPause(this, EventArgs.Empty);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick (bug_risk): A drag that moves the window away from its starting point and then back within two pixels is treated as a click, so the video is paused or resumed even though the user performed a drag.

Triggers: When the user drags the preview window back to approximately its original position.

Suggested fix: Track whether the pointer moved beyond the drag threshold during the interaction, rather than comparing only the final window position with the starting position.

@BerryUIKI BerryUIKI changed the title Add keyboard navigation shortcuts and click to pause in VideoViewer (… Add keyboard navigation shortcuts and click to pause in VideoViewer (#47, #1979, #1753) Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant