MacGui: add Quick Look to the queue.

This commit is contained in:
Damiano Galassi 2022-01-11 09:22:48 +01:00
parent 513b0fc4b0
commit 659b0cd3ff
No known key found for this signature in database
GPG Key ID: 5452E231DFDBCA11
6 changed files with 117 additions and 5 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -43,7 +43,7 @@
<toolbarItem implicitItemIdentifier="E914B732-9FA4-42E0-AFA6-353A8ACC406B" label="Action" paletteLabel="Action" image="NSActionTemplate" sizingBehavior="auto" id="DCB-WP-NRs">
<nil key="toolTip"/>
<popUpButton key="view" verticalHuggingPriority="750" id="Wfu-Hw-JBC">
<rect key="frame" x="0.0" y="14" width="54" height="25"/>
<rect key="frame" x="0.0" y="14" width="50" height="25"/>
<autoresizingMask key="autoresizingMask"/>
<popUpButtonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" pullsDown="YES" id="Zxj-rr-UnA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -83,7 +83,7 @@
</toolbarItem>
<toolbarItem implicitItemIdentifier="938D3EC6-1547-4AAB-86AF-B3FD3C7AF8BD" label="When Done" paletteLabel="When Done" toolTip="Action to perform when encoding is complete." sizingBehavior="auto" id="a3c-kV-98E">
<popUpButton key="view" verticalHuggingPriority="750" id="rfS-M1-CnB">
<rect key="frame" x="0.0" y="14" width="177" height="25"/>
<rect key="frame" x="0.0" y="14" width="173" height="25"/>
<autoresizingMask key="autoresizingMask"/>
<popUpButtonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="pch-jl-VXA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -118,6 +118,20 @@
<action selector="toggleDetails:" target="-2" id="EcM-0b-BRV"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="5C78EBF4-3788-4E56-8AFF-F458898F6A84" label="Quick Look" paletteLabel="Quick Look" image="NSQuickLookTemplate" bordered="YES" sizingBehavior="auto" id="nCq-Nc-EbB">
<nil key="toolTip"/>
<button key="view" verticalHuggingPriority="750" id="VlJ-Hc-dCl">
<rect key="frame" x="17" y="14" width="33" height="23"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSQuickLookTemplate" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="CfE-wU-25D">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="toggleQuickLook:" target="-2" id="6da-8Y-VUg"/>
</connections>
</toolbarItem>
</allowedToolbarItems>
<defaultToolbarItems>
<toolbarItem reference="SX6-mq-Hck"/>
@ -137,6 +151,7 @@
</objects>
<resources>
<image name="NSActionTemplate" width="15" height="15"/>
<image name="NSQuickLookTemplate" width="21" height="13"/>
<image name="details" width="15" height="12"/>
<image name="encode" width="32" height="32"/>
<image name="pauseencode" width="32" height="32"/>

View File

