From 0e5caab72a18f08910f6a7e9fc49990c2d38b366 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Mon, 3 Feb 2020 17:51:59 +0100 Subject: [PATCH] Fixed deprecation warnings --- MacPass/MPAppDelegate.m | 2 +- MacPass/MPContextMenuHelper.m | 6 +++--- MacPass/MPDocument.m | 8 ++++---- MacPass/MPDocumentController.m | 2 +- MacPass/MPDocumentWindowController.m | 10 +++++----- MacPass/MPEntryInspectorViewController.m | 4 ++-- MacPass/MPSettingsHelper.m | 2 +- MacPass/MPToolbarButton.m | 6 +++--- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 7ccae156..942ca07b 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -241,7 +241,7 @@ typedef NS_OPTIONS(NSInteger, MPAppStartupState) { self.saveMenuItem.title = saveTitle; } else if(menu == self.fixAutotypeMenuItem.menu) { - self.fixAutotypeMenuItem.hidden = !(NSEvent.modifierFlags & NSAlternateKeyMask); + self.fixAutotypeMenuItem.hidden = !(NSEvent.modifierFlags & NSEventModifierFlagOption); } else if(menu == self.importMenu) { NSMenuItem *exportXML = menu.itemArray.firstObject; diff --git a/MacPass/MPContextMenuHelper.m b/MacPass/MPContextMenuHelper.m index 7304dc91..8fce1f2f 100644 --- a/MacPass/MPContextMenuHelper.m +++ b/MacPass/MPContextMenuHelper.m @@ -84,7 +84,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { NSMenuItem *emptyTrash = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"EMPTY_TRASH", @"Menu item to empty the trash") action:[MPActionHelper actionOfType:MPActionEmptyTrash] keyEquivalent:@""]; - emptyTrash.keyEquivalentModifierMask = (NSShiftKeyMask | NSCommandKeyMask); + emptyTrash.keyEquivalentModifierMask = (NSEventModifierFlagShift | NSEventModifierFlagCommand); unichar backSpace = NSBackspaceCharacter; emptyTrash.keyEquivalent = [NSString stringWithCharacters:&backSpace length:1]; [items addObject:emptyTrash]; @@ -99,7 +99,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { NSMenuItem *copyPassword = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_PASSWORD", @"Menu item to copy the password of an entry") action:[MPActionHelper actionOfType:MPActionCopyPassword] keyEquivalent:@"c"]; - copyPassword.keyEquivalentModifierMask = (copyPassword.keyEquivalentModifierMask | NSAlternateKeyMask); + copyPassword.keyEquivalentModifierMask = (copyPassword.keyEquivalentModifierMask | NSEventModifierFlagOption); NSMenu *urlMenu = [[NSMenu alloc] init]; NSMenuItem *urlItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"URL", @"Submenu with options what to do with the URL of an entry") action:0 @@ -129,7 +129,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) { NSMenuItem *showHistory = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SHOW_HISTORY", @"Menu item to show the history of the selected entry") action:[MPActionHelper actionOfType:MPActionShowEntryHistory] keyEquivalent:@"h"]; - showHistory.keyEquivalentModifierMask = (showHistory.keyEquivalentModifierMask | NSCommandKeyMask | NSControlKeyMask); + showHistory.keyEquivalentModifierMask = (showHistory.keyEquivalentModifierMask | NSEventModifierFlagCommand | NSEventModifierFlagControl); [items addObject:showHistory]; } if(insertShowGroupInOutline) { diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 69ed34e2..523c2736 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -295,7 +295,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou return; } NSAlert *alert = [[NSAlert alloc] init]; - alert.alertStyle = NSWarningAlertStyle; + alert.alertStyle = NSAlertStyleWarning; alert.messageText = NSLocalizedString(@"FILE_CHANGED_BY_OTHERS_MESSAGE_TEXT", @"Message displayed when an open file was changed from another application"); alert.informativeText = NSLocalizedString(@"FILE_CHANGED_BY_OTHERS_INFO_TEXT", @"Informative text displayed when the file was change from another application"); alert.showsSuppressionButton = YES; @@ -369,7 +369,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou if(mergeKDB) { NSAlert *alert = [[NSAlert alloc] init]; - alert.alertStyle = NSWarningAlertStyle; + alert.alertStyle = NSAlertStyleWarning; alert.messageText = NSLocalizedString(@"ALERT_MERGE_KDB_FILE_MESSAGE", @"Alert message warning user about KDB file merge"); alert.informativeText = NSLocalizedString(@"ALERT_MERGE_KDB_FILE_INFO_TEXT", @"Informative text displayed when merging KDB files"); [alert addButtonWithTitle:NSLocalizedString(@"ALERT_MERGE_CONTINUE", @"Button in dialog to merge KDB changes into file!")]; @@ -751,7 +751,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou #pragma mark Actions - (void)emptyTrash:(id)sender { NSAlert *alert = [[NSAlert alloc] init]; - alert.alertStyle = NSWarningAlertStyle; + alert.alertStyle = NSAlertStyleWarning; alert.messageText = NSLocalizedString(@"WARNING_ON_EMPTY_TRASH_TITLE", "Message text for the alert displayed when clearing the Trash"); alert.informativeText = NSLocalizedString(@"WARNING_ON_EMPTY_TRASH_DESCRIPTION", "Informative Text displayed when clearing the Trash"); @@ -770,7 +770,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou KPKEntry *entry = node.asEntry; NSAlert *alert = [[NSAlert alloc] init]; - alert.alertStyle = NSWarningAlertStyle; + alert.alertStyle = NSAlertStyleWarning; alert.messageText = NSLocalizedString(@"WARNING_ON_DELETE_TRASHED_NODE_TITLE", "Message text for the alert displayed when deleting a node"); alert.informativeText = NSLocalizedString(@"WARNING_ON_DELETE_TRASHED_NODE_DESCRIPTION", "Informative Text displayed when clearing the Trash"); diff --git a/MacPass/MPDocumentController.m b/MacPass/MPDocumentController.m index 59731ee8..bccf5692 100644 --- a/MacPass/MPDocumentController.m +++ b/MacPass/MPDocumentController.m @@ -105,7 +105,7 @@ NSAlert *alert = [[NSAlert alloc] init]; alert.messageText = NSLocalizedString(@"FILE_OPEN_ERROR", "Error while reopening last known documents"); alert.informativeText = error.localizedDescription; - alert.alertStyle = NSCriticalAlertStyle; + alert.alertStyle = NSAlertStyleCritical; [alert runModal]; } diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 1e140d66..74bdb9fe 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -203,7 +203,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); savePanel.allowedFileTypes = @[(id)kUTTypeXML]; savePanel.canSelectHiddenExtension = YES; [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) { - if(result == NSFileHandlingPanelOKButton) { + if(result == NSModalResponseOK) { [document writeXMLToURL:savePanel.URL]; } }]; @@ -219,7 +219,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); openPanel.prompt = NSLocalizedString(@"OPEN_BUTTON_IMPORT_XML_OPEN_PANEL", "Open button in the open panel to import an XML file"); openPanel.message = NSLocalizedString(@"MESSAGE_XML_OPEN_PANEL", "Message in the open panel to import an XML file"); [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) { - if(result == NSFileHandlingPanelOKButton) { + if(result == NSModalResponseOK) { [document readXMLfromURL:openPanel.URL]; [self.splitViewController showOutline]; } @@ -284,7 +284,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); openPanel.message = NSLocalizedString(@"SELECT_FILE_TO_MERGE", @"Message for the dialog to open a file for merge"); //openPanel.allowedFileTypes = @[(id)kUTTypeXML]; [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) { - if(result == NSFileHandlingPanelOKButton) { + if(result == NSModalResponseOK) { [document mergeWithContentsFromURL:openPanel.URL key:document.compositeKey]; } }]; @@ -504,7 +504,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); if(document.shouldEnforcePasswordChange) { NSAlert *alert = [[NSAlert alloc] init]; - alert.alertStyle = NSCriticalAlertStyle; + alert.alertStyle = NSAlertStyleCritical; alert.messageText = NSLocalizedString(@"ENFORCE_PASSWORD_CHANGE_ALERT_TITLE", "Message text for the enforce password change alert"); alert.informativeText = NSLocalizedString(@"ENFORCE_PASSWORD_CHANGE_ALERT_DESCRIPTION", "Informative text for the enforce password change alert"); @@ -535,7 +535,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); else if(document.shouldRecommendPasswordChange) { NSAlert *alert = [[NSAlert alloc] init]; - alert.alertStyle = NSInformationalAlertStyle; + alert.alertStyle = NSAlertStyleInformational; alert.messageText = NSLocalizedString(@"RECOMMEND_PASSWORD_CHANGE_ALERT_TITLE", "Message text for the recommend password change alert"); alert.informativeText = NSLocalizedString(@"RECOMMEND_PASSWORD_CHANGE_ALERT_DESCRIPTION", "Informative text for the recommend password change alert"); diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m index 7de036f1..0ea63f1c 100644 --- a/MacPass/MPEntryInspectorViewController.m +++ b/MacPass/MPEntryInspectorViewController.m @@ -219,7 +219,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { savePanel.nameFieldStringValue = binary.name; [savePanel beginSheetModalForWindow:self.windowController.window completionHandler:^(NSInteger result) { - if(result == NSFileHandlingPanelOKButton) { + if(result == NSModalResponseOK) { NSError *error; BOOL sucess = [binary saveToLocation:savePanel.URL error:&error]; if(!sucess && error) { @@ -237,7 +237,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { openPanel.prompt = NSLocalizedString(@"OPEN_BUTTON_ADD_ATTACHMENT_OPEN_PANEL", "Open button in the open panel to add attachments to an entry"); openPanel.message = NSLocalizedString(@"MESSAGE_ADD_ATTACHMENT_OPEN_PANEL", "Message in the open panel to add attachments to an entry"); [openPanel beginSheetModalForWindow:self.windowController.window completionHandler:^(NSInteger result) { - if(result == NSFileHandlingPanelOKButton) { + if(result == NSModalResponseOK) { for (NSURL *attachmentURL in openPanel.URLs) { KPKBinary *binary = [[KPKBinary alloc] initWithContentsOfURL:attachmentURL]; [self.observer willChangeModelProperty]; diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 7ec3d674..766f51e8 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -212,7 +212,7 @@ NSString *const kMPDepricatedSettingsKeyAutotypeHideAccessibiltyWarning = @"Au if(!descriptorData) { return; // No user defaults } - NSArray *sortDescriptors = [NSUnarchiver unarchiveObjectWithData:descriptorData]; + NSArray *sortDescriptors = [NSKeyedUnarchiver unarchiveObjectWithData:descriptorData]; for(NSSortDescriptor *descriptor in sortDescriptors) { /* Brute force, just kill the settings if they might cause trouble */ diff --git a/MacPass/MPToolbarButton.m b/MacPass/MPToolbarButton.m index ae9d5514..678ab2b4 100644 --- a/MacPass/MPToolbarButton.m +++ b/MacPass/MPToolbarButton.m @@ -41,15 +41,15 @@ NSImageRep *rep = [self.image bestRepresentationForRect:NSMakeRect(0, 0, 100, 100) context:nil hints:nil]; CGFloat scale = rep.size.width / rep.size.height; switch (controlSize) { - case NSRegularControlSize: + case NSControlSizeRegular: self.image.size = NSMakeSize(16 * scale, 16); break; - case NSSmallControlSize: + case NSControlSizeSmall: self.image.size = NSMakeSize(14 * scale, 14); break; - case NSMiniControlSize: + case NSControlSizeMini: self.image.size = NSMakeSize(8 * scale, 8); default: