Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2017-2026 QL-Win Contributors
// Copyright © 2017-2026 QL-Win Contributors
//
// This file is part of QuickLook program.
//
Expand Down Expand Up @@ -109,6 +109,10 @@ public ViewerPanel(ContextObject context)
};

PreviewMouseWheel += (_, e) => ChangeVolume(e.Delta / 120d * 0.04d);

Focusable = true;
Loaded += (_, _) => Focus();
PreviewKeyDown += ViewerPanel_PreviewKeyDown;
}

private partial void LoadAndInsertGlassLayer();
Expand Down Expand Up @@ -200,17 +204,69 @@ public void Dispose()

private void Panel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Focus();

if (e.LeftButton == MouseButtonState.Pressed)
{
var wnd = Window.GetWindow(this);
// Do not allow dragging when window is borderless (e.g. fullscreen)
if (wnd?.WindowStyle == WindowStyle.None)
{
TogglePlayPause(this, EventArgs.Empty);
return;
}

if (wnd != null)
{
var startLeft = wnd.Left;
var startTop = wnd.Top;

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);
}
}
}
}

private void ViewerPanel_PreviewKeyDown(object sender, KeyEventArgs e)
{
switch (e.Key)
{
case Key.Left:
Seek(-TimeSpan.FromSeconds(5).Ticks);
e.Handled = true;
break;

case Key.Right:
Seek(TimeSpan.FromSeconds(5).Ticks);
e.Handled = true;
break;

case Key.Up:
ChangeVolume(0.05d);
e.Handled = true;
break;

wnd?.DragMove();
case Key.Down:
ChangeVolume(-0.05d);
e.Handled = true;
break;
}
}

private void Seek(long deltaTicks)
{
if (mediaElement == null)
return;

var target = Math.Max(0, Math.Min(mediaElement.MediaDuration, mediaElement.MediaPosition + deltaTicks));
mediaElement.MediaPosition = target;
}

public event PropertyChangedEventHandler PropertyChanged;

private void MediaOpened(object o, RoutedEventArgs args)
Expand Down