mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 19:22:25 +00:00
Added pretty pring value transformer
This commit is contained in:
@@ -195,6 +195,7 @@
|
||||
4C8F0C731FCF1B7A00BE157F /* MPTestPickcharsParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8F0C721FCF1B7A00BE157F /* MPTestPickcharsParser.m */; };
|
||||
4C8F0C791FD05A6A00BE157F /* NSString+MPPrettyPasswordDisplay.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8F0C781FD05A6A00BE157F /* NSString+MPPrettyPasswordDisplay.m */; };
|
||||
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 */; };
|
||||
4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */; };
|
||||
@@ -671,6 +672,8 @@
|
||||
4C93C5711FBDFEF900F36855 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/AutotypeBuilderView.strings; sourceTree = "<group>"; };
|
||||
4C978E0C19AE54AB003067DF /* MPFlagsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPFlagsHelper.m; sourceTree = "<group>"; };
|
||||
4C97CCEF1FA727DC00E58F8C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
4C9BFFF91FD19B5400264B16 /* MPPrettyPasswordTransformer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPrettyPasswordTransformer.h; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
@@ -1020,6 +1023,8 @@
|
||||
children = (
|
||||
4CF6C70F176F4533007A811D /* MPStringLengthValueTransformer.h */,
|
||||
4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */,
|
||||
4C9BFFF91FD19B5400264B16 /* MPPrettyPasswordTransformer.h */,
|
||||
4C9BFFFA1FD19B5400264B16 /* MPPrettyPasswordTransformer.m */,
|
||||
4C888C9516EB754B003D34A1 /* MPActionHelper.h */,
|
||||
4C888C9616EB754B003D34A1 /* MPActionHelper.m */,
|
||||
4C2E382116D1421B00037A9D /* MPIconHelper.h */,
|
||||
@@ -1912,6 +1917,7 @@
|
||||
4C6F228919A4A7F90012310C /* MPAutotypeClear.m in Sources */,
|
||||
4C0B038C18E36DA400B9F9C9 /* MPFixAutotypeWindowController.m in Sources */,
|
||||
4C7679BF1D76D6D8001F33D6 /* MPErrorRecoveryAttempter.m in Sources */,
|
||||
4C9BFFFB1FD19B5400264B16 /* MPPrettyPasswordTransformer.m in Sources */,
|
||||
4CA0F3ED1A3074B50067C0E5 /* MPWindowTitleComboBoxDelegate.m in Sources */,
|
||||
4CF78064176E75AD0032EE71 /* MPIntegrationSettingsController.m in Sources */,
|
||||
4C25703F1BF11C2300D39416 /* MPPluginSettingsController.m in Sources */,
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#import "MPSettingsHelper.h"
|
||||
#import "MPSettingsWindowController.h"
|
||||
#import "MPStringLengthValueTransformer.h"
|
||||
#import "MPPrettyPasswordTransformer.h"
|
||||
#import "MPTemporaryFileStorageCenter.h"
|
||||
#import "MPValueTransformerHelper.h"
|
||||
|
||||
@@ -62,6 +63,7 @@ NSString *const MPHelpURLKey = @"MPHelpURL";
|
||||
[MPSettingsHelper setupDefaults];
|
||||
[MPSettingsHelper migrateDefaults];
|
||||
[MPStringLengthValueTransformer registerTransformer];
|
||||
[MPPrettyPasswordTransformer registerTransformer];
|
||||
[MPValueTransformerHelper registerValueTransformer];
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#import "MPAutotypeBuilderViewController.h"
|
||||
#import "MPReferenceBuilderViewController.h"
|
||||
|
||||
#import "MPPrettyPasswordTransformer.h"
|
||||
#import "NSString+MPPasswordCreation.h"
|
||||
#import "KPKEntry+MPAdditions.h"
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "MPIconHelper.h"
|
||||
@@ -137,13 +137,13 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
|
||||
NSDictionary *dict = NSDictionaryOfVariableBindings(customFieldTableView, _tagsTokenField, _addCustomFieldButton);
|
||||
[self.generalView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-16-[customFieldTableView]-16-|"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:dict]];
|
||||
options:0
|
||||
metrics:nil
|
||||
views:dict]];
|
||||
[self.generalView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_tagsTokenField]-[customFieldTableView]-[_addCustomFieldButton]"
|
||||
options:0
|
||||
metrics:nil
|
||||
views:dict]];
|
||||
options:0
|
||||
metrics:nil
|
||||
views:dict]];
|
||||
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expires))]
|
||||
options:nil];
|
||||
|
||||
|
||||
[self.tagsTokenField bind:NSValueBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(tags))]
|
||||
@@ -546,13 +546,13 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
#pragma mark HNHUITextFieldDelegate
|
||||
- (NSMenu *)textField:(NSTextField *)textField textView:(NSTextView *)view menu:(NSMenu *)menu {
|
||||
/*for(NSMenuItem *item in [menu itemArray]) {
|
||||
if(item.action == @selector(showReferenceBuilder:)) {
|
||||
return menu; // item is already contained!
|
||||
}
|
||||
}
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SHOW_REFERENCE_BUILDER", @"Menu item to show the reference builder in a text view's context menu")action:@selector(showReferenceBuilder:) keyEquivalent:@""];
|
||||
item.representedObject = textField;
|
||||
[menu addItem:item];
|
||||
if(item.action == @selector(showReferenceBuilder:)) {
|
||||
return menu; // item is already contained!
|
||||
}
|
||||
}
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SHOW_REFERENCE_BUILDER", @"Menu item to show the reference builder in a text view's context menu")action:@selector(showReferenceBuilder:) keyEquivalent:@""];
|
||||
item.representedObject = textField;
|
||||
[menu addItem:item];
|
||||
*/
|
||||
return menu;
|
||||
}
|
||||
|
||||
17
MacPass/MPPrettyPasswordTransformer.h
Normal file
17
MacPass/MPPrettyPasswordTransformer.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MPPrettyPasswordTransformer.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 01.12.17.
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
APPKIT_EXTERN NSString *const MPPrettyPasswordTransformerName;
|
||||
|
||||
@interface MPPrettyPasswordTransformer : NSValueTransformer
|
||||
|
||||
+ (void)registerTransformer;
|
||||
|
||||
@end
|
||||
41
MacPass/MPPrettyPasswordTransformer.m
Normal file
41
MacPass/MPPrettyPasswordTransformer.m
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// MPPrettyPasswordTransformer.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 01.12.17.
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPPrettyPasswordTransformer.h"
|
||||
#import "NSString+MPPrettyPasswordDisplay.h"
|
||||
|
||||
NSString *const MPPrettyPasswordTransformerName = @"com.hicknhack.macpass.MPPrettyPasswordTransformerName";
|
||||
|
||||
@implementation MPPrettyPasswordTransformer
|
||||
|
||||
+ (Class)transformedValueClass {
|
||||
return NSAttributedString.class;
|
||||
}
|
||||
|
||||
+ (BOOL)allowsReverseTransformation {
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (void)registerTransformer {
|
||||
MPPrettyPasswordTransformer *transformer = [[MPPrettyPasswordTransformer alloc] init];
|
||||
[NSValueTransformer setValueTransformer:transformer
|
||||
forName:MPPrettyPasswordTransformerName];
|
||||
}
|
||||
|
||||
- (id)transformedValue:(id)value {
|
||||
if([value isKindOfClass:NSString.class]) {
|
||||
return ((NSString *)value).passwordPrettified;
|
||||
}
|
||||
if([value isKindOfClass:NSAttributedString.class]) {
|
||||
return ((NSAttributedString *)value).string;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user