mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 08:52:20 +00:00
Using preferences instead of settings name. Alert for incompaitble plugins now has a button to show preferences
This commit is contained in:
@@ -210,9 +210,9 @@
|
||||
4C978E0D19AE54AB003067DF /* MPFlagsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C978E0C19AE54AB003067DF /* MPFlagsHelper.m */; };
|
||||
4C9BFFFB1FD19B5400264B16 /* MPPrettyPasswordTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C9BFFFA1FD19B5400264B16 /* MPPrettyPasswordTransformer.m */; };
|
||||
4CA08DA017A831B200A6544B /* MPAddEntryContextMenuDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA08D9F17A831B200A6544B /* MPAddEntryContextMenuDelegate.m */; };
|
||||
4CA0B2ED15BCADAC00654E32 /* SettingsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */; };
|
||||
4CA0B2ED15BCADAC00654E32 /* PreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EC15BCADAC00654E32 /* PreferencesWindow.xib */; };
|
||||
4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */; };
|
||||
4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */; };
|
||||
4CA0B2FC15BCAF8600654E32 /* MPPreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2FB15BCAF8600654E32 /* MPPreferencesWindowController.m */; };
|
||||
4CA0F3ED1A3074B50067C0E5 /* MPWindowTitleComboBoxDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0F3EC1A3074B50067C0E5 /* MPWindowTitleComboBoxDelegate.m */; };
|
||||
4CA182741F963FF600DD4A4A /* MPTitlebarColorAccessoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA182721F963FF600DD4A4A /* MPTitlebarColorAccessoryViewController.m */; };
|
||||
4CA182751F963FF600DD4A4A /* TitlebarColorAccessoryViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA182731F963FF600DD4A4A /* TitlebarColorAccessoryViewController.xib */; };
|
||||
@@ -724,12 +724,12 @@
|
||||
4C9BFFFA1FD19B5400264B16 /* MPPrettyPasswordTransformer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPrettyPasswordTransformer.m; sourceTree = "<group>"; };
|
||||
4CA08D9E17A831B200A6544B /* MPAddEntryContextMenuDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAddEntryContextMenuDelegate.h; sourceTree = "<group>"; };
|
||||
4CA08D9F17A831B200A6544B /* MPAddEntryContextMenuDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAddEntryContextMenuDelegate.m; sourceTree = "<group>"; };
|
||||
4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsWindow.xib; sourceTree = "<group>"; };
|
||||
4CA0B2EC15BCADAC00654E32 /* PreferencesWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesWindow.xib; sourceTree = "<group>"; };
|
||||
4CA0B2F715BCAF6700654E32 /* MPGeneralSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPGeneralSettingsController.h; sourceTree = "<group>"; };
|
||||
4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPGeneralSettingsController.m; sourceTree = "<group>"; };
|
||||
4CA0B2FA15BCAF8600654E32 /* MPSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsWindowController.h; sourceTree = "<group>"; };
|
||||
4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsWindowController.m; sourceTree = "<group>"; };
|
||||
4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPSettingsTab.h; sourceTree = "<group>"; };
|
||||
4CA0B2FA15BCAF8600654E32 /* MPPreferencesWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPreferencesWindowController.h; sourceTree = "<group>"; };
|
||||
4CA0B2FB15BCAF8600654E32 /* MPPreferencesWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPreferencesWindowController.m; sourceTree = "<group>"; };
|
||||
4CA0B30D15BCB6FD00654E32 /* MPPreferencesTab.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPreferencesTab.h; sourceTree = "<group>"; };
|
||||
4CA0F3EB1A3074B50067C0E5 /* MPWindowTitleComboBoxDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPWindowTitleComboBoxDelegate.h; sourceTree = "<group>"; };
|
||||
4CA0F3EC1A3074B50067C0E5 /* MPWindowTitleComboBoxDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPWindowTitleComboBoxDelegate.m; sourceTree = "<group>"; };
|
||||
4CA182711F963FF600DD4A4A /* MPTitlebarColorAccessoryViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPTitlebarColorAccessoryViewController.h; sourceTree = "<group>"; };
|
||||
@@ -1246,7 +1246,7 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4C47D77718B37911002755E4 /* Settings */ = {
|
||||
4C47D77718B37911002755E4 /* Preferences */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4CA0B2F715BCAF6700654E32 /* MPGeneralSettingsController.h */,
|
||||
@@ -1268,7 +1268,7 @@
|
||||
4CC663E5216F7A7100E33965 /* MPPluginRepositoryBrowserViewController.m */,
|
||||
4CC663E6216F7A7100E33965 /* PluginRepositoryBrowserView.xib */,
|
||||
);
|
||||
name = Settings;
|
||||
name = Preferences;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4C4B7EF517A46815000234C7 /* Inspector */ = {
|
||||
@@ -1547,7 +1547,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4C5133861FA0C32C00C94C73 /* Accessory */,
|
||||
4C47D77718B37911002755E4 /* Settings */,
|
||||
4C47D77718B37911002755E4 /* Preferences */,
|
||||
4C4B7EF517A46815000234C7 /* Inspector */,
|
||||
4C2E382416D1470200037A9D /* MPViewController.h */,
|
||||
4C2E382516D1470200037A9D /* MPViewController.m */,
|
||||
@@ -1605,7 +1605,7 @@
|
||||
4CA0B30E15BCB70200654E32 /* Protocolls */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */,
|
||||
4CA0B30D15BCB6FD00654E32 /* MPPreferencesTab.h */,
|
||||
4C2B0B7419F66F6400E48913 /* MPTargetNodeResolving.h */,
|
||||
4C7679BC1D75E690001F33D6 /* MPModelChangeObserving.h */,
|
||||
);
|
||||
@@ -1641,9 +1641,9 @@
|
||||
4CE8247016E2E96500573141 /* Window Controller */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4CA0B2FA15BCAF8600654E32 /* MPSettingsWindowController.h */,
|
||||
4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */,
|
||||
4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */,
|
||||
4CA0B2FA15BCAF8600654E32 /* MPPreferencesWindowController.h */,
|
||||
4CA0B2FB15BCAF8600654E32 /* MPPreferencesWindowController.m */,
|
||||
4CA0B2EC15BCADAC00654E32 /* PreferencesWindow.xib */,
|
||||
4C83814015BF4677001AE468 /* MPDocumentWindowController.h */,
|
||||
4C83814115BF4677001AE468 /* MPDocumentWindowController.m */,
|
||||
4CD884B615BD47080042BBF8 /* DocumentWindow.xib */,
|
||||
@@ -1830,7 +1830,7 @@
|
||||
4C3826B41AD04D8E007D7D67 /* 39_HistoryTemplate.pdf in Resources */,
|
||||
4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */,
|
||||
4C3826CD1AD04D8E007D7D67 /* 66_MoneyTemplate.pdf in Resources */,
|
||||
4CA0B2ED15BCADAC00654E32 /* SettingsWindow.xib in Resources */,
|
||||
4CA0B2ED15BCADAC00654E32 /* PreferencesWindow.xib in Resources */,
|
||||
4C76155C1764C04C0015A1A6 /* GeneralSettings.xib in Resources */,
|
||||
4CD884B715BD47080042BBF8 /* DocumentWindow.xib in Resources */,
|
||||
4C17F109184E6B6C00E85625 /* 30_TerminalTemplate.pdf in Resources */,
|
||||
@@ -1987,7 +1987,7 @@
|
||||
4C8F0C791FD05A6A00BE157F /* NSString+MPPrettyPasswordDisplay.m in Sources */,
|
||||
4C73B6F1215E64A7009787F7 /* MPWelcomeViewController.m in Sources */,
|
||||
4C6B7C7D18BE7EB0001D5D77 /* MPDocument+History.m in Sources */,
|
||||
4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */,
|
||||
4CA0B2FC15BCAF8600654E32 /* MPPreferencesWindowController.m in Sources */,
|
||||
4C4F72D118DF704400E8D378 /* DDHotKeyTextField.m in Sources */,
|
||||
4C8F0C6E1FCEE9B900BE157F /* MPPluginConstants.m in Sources */,
|
||||
4C83814215BF4677001AE468 /* MPDocumentWindowController.m in Sources */,
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#import "MPPasswordCreatorViewController.h"
|
||||
#import "MPPluginHost.h"
|
||||
#import "MPSettingsHelper.h"
|
||||
#import "MPSettingsWindowController.h"
|
||||
#import "MPPreferencesWindowController.h"
|
||||
#import "MPStringLengthValueTransformer.h"
|
||||
#import "MPPrettyPasswordTransformer.h"
|
||||
#import "MPTemporaryFileStorageCenter.h"
|
||||
@@ -59,7 +59,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
||||
|
||||
@property (strong) NSWindow *welcomeWindow;
|
||||
@property (strong) IBOutlet NSWindow *passwordCreatorWindow;
|
||||
@property (strong, nonatomic) MPSettingsWindowController *settingsController;
|
||||
@property (strong, nonatomic) MPPreferencesWindowController *preferencesController;
|
||||
@property (strong, nonatomic) MPPasswordCreatorViewController *passwordCreatorController;
|
||||
|
||||
@end
|
||||
@@ -228,10 +228,10 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
||||
#pragma mark -
|
||||
#pragma mark Actions
|
||||
- (void)showPreferences:(id)sender {
|
||||
if(self.settingsController == nil) {
|
||||
self.settingsController = [[MPSettingsWindowController alloc] init];
|
||||
if(self.preferencesController == nil) {
|
||||
self.preferencesController = [[MPPreferencesWindowController alloc] init];
|
||||
}
|
||||
[self.settingsController showSettings];
|
||||
[self.preferencesController showPreferences];
|
||||
}
|
||||
|
||||
- (void)showPasswordCreator:(id)sender {
|
||||
|
||||
@@ -523,7 +523,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
||||
}
|
||||
|
||||
- (NSURL *)suggestedKeyURL {
|
||||
MPAppDelegate *delegate = (MPAppDelegate *)[NSApp delegate];
|
||||
MPAppDelegate *delegate = (MPAppDelegate *)NSApp.delegate;
|
||||
if(!delegate.isAllowedToStoreKeyFile) {
|
||||
return nil;
|
||||
}
|
||||
@@ -630,7 +630,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
||||
if(!metaData.enforceMasterKeyChange) {
|
||||
return NO;
|
||||
}
|
||||
return ((24*60*60*metaData.masterKeyChangeEnforcementInterval) < -[metaData.masterKeyChanged timeIntervalSinceNow]);
|
||||
return ((24*60*60*metaData.masterKeyChangeEnforcementInterval) < - metaData.masterKeyChanged.timeIntervalSinceNow);
|
||||
}
|
||||
|
||||
- (BOOL)shouldRecommendPasswordChange {
|
||||
@@ -638,7 +638,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
||||
if(!metaData.recommendMasterKeyChange) {
|
||||
return NO;
|
||||
}
|
||||
return ( (24*60*60*metaData.masterKeyChangeRecommendationInterval) < -[metaData.masterKeyChanged timeIntervalSinceNow]);
|
||||
return ( (24*60*60*metaData.masterKeyChangeRecommendationInterval) < - metaData.masterKeyChanged.timeIntervalSinceNow);
|
||||
}
|
||||
|
||||
#pragma mark Data manipulation
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "MPViewController.h"
|
||||
#import "MPSettingsTab.h"
|
||||
#import "MPPreferencesTab.h"
|
||||
|
||||
@interface MPGeneralSettingsController : MPViewController <MPSettingsTab>
|
||||
@interface MPGeneralSettingsController : MPViewController <MPPreferencesTab>
|
||||
|
||||
@property (weak) IBOutlet NSButton *clearPasteboardOnQuitCheckButton;
|
||||
@property (weak) IBOutlet NSPopUpButton *clearPasteboardTimeoutPopup;
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
//
|
||||
|
||||
#import "MPViewController.h"
|
||||
#import "MPSettingsTab.h"
|
||||
#import "MPPreferencesTab.h"
|
||||
|
||||
@class DDHotKeyTextField;
|
||||
|
||||
@interface MPIntegrationSettingsController : MPViewController <MPSettingsTab, NSTextFieldDelegate>
|
||||
@interface MPIntegrationSettingsController : MPViewController <MPPreferencesTab, NSTextFieldDelegate>
|
||||
/* Autotype */
|
||||
@property (strong) IBOutlet NSButton *enableGlobalAutotypeCheckBox;
|
||||
@property (strong) IBOutlet DDHotKeyTextField *hotKeyTextField;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#import "MPPluginVersionComparator.h"
|
||||
|
||||
#import "NSApplication+MPAdditions.h"
|
||||
#import "MPAppDelegate.h"
|
||||
#import "MPSettingsHelper.h"
|
||||
|
||||
#import "NSError+Messages.h"
|
||||
@@ -286,7 +287,25 @@ NSString *const MPPluginHostPluginBundleIdentifiyerKey = @"MPPluginHostPluginBun
|
||||
alert.informativeText = NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_INFORMATIVE_TEXT", "Informative text of the alert displayed when plugins where disabled due to incompatibilty");
|
||||
alert.alertStyle = NSAlertStyleWarning;
|
||||
alert.showsSuppressionButton = YES;
|
||||
[alert runModal];
|
||||
[alert addButtonWithTitle:NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OK", @"Button in dialog to leave plugin ds disabled and continiue!")];
|
||||
[alert addButtonWithTitle:NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OPEN_PREFERENCES", @"Button in dialog to open plugin preferences pane!")];
|
||||
NSModalResponse returnCode = [alert runModal];
|
||||
//BOOL suppressWarning = (alert.suppressionButton.state == NSOnState);
|
||||
//[NSUserDefaults.standardUserDefaults setBool:suppressWarning forKey:kMPSettingsKeyAutotypeHideAccessibiltyWarning];
|
||||
switch(returnCode) {
|
||||
case NSAlertFirstButtonReturn: {
|
||||
/* ok, ignore */
|
||||
break;
|
||||
}
|
||||
case NSAlertSecondButtonReturn:
|
||||
/* open prefs */
|
||||
[((MPAppDelegate *)NSApp.delegate) showPreferences:nil];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
//
|
||||
|
||||
#import "MPViewController.h"
|
||||
#import "MPSettingsTab.h"
|
||||
#import "MPPreferencesTab.h"
|
||||
|
||||
@interface MPPluginSettingsController : MPViewController <MPSettingsTab>
|
||||
@interface MPPluginSettingsController : MPViewController <MPPreferencesTab>
|
||||
|
||||
- (IBAction)addOrRemovePlugin:(id)sender;
|
||||
- (IBAction)browsePlugins:(id)sender;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
Protrocoll to be implemented by ViewControllers that can be added to
|
||||
the settings windows. Tabs are ordered as the controllers are included.
|
||||
*/
|
||||
@protocol MPSettingsTab <NSObject>
|
||||
@protocol MPPreferencesTab <NSObject>
|
||||
|
||||
@required
|
||||
@property (readonly, copy) NSString *identifier;
|
||||
@@ -22,11 +22,18 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@protocol MPSettingsTab;
|
||||
@protocol MPPreferencesTab;
|
||||
|
||||
@interface MPSettingsWindowController : NSWindowController <NSToolbarDelegate>
|
||||
typedef NS_ENUM(NSUInteger, MPPreferencesTab) {
|
||||
MPPreferencesTabGeneral,
|
||||
MPPreferencesTabWorkflow,
|
||||
MPPreferencesTabUpdate,
|
||||
MPPreferencesTabPlugins
|
||||
};
|
||||
|
||||
- (void)showSettings;
|
||||
- (void)showSettingsTabWithIdentifier:(NSString *)identifier;
|
||||
@interface MPPreferencesWindowController : NSWindowController <NSToolbarDelegate>
|
||||
|
||||
- (void)showPreferences;
|
||||
- (void)showPreferencesTab:(MPPreferencesTab)tab;
|
||||
|
||||
@end
|
||||
@@ -20,40 +20,43 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#import "MPSettingsWindowController.h"
|
||||
#import "MPPreferencesWindowController.h"
|
||||
|
||||
#import "MPPreferencesTab.h"
|
||||
|
||||
#import "MPGeneralSettingsController.h"
|
||||
#import "MPIntegrationSettingsController.h"
|
||||
#import "MPWorkflowSettingsController.h"
|
||||
#import "MPUpdateSettingsController.h"
|
||||
#import "MPPluginSettingsController.h"
|
||||
|
||||
@interface MPSettingsWindowController () {
|
||||
@interface MPPreferencesWindowController () {
|
||||
NSString *lastIdentifier;
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) NSMutableDictionary *settingsController;
|
||||
@property (strong, nonatomic) NSMutableDictionary *preferencesController;
|
||||
@property (strong, nonatomic) NSMutableDictionary *toolbarItems;
|
||||
@property (strong) NSArray *defaultToolbarItems;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPSettingsWindowController
|
||||
@implementation MPPreferencesWindowController
|
||||
|
||||
- (NSString *)windowNibName {
|
||||
return @"SettingsWindow";
|
||||
return @"PreferencesWindow";
|
||||
}
|
||||
|
||||
-(id)init {
|
||||
self = [super initWithWindow:nil];
|
||||
if(self) {
|
||||
NSToolbar *tb = [[NSToolbar alloc] initWithIdentifier:@"SettingsToolBar"];
|
||||
NSToolbar *tb = [[NSToolbar alloc] initWithIdentifier:@"PreferencesToolBar"];
|
||||
tb.allowsUserCustomization = NO;
|
||||
tb.displayMode = NSToolbarDisplayModeIconAndLabel;
|
||||
_settingsController = [[NSMutableDictionary alloc] initWithCapacity:5];
|
||||
_preferencesController = [[NSMutableDictionary alloc] initWithCapacity:5];
|
||||
_toolbarItems = [[NSMutableDictionary alloc] initWithCapacity:5];
|
||||
lastIdentifier = nil;
|
||||
|
||||
[self _setupDefaultSettingsTabs];
|
||||
[self _setupDefaultPreferencesTabs];
|
||||
|
||||
tb.delegate = self;
|
||||
self.window.toolbar = tb;
|
||||
@@ -62,17 +65,17 @@
|
||||
}
|
||||
|
||||
|
||||
- (void)showSettings {
|
||||
- (void)showPreferences {
|
||||
if(self.defaultToolbarItems.count > 0) {
|
||||
[self showSettingsTabWithIdentifier:self.defaultToolbarItems[0]];
|
||||
[self _showPreferencesTabWithIdentifier:self.defaultToolbarItems[0]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showSettingsTabWithIdentifier:(NSString *)identifier {
|
||||
- (void)_showPreferencesTabWithIdentifier:(NSString *)identifier {
|
||||
if(nil == identifier) {
|
||||
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Identifier cannot be nil" userInfo:nil];
|
||||
}
|
||||
id<MPSettingsTab> tab = self.settingsController[identifier];
|
||||
id<MPPreferencesTab> tab = self.preferencesController[identifier];
|
||||
if(tab == nil){
|
||||
NSLog(@"Warning. Unknown settingscontroller for identifier: %@. Did you miss to add the controller?", identifier);
|
||||
return;
|
||||
@@ -111,8 +114,35 @@
|
||||
[self.window makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
- (void)_addSettingsTab:(id<MPSettingsTab>)tabController {
|
||||
if(NO == [tabController conformsToProtocol:@protocol(MPSettingsTab)]) {
|
||||
- (void)showPreferencesTab:(MPPreferencesTab)tab {
|
||||
Class tabClass;
|
||||
switch(tab) {
|
||||
case MPPreferencesTabPlugins:
|
||||
tabClass = MPPluginSettingsController.class;
|
||||
break;
|
||||
case MPPreferencesTabUpdate:
|
||||
tabClass = MPUpdateSettingsController.class;
|
||||
break;
|
||||
case MPPreferencesTabWorkflow:
|
||||
tabClass = MPWorkflowSettingsController.class;
|
||||
break;
|
||||
case MPPreferencesTabGeneral:
|
||||
default:
|
||||
tabClass = MPGeneralSettingsController.class;
|
||||
break;
|
||||
}
|
||||
NSString *identifier;
|
||||
for(id<MPPreferencesTab> tab in self.preferencesController) {
|
||||
if([tab isKindOfClass:tabClass]) {
|
||||
identifier = tab.identifier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[self _showPreferencesTabWithIdentifier:identifier];
|
||||
}
|
||||
|
||||
- (void)_addSettingsTab:(id<MPPreferencesTab>)tabController {
|
||||
if(NO == [tabController conformsToProtocol:@protocol(MPPreferencesTab)]) {
|
||||
NSException *protocollException = [NSException exceptionWithName:NSInvalidArgumentException
|
||||
reason:@"Controller must conform to MPSettingsTabProtrocoll"
|
||||
userInfo:nil];
|
||||
@@ -125,22 +155,22 @@
|
||||
@throw controllerException;
|
||||
}
|
||||
NSString *identifier = tabController.identifier;
|
||||
if(nil != self.settingsController[identifier]) {
|
||||
if(nil != self.preferencesController[identifier]) {
|
||||
NSLog(@"Warning: Settingscontroller with identifier %@ already present!", identifier);
|
||||
}
|
||||
else {
|
||||
self.settingsController[identifier] = tabController;
|
||||
self.preferencesController[identifier] = tabController;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_setupDefaultSettingsTabs {
|
||||
- (void)_setupDefaultPreferencesTabs {
|
||||
NSArray *controllers = @[ [[MPGeneralSettingsController alloc] init],
|
||||
[[MPIntegrationSettingsController alloc] init],
|
||||
[[MPWorkflowSettingsController alloc] init],
|
||||
[[MPUpdateSettingsController alloc] init],
|
||||
[[MPPluginSettingsController alloc] init] ];
|
||||
[[MPIntegrationSettingsController alloc] init],
|
||||
[[MPWorkflowSettingsController alloc] init],
|
||||
[[MPUpdateSettingsController alloc] init],
|
||||
[[MPPluginSettingsController alloc] init] ];
|
||||
NSMutableArray *identifier = [[NSMutableArray alloc] initWithCapacity:controllers.count];
|
||||
for(id<MPSettingsTab> controller in controllers) {
|
||||
for(id<MPPreferencesTab> controller in controllers) {
|
||||
[self _addSettingsTab:controller];
|
||||
[identifier addObject:controller.identifier];
|
||||
}
|
||||
@@ -150,14 +180,14 @@
|
||||
- (void)_showSettingsTab:(id)sender {
|
||||
if([sender respondsToSelector:@selector(itemIdentifier)]) {
|
||||
NSString *identfier = [sender itemIdentifier];
|
||||
[self showSettingsTabWithIdentifier:identfier];
|
||||
[self _showPreferencesTabWithIdentifier:identfier];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark NSToolbarDelegate
|
||||
|
||||
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
|
||||
return self.settingsController.allKeys;
|
||||
return self.preferencesController.allKeys;
|
||||
}
|
||||
|
||||
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar {
|
||||
@@ -165,7 +195,7 @@
|
||||
}
|
||||
|
||||
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar {
|
||||
return self.settingsController.allKeys;
|
||||
return self.preferencesController.allKeys;
|
||||
}
|
||||
|
||||
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag {
|
||||
@@ -176,7 +206,7 @@
|
||||
Setup the item to use the controllers label if one is present
|
||||
and supports the appropriate @optional protocol messages
|
||||
*/
|
||||
id<MPSettingsTab> tab = self.settingsController[itemIdentifier];
|
||||
id<MPPreferencesTab> tab = self.preferencesController[itemIdentifier];
|
||||
if([tab respondsToSelector:@selector(label)]) {
|
||||
item.label = [tab label];
|
||||
}
|
||||
@@ -21,8 +21,8 @@
|
||||
//
|
||||
|
||||
#import "MPViewController.h"
|
||||
#import "MPSettingsTab.h"
|
||||
#import "MPPreferencesTab.h"
|
||||
|
||||
@interface MPUpdateSettingsController : MPViewController <MPSettingsTab>
|
||||
@interface MPUpdateSettingsController : MPViewController <MPPreferencesTab>
|
||||
|
||||
@end
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
//
|
||||
|
||||
#import "MPViewController.h"
|
||||
#import "MPSettingsTab.h"
|
||||
#import "MPPreferencesTab.h"
|
||||
|
||||
@interface MPWorkflowSettingsController : MPViewController <MPSettingsTab>
|
||||
@interface MPWorkflowSettingsController : MPViewController <MPPreferencesTab>
|
||||
|
||||
@property (weak) IBOutlet NSPopUpButton *browserPopup;
|
||||
@property (weak) IBOutlet NSPopUpButton *doubleClickURLPopup;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPSettingsWindowController">
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPPreferencesWindowController">
|
||||
<connections>
|
||||
<outlet property="window" destination="1" id="3"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="400" height="300"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
Reference in New Issue
Block a user