summaryrefslogtreecommitdiffstats
path: root/macosx/HBAddPresetController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2018-10-16 13:57:40 +0200
committerDamiano Galassi <[email protected]>2018-10-16 13:57:40 +0200
commit8150402d59c01f1a00587b7d169390710c4af58f (patch)
tree288361a0b59e8faed37564fb726fc55841d41a9d /macosx/HBAddPresetController.m
parentacee00072b04e9a86f9238fd1430e33e3b08a5d1 (diff)
MacGui: improve touch bar support, add touch bars to the add titles to queue and add preset sheets.
Diffstat (limited to 'macosx/HBAddPresetController.m')
-rw-r--r--macosx/HBAddPresetController.m48
1 files changed, 48 insertions, 0 deletions
diff --git a/macosx/HBAddPresetController.m b/macosx/HBAddPresetController.m
index ab011155b..b29c516c5 100644
--- a/macosx/HBAddPresetController.m
+++ b/macosx/HBAddPresetController.m
@@ -258,3 +258,51 @@ typedef NS_ENUM(NSUInteger, HBAddPresetControllerMode) {
}
@end
+
+@interface HBAddPresetController (TouchBar) <NSTouchBarProvider, NSTouchBarDelegate>
+@end
+
+@implementation HBAddPresetController (TouchBar)
+
+@dynamic touchBar;
+
+static NSTouchBarItemIdentifier HBTouchBarGroup = @"fr.handbrake.buttonsGroup";
+static NSTouchBarItemIdentifier HBTouchBarAdd = @"fr.handbrake.openSource";
+static NSTouchBarItemIdentifier HBTouchBarCancel = @"fr.handbrake.addToQueue";
+
+- (NSTouchBar *)makeTouchBar
+{
+ NSTouchBar *bar = [[NSTouchBar alloc] init];
+ bar.delegate = self;
+
+ bar.defaultItemIdentifiers = @[HBTouchBarGroup, NSTouchBarItemIdentifierOtherItemsProxy];
+ bar.principalItemIdentifier = HBTouchBarGroup;
+
+ return bar;
+}
+
+- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
+{
+ if ([identifier isEqualTo:HBTouchBarGroup])
+ {
+ NSCustomTouchBarItem *cancelItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:HBTouchBarAdd];
+ cancelItem.customizationLabel = NSLocalizedString(@"Cancel", @"Touch bar");
+ NSButton *cancelButton = [NSButton buttonWithTitle:NSLocalizedString(@"Cancel", @"Touch bar") target:self action:@selector(cancel:)];
+ [cancelButton.widthAnchor constraintGreaterThanOrEqualToConstant:200].active = YES;
+ cancelItem.view = cancelButton;
+
+ NSCustomTouchBarItem *addItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:HBTouchBarCancel];
+ addItem.customizationLabel = NSLocalizedString(@"Add Preset", @"Touch bar");
+ NSButton *addButton = [NSButton buttonWithTitle:NSLocalizedString(@"Add Preset", @"Touch bar") target:self action:@selector(add:)];
+ [addButton.widthAnchor constraintGreaterThanOrEqualToConstant:200].active = YES;
+ addButton.keyEquivalent = @"\r";
+ addItem.view = addButton;
+
+ NSGroupTouchBarItem *item = [NSGroupTouchBarItem groupItemWithIdentifier:identifier items:@[cancelItem, addItem]];
+ return item;
+ }
+
+ return nil;
+}
+
+@end