Fixed regression in Preferences preventing willShowTab and didShowTab from being called.

This commit is contained in:
Michael Starke
2020-11-03 17:08:09 +01:00
parent 927a4bf86e
commit 8e3bca062b
4 changed files with 34 additions and 10 deletions

View File

@@ -49,9 +49,21 @@
_tabViewController = [[MPTabViewController alloc] init];
_tabViewController.tabStyle = NSTabViewControllerTabStyleToolbar;
_tabViewController.transitionOptions = NSViewControllerTransitionNone | NSViewControllerTransitionAllowUserInteraction;
self.contentViewController = self.tabViewController;
_tabViewController.willSelectTabHandler = ^void(NSTabViewItem *item) {
if([item.viewController respondsToSelector:@selector(willShowTab)]) {
[(id<MPPreferencesTab>)item.viewController willShowTab];
}
};
_tabViewController.didSelectTabHandler = ^void(NSTabViewItem *item) {
if([item.viewController respondsToSelector:@selector(didShowTab)]) {
[(id<MPPreferencesTab>)item.viewController didShowTab];
}
};
[self _setupDefaultPreferencesTabs];
}
return self;
@@ -124,10 +136,10 @@
- (void)_setupDefaultPreferencesTabs {
NSArray<NSViewController<MPPreferencesTab>*> *controllers = @[ [[MPGeneralPreferencesController alloc] init],
[[MPIntegrationPreferencesController alloc] init],
[[MPWorkflowPreferencesController alloc] init],
[[MPUpdatePreferencesController alloc] init],
[[MPPluginPreferencesController alloc] init] ];
[[MPIntegrationPreferencesController alloc] init],
[[MPWorkflowPreferencesController alloc] init],
[[MPUpdatePreferencesController alloc] init],
[[MPPluginPreferencesController alloc] init] ];
for(NSViewController<MPPreferencesTab> *controller in controllers) {
NSString *identifier = controller.identifier;
if([self.tabViewController tabViewItemForViewController:controller]) {
@@ -140,7 +152,7 @@
NSTabViewItem *item = [NSTabViewItem tabViewItemWithViewController:controller];
item.identifier = controller.identifier;
if([controller respondsToSelector:@selector(label)]) {
item.label = controller.label;
item.label = controller.label;
}
if([controller respondsToSelector:@selector(image)]) {
item.image = controller.image;

View File

@@ -12,6 +12,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface MPTabViewController : NSTabViewController
@property (nonatomic, copy, nullable) void (^willSelectTabHandler)(NSTabViewItem *item);
@property (nonatomic, copy, nullable) void (^didSelectTabHandler)(NSTabViewItem *item);
@end
NS_ASSUME_NONNULL_END

View File

@@ -33,6 +33,9 @@
- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem {
[super tabView:tabView didSelectTabViewItem:tabViewItem];
[self _resizeWindowToFitTabView:tabViewItem];
if(self.didSelectTabHandler) {
self.didSelectTabHandler(tabViewItem);
}
}
- (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem {
@@ -40,6 +43,10 @@
if(tabViewItem.view) {
self.tabViewSizes[tabViewItem.identifier] = @(tabViewItem.view.frame.size);
}
if(self.willSelectTabHandler) {
self.willSelectTabHandler(tabViewItem);
}
}

View File

@@ -63,6 +63,8 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>UNDEFINED</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>MPHelpURL</key>
@@ -77,16 +79,16 @@
<string>MacPass accesses the Documents folder to load and save your databases and/or key files there</string>
<key>NSDownloadsFolderUsageDescription</key>
<string>MacPass accesses the Downloads folder to load and save your databases and/or key files there</string>
<key>NSNetworkVolumesUsageDescription</key>
<string>MacPass need access to Network Volumes to load and save your databases and/or key files there</string>
<key>NSRemovableVolumesUsageDescription</key>
<string>MacPass need access to Removable Volumes to load and save your databases and/or key files there</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012-2020 HicknHack Software GmbH. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSNetworkVolumesUsageDescription</key>
<string>MacPass need access to Network Volumes to load and save your databases and/or key files there</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSRemovableVolumesUsageDescription</key>
<string>MacPass need access to Removable Volumes to load and save your databases and/or key files there</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>NSUserNotificationAlertStyle</key>