Cleaned up logging

Added bagde icon to show timeout for clipboard clearing
Badge display not optimal if clipboard clearing is disabled
Autotype incovation on locked documents now activates MacPass to unlock.
If multipel entries match, the seleciton dialog will pop up as well
This commit is contained in:
michael starke
2014-03-27 22:03:04 +01:00
parent ee0a1009b5
commit 0160b9055a
12 changed files with 171 additions and 32 deletions

View File

@@ -0,0 +1,64 @@
//
// MPDockTileHelper.m
// MacPass
//
// Created by Michael Starke on 27/03/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "MPDockTileHelper.h"
#import "MPPasteBoardController.h"
@interface MPDockTileHelper () {
BOOL _pasteboardCleard;
}
@property (assign) NSTimeInterval timeStamp;
@end
@implementation MPDockTileHelper
- (instancetype)init {
self = [super init];
if (self) {
MPPasteBoardController *controller = [MPPasteBoardController defaultController];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didCopyToPastboard:) name:MPPasteBoardControllerDidCopyObjects object:controller];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didClearPasteboard:) name:MPPasteBoardControllerDidClearClipboard object:controller];
}
return self;
}
- (void)didCopyToPastboard:(NSNotification *)notification {
self.timeStamp = [NSDate timeIntervalSinceReferenceDate];
_pasteboardCleard = NO;
if([MPPasteBoardController defaultController].clearTimeout > 0) {
[self updateBadge];
}
}
- (void)didClearPasteboard:(NSNotification *)notification {
_pasteboardCleard = YES;
if([MPPasteBoardController defaultController].clearTimeout > 0) {
[[NSApp dockTile] setBadgeLabel:NSLocalizedString(@"CLEARING_PASTEBOARD","")];
}
[self performSelector:@selector(clearBadge) withObject:nil afterDelay:1];
}
- (void)clearBadge {
[[NSApp dockTile] setBadgeLabel:nil];
}
- (void)updateBadge {
if(_pasteboardCleard) {
return;
}
NSTimeInterval timeOut = [MPPasteBoardController defaultController].clearTimeout;
NSTimeInterval countDown = timeOut - ([NSDate timeIntervalSinceReferenceDate] - self.timeStamp);
if(countDown > 0) {
[[NSApp dockTile] setBadgeLabel:[[NSString alloc] initWithFormat:@"%d", (int)countDown]];
[self performSelector:@selector(updateBadge) withObject:nil afterDelay:1];
}
}
@end