mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 17:02:20 +00:00
dedicated delegate for user interaction with notifications
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
4C2E381F16D11FF900037A9D /* 05_LanguagesTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C2E381C16D11FF900037A9D /* 05_LanguagesTemplate.pdf */; };
|
||||
4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382216D1421B00037A9D /* MPIconHelper.m */; };
|
||||
4C2E382616D1470200037A9D /* MPViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382516D1470200037A9D /* MPViewController.m */; };
|
||||
4C2F17A21FD69BCA0097418D /* MPUserNotificationCenterDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2F17A11FD69BCA0097418D /* MPUserNotificationCenterDelegate.m */; };
|
||||
4C32B0E71A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C32B0E61A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m */; };
|
||||
4C3666411787327E00B249F1 /* MPDocument+Attachments.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */; };
|
||||
4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */; };
|
||||
@@ -371,6 +372,8 @@
|
||||
4C2E382216D1421B00037A9D /* MPIconHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconHelper.m; sourceTree = "<group>"; };
|
||||
4C2E382416D1470200037A9D /* MPViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPViewController.h; sourceTree = "<group>"; };
|
||||
4C2E382516D1470200037A9D /* MPViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPViewController.m; sourceTree = "<group>"; };
|
||||
4C2F17A01FD69BCA0097418D /* MPUserNotificationCenterDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPUserNotificationCenterDelegate.h; sourceTree = "<group>"; };
|
||||
4C2F17A11FD69BCA0097418D /* MPUserNotificationCenterDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPUserNotificationCenterDelegate.m; sourceTree = "<group>"; };
|
||||
4C32B0E51A1D4436007E12F1 /* KPKFormat+MPUTIDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KPKFormat+MPUTIDetection.h"; sourceTree = "<group>"; };
|
||||
4C32B0E61A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KPKFormat+MPUTIDetection.m"; sourceTree = "<group>"; };
|
||||
4C3666401787327E00B249F1 /* MPDocument+Attachments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Attachments.m"; sourceTree = "<group>"; };
|
||||
@@ -1089,6 +1092,8 @@
|
||||
4CA0F3EC1A3074B50067C0E5 /* MPWindowTitleComboBoxDelegate.m */,
|
||||
4CE501321BBC47F500FB819D /* MPTagsTokenFieldDelegate.h */,
|
||||
4CE501331BBC47F500FB819D /* MPTagsTokenFieldDelegate.m */,
|
||||
4C2F17A01FD69BCA0097418D /* MPUserNotificationCenterDelegate.h */,
|
||||
4C2F17A11FD69BCA0097418D /* MPUserNotificationCenterDelegate.m */,
|
||||
);
|
||||
name = Delegates;
|
||||
sourceTree = "<group>";
|
||||
@@ -1647,7 +1652,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
CLASSPREFIX = MP;
|
||||
LastUpgradeCheck = 0910;
|
||||
LastUpgradeCheck = 0920;
|
||||
ORGANIZATIONNAME = "HicknHack Software GmbH";
|
||||
TargetAttributes = {
|
||||
4C77E36115B84A240093A587 = {
|
||||
@@ -1935,6 +1940,7 @@
|
||||
4C3666411787327E00B249F1 /* MPDocument+Attachments.m in Sources */,
|
||||
4CF6C3021FBF39BF0055AD03 /* MPPluginTabelCellView.m in Sources */,
|
||||
4C10412C178CDD44001B5239 /* NSDate+Humanized.m in Sources */,
|
||||
4C2F17A21FD69BCA0097418D /* MPUserNotificationCenterDelegate.m in Sources */,
|
||||
4C0C59F118B17F10009C7B76 /* DDHotKeyUtilities.m in Sources */,
|
||||
4CEE46DD181C301D006BF1E5 /* MPAutotypeDaemon.m in Sources */,
|
||||
4C50CC041F6C18830095629D /* MPCollectionViewItem.m in Sources */,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0910"
|
||||
LastUpgradeVersion = "0920"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -81,16 +81,16 @@ static MPAutotypeDaemon *_sharedInstance;
|
||||
_enabled = NO;
|
||||
_targetPID = -1;
|
||||
[self bind:NSStringFromSelector(@selector(enabled))
|
||||
toObject:[NSUserDefaultsController sharedUserDefaultsController]
|
||||
toObject:NSUserDefaultsController.sharedUserDefaultsController
|
||||
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEnableGlobalAutotype]
|
||||
options:nil];
|
||||
|
||||
[self bind:NSStringFromSelector(@selector(hotKeyData))
|
||||
toObject:[NSUserDefaultsController sharedUserDefaultsController]
|
||||
toObject:NSUserDefaultsController.sharedUserDefaultsController
|
||||
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyGlobalAutotypeKeyDataKey]
|
||||
options:nil];
|
||||
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
|
||||
[NSWorkspace.sharedWorkspace.notificationCenter addObserver:self
|
||||
selector:@selector(_didDeactivateApplication:)
|
||||
name:NSWorkspaceDidDeactivateApplicationNotification
|
||||
object:nil];
|
||||
@@ -164,13 +164,14 @@ static MPAutotypeDaemon *_sharedInstance;
|
||||
}
|
||||
|
||||
/* find autotype documents */
|
||||
NSArray *documents = [NSApp orderedDocuments];
|
||||
NSArray *documents = NSApp.orderedDocuments;
|
||||
/* No open document, inform the user and return without any action */
|
||||
if(documents.count == 0) {
|
||||
NSUserNotification *notification = [[NSUserNotification alloc] init];
|
||||
notification.title = NSApp.applicationName;
|
||||
notification.informativeText = NSLocalizedString(@"AUTOTYPE_OVERLAY_NO_DOCUMENTS", "Notification: Autotype failed, no documents are open");
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
|
||||
|
||||
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
|
||||
return;
|
||||
}
|
||||
NSPredicate *filterPredicate = [NSPredicate predicateWithBlock:^BOOL(id _Nonnull evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
|
||||
@@ -183,7 +184,7 @@ static MPAutotypeDaemon *_sharedInstance;
|
||||
[NSApp.mainWindow makeKeyAndOrderFront:self];
|
||||
/* show the actual document window to the user */
|
||||
[documents.firstObject showWindows];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didUnlockDatabase:) name:MPDocumentDidUnlockDatabaseNotification object:nil];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didUnlockDatabase:) name:MPDocumentDidUnlockDatabaseNotification object:nil];
|
||||
return; // wait for the unlock to happen
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ static MPAutotypeDaemon *_sharedInstance;
|
||||
else {
|
||||
notification.informativeText = [NSString stringWithFormat:NSLocalizedString(@"AUTOTYPE_OVERLAY_NO_MATCH_FOR_%@", "Noticiation: Autotype failed to find a match for %@ (string placeholder)"), self.targetWindowTitle];
|
||||
}
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
|
||||
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
|
||||
}
|
||||
[self _performAutotypeForContext:context];
|
||||
}
|
||||
|
||||
13
MacPass/MPUserNotificationCenterDelegate.h
Normal file
13
MacPass/MPUserNotificationCenterDelegate.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// MPUserNotificationCenterDelegate.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 05.12.17.
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface MPUserNotificationCenterDelegate : NSObject <NSUserNotificationCenterDelegate>
|
||||
|
||||
@end
|
||||
21
MacPass/MPUserNotificationCenterDelegate.m
Normal file
21
MacPass/MPUserNotificationCenterDelegate.m
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// MPUserNotificationCenterDelegate.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 05.12.17.
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPUserNotificationCenterDelegate.h"
|
||||
|
||||
@implementation MPUserNotificationCenterDelegate
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
NSUserNotificationCenter.defaultUserNotificationCenter.delegate = self;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -66,7 +66,7 @@
|
||||
<rect key="frame" x="1" y="1" width="118" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField identifier="DataCell" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ADN-XZ-Lq7">
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ADN-XZ-Lq7">
|
||||
<rect key="frame" x="0.0" y="0.0" width="118" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="e8U-mE-mZh">
|
||||
@@ -125,7 +125,7 @@
|
||||
<rect key="frame" x="1" y="255" width="432" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="b5D-WW-IPI">
|
||||
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="b5D-WW-IPI">
|
||||
<rect key="frame" x="224" y="17" width="15" height="102"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
|
||||
Reference in New Issue
Block a user