@ -30,6 +30,11 @@
return NO;
}
- (NSURL *)destinationURL
{
return nil;
}
- (NSAttributedString *)attributedDescription
{
return [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Stop action.", @"Queue -> Stop action")

View File

@ -19,6 +19,7 @@
#import "NSArray+HBAdditions.h"
@import HandBrakeKit;
@import QuickLookUI;
@interface HBQueueController () <NSToolbarItemValidation, NSMenuItemValidation, NSUserNotificationCenterDelegate, HBQueueTableViewControllerDelegate, HBQueueDetailsViewControllerDelegate>
@ -708,6 +709,18 @@ NSString * const HBQueueItemNotificationPathKey = @"HBQueueItemNotificationPathK
detailsItem.animator.collapsed = !detailsItem.isCollapsed;
}
- (IBAction)toggleQuickLook:(id)sender
{
if (QLPreviewPanel.sharedPreviewPanelExists && QLPreviewPanel.sharedPreviewPanel.isVisible)
{
[QLPreviewPanel.sharedPreviewPanel orderOut:sender];
}
else
{
[QLPreviewPanel.sharedPreviewPanel makeKeyAndOrderFront:sender];
}
}
#pragma mark - table view controller delegate
- (void)tableViewDidSelectItemsAtIndexes:(NSIndexSet *)indexes

View File

@ -27,6 +27,8 @@ typedef NS_ENUM(NSUInteger, HBQueueItemState) {
/// Whether the item has a file representation on disk or not.
@property (nonatomic, readonly) BOOL hasFileRepresentation;
@property (nonatomic, readonly, copy, nullable) NSURL *destinationURL;
/// The title of the item.
@property (nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) NSAttributedString *attributedDescription;

View File

@ -13,7 +13,9 @@
#import "NSArray+HBAdditions.h"
#import "HBPasteboardItem.h"
@interface HBQueueTableViewController () <NSMenuItemValidation, NSTableViewDataSource, NSTableViewDelegate, HBQueueItemViewDelegate>
@import QuickLookUI;
@interface HBQueueTableViewController () <NSMenuItemValidation, NSTableViewDataSource, NSTableViewDelegate, HBQueueItemViewDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate>
@property (nonatomic, weak, readonly) HBQueue *queue;
@property (nonatomic, strong) id<HBQueueTableViewControllerDelegate> delegate;
@ -399,4 +401,75 @@
return YES;
}
#pragma mark - QuickLook
- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel
{
return YES;
}
- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel
{
QLPreviewPanel.sharedPreviewPanel.delegate = self;
QLPreviewPanel.sharedPreviewPanel.dataSource = self;
}
- (void)endPreviewPanelControl:(QLPreviewPanel *)panel
{
QLPreviewPanel.sharedPreviewPanel.delegate = nil;
QLPreviewPanel.sharedPreviewPanel.dataSource = nil;
}
- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel
{
return self.tableView.selectedRowIndexes.count;
}
- (id<QLPreviewItem>)previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index
{
NSArray<id<HBQueueItem>> *items = [self.queue.items objectsAtIndexes:self.tableView.selectedRowIndexes];
if (items.count > index)
{
return items[index].destinationURL;
}
else
{
return nil;
}
}
- (BOOL)previewPanel:(QLPreviewPanel *)panel handleEvent:(NSEvent *)event
{
if (event.type == NSEventTypeKeyDown)
{
[self.tableView keyDown:event];
[QLPreviewPanel.sharedPreviewPanel reloadData];
return YES;
}
return NO;
}
- (void)keyDown:(NSEvent *)event
{
NSString *characters = event.charactersIgnoringModifiers;
if (characters.length)
{
unichar key = [characters characterAtIndex:0];
if (key == ' ')
{
if (QLPreviewPanel.sharedPreviewPanel.isVisible)
{
[QLPreviewPanel.sharedPreviewPanel orderOut:self];
}
else
{
[QLPreviewPanel.sharedPreviewPanel makeKeyAndOrderFront:self];
}
return;
}
}
[super keyDown:event];
}
@end

View File

@ -265,6 +265,7 @@
A990C55322FF4FBA00E07CE2 /* HandBrakeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9736F021C7DA5FE008F1D18 /* HandBrakeKit.framework */; };
A9935865256C346F00A6875E /* libzimg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A9935852256C346F00A6875E /* libzimg.a */; };
A9935866256C347800A6875E /* libzimg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A9935852256C346F00A6875E /* libzimg.a */; };
A9998605278868220019E76F /* QuickLookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A99985F3278868220019E76F /* QuickLookUI.framework */; };
A99F40CF1B624E7E00750170 /* HBPictureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A99F40CD1B624E7E00750170 /* HBPictureViewController.m */; };
A9A0CBE81CCEA3670045B3DF /* HBPlayerTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A0CBE61CCEA1D10045B3DF /* HBPlayerTrack.m */; };
A9A25D9C21182741005A8A0F /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9A25D9B21182741005A8A0F /* CoreMedia.framework */; };
@ -924,6 +925,7 @@
A99422DE1B1887B000DDB077 /* NSJSONSerialization+HBAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSJSONSerialization+HBAdditions.h"; sourceTree = "<group>"; };
A99422DF1B1887B000DDB077 /* NSJSONSerialization+HBAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSJSONSerialization+HBAdditions.m"; sourceTree = "<group>"; };
A997D8EB1A4ABB0900E19B6F /* HBPresetCoding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBPresetCoding.h; sourceTree = "<group>"; };
A99985F3278868220019E76F /* QuickLookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLookUI.framework; path = System/Library/Frameworks/QuickLookUI.framework; sourceTree = SDKROOT; };
A99F40CC1B624E7E00750170 /* HBPictureViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBPictureViewController.h; sourceTree = "<group>"; };
A99F40CD1B624E7E00750170 /* HBPictureViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBPictureViewController.m; sourceTree = "<group>"; };
A9A0CBE51CCEA1D10045B3DF /* HBPlayerTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBPlayerTrack.h; sourceTree = "<group>"; };
@ -1262,6 +1264,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A9998605278868220019E76F /* QuickLookUI.framework in Frameworks */,
A9BB1C6924DAD869007CD416 /* Sparkle.framework in Frameworks */,
273F203C14ADBC210021BE6D /* Cocoa.framework in Frameworks */,
A9E1467B16BC2ABD00C307BC /* QuartzCore.framework in Frameworks */,
@ -1451,6 +1454,7 @@
273F203414ADBAC30021BE6D /* Frameworks */ = {
isa = PBXGroup;
children = (
A99985F3278868220019E76F /* QuickLookUI.framework */,
A9935852256C346F00A6875E /* libzimg.a */,
A9442CDD24DABFED005EDF62 /* Sparkle.xcodeproj */,
A9A25D9B21182741005A8A0F /* CoreMedia.framework */,