@@ -171,6 +171,7 @@ @implementation AppDelegate {
171
171
VZVirtualMachineView *_virtualMachineView;
172
172
NSWindow *_window;
173
173
NSToolbar *_toolbar;
174
+ BOOL _enableController;
174
175
// Overlay for pause mode.
175
176
NSVisualEffectView *_pauseOverlayView;
176
177
// Zoom function properties.
@@ -185,6 +186,7 @@ - (instancetype)initWithVirtualMachine:(VZVirtualMachine *)virtualMachine
185
186
windowWidth : (CGFloat )windowWidth
186
187
windowHeight : (CGFloat )windowHeight
187
188
windowTitle : (NSString *)windowTitle
189
+ enableController : (BOOL )enableController
188
190
{
189
191
self = [super init ];
190
192
_virtualMachine = virtualMachine;
@@ -206,6 +208,7 @@ - (instancetype)initWithVirtualMachine:(VZVirtualMachine *)virtualMachine
206
208
// Setup some window configs
207
209
_window = [self createMainWindowWithTitle: windowTitle width: windowWidth height: windowHeight];
208
210
_toolbar = [self createCustomToolbar ];
211
+ _enableController = enableController;
209
212
[_virtualMachine addObserver: self
210
213
forKeyPath: @" state"
211
214
options: NSKeyValueObservingOptionNew
@@ -321,23 +324,31 @@ - (void)hideOverlay
321
324
static NSString *const PowerToolbarIdentifier = @" Power" ;
322
325
static NSString *const SpaceToolbarIdentifier = @" Space" ;
323
326
324
- - (void ) updateToolbarItems
327
+ - (NSArray <NSToolbarItemIdentifier> *) setupToolbarItemIdentifiers
325
328
{
326
329
NSMutableArray <NSToolbarItemIdentifier > *toolbarItems = [NSMutableArray array ];
327
- if ([self canPauseVirtualMachine ]) {
328
- [toolbarItems addObject: PauseToolbarIdentifier];
329
- }
330
- if ([self canResumeVirtualMachine ]) {
331
- [toolbarItems addObject: SpaceToolbarIdentifier];
332
- [toolbarItems addObject: PlayToolbarIdentifier];
333
- }
334
- if ([self canStopVirtualMachine ] || [self canStartVirtualMachine ]) {
335
- [toolbarItems addObject: SpaceToolbarIdentifier];
336
- [toolbarItems addObject: PowerToolbarIdentifier];
330
+ if (_enableController) {
331
+ if ([self canPauseVirtualMachine ]) {
332
+ [toolbarItems addObject: PauseToolbarIdentifier];
333
+ }
334
+ if ([self canResumeVirtualMachine ]) {
335
+ [toolbarItems addObject: SpaceToolbarIdentifier];
336
+ [toolbarItems addObject: PlayToolbarIdentifier];
337
+ }
338
+ if ([self canStopVirtualMachine ] || [self canStartVirtualMachine ]) {
339
+ [toolbarItems addObject: SpaceToolbarIdentifier];
340
+ [toolbarItems addObject: PowerToolbarIdentifier];
341
+ }
337
342
}
338
343
[toolbarItems addObject: NSToolbarSpaceItemIdentifier ];
339
344
[toolbarItems addObject: ZoomToolbarIdentifier];
340
345
[toolbarItems addObject: NSToolbarFlexibleSpaceItemIdentifier ];
346
+ return [toolbarItems copy ];
347
+ }
348
+
349
+ - (void )updateToolbarItems
350
+ {
351
+ NSArray <NSToolbarItemIdentifier > *toolbarItems = [self setupToolbarItemIdentifiers ];
341
352
[self setToolBarItems: toolbarItems];
342
353
}
343
354
@@ -467,14 +478,7 @@ - (NSWindow *)createMainWindowWithTitle:(NSString *)title
467
478
468
479
- (NSArray <NSToolbarItemIdentifier> *)toolbarDefaultItemIdentifiers : (NSToolbar *)toolbar
469
480
{
470
- return @[
471
- PauseToolbarIdentifier,
472
- SpaceToolbarIdentifier,
473
- PowerToolbarIdentifier,
474
- NSToolbarSpaceItemIdentifier ,
475
- ZoomToolbarIdentifier,
476
- NSToolbarFlexibleSpaceItemIdentifier
477
- ];
481
+ return [self setupToolbarItemIdentifiers ];
478
482
}
479
483
480
484
- (NSArray <NSToolbarItemIdentifier> *)toolbarAllowedItemIdentifiers : (NSToolbar *)toolbar
@@ -526,10 +530,10 @@ - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSToolbar
526
530
[item setLabel: @" Zoom" ];
527
531
[item setToolTip: @" Toggle Zoom" ];
528
532
} else if ([itemIdentifier isEqualToString: SpaceToolbarIdentifier]) {
529
- NSView *spaceView = [[[NSView alloc ] initWithFrame: NSMakeRect (0 , 0 , 5 , 10 )] autorelease ];
533
+ NSView *spaceView = [[[NSView alloc ] initWithFrame: NSMakeRect (0 , 0 , 2 , 10 )] autorelease ];
530
534
item.view = spaceView;
531
- item.minSize = NSMakeSize (2.5 , 10 );
532
- item.maxSize = NSMakeSize (2.5 , 10 );
535
+ item.minSize = NSMakeSize (1 , 10 );
536
+ item.maxSize = NSMakeSize (1 , 10 );
533
537
}
534
538
535
539
return item;
0 commit comments