Selection Dialog for multiple matching entries sketched

This commit is contained in:
michael starke
2014-02-17 21:45:06 +01:00
parent c4b7dc1c64
commit e976398a5e
5 changed files with 133 additions and 3 deletions

View File

@@ -18,6 +18,7 @@
4C0728BF17B68ED0005A7DD9 /* SavePanelAccessoryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0728BE17B68ED0005A7DD9 /* SavePanelAccessoryView.xib */; }; 4C0728BF17B68ED0005A7DD9 /* SavePanelAccessoryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0728BE17B68ED0005A7DD9 /* SavePanelAccessoryView.xib */; };
4C08C3AE17B3022400BBBC95 /* KPKLegacyHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C08C3AD17B3022400BBBC95 /* KPKLegacyHeaderWriter.m */; }; 4C08C3AE17B3022400BBBC95 /* KPKLegacyHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C08C3AD17B3022400BBBC95 /* KPKLegacyHeaderWriter.m */; };
4C0C59F118B17F10009C7B76 /* DDHotKeyUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */; }; 4C0C59F118B17F10009C7B76 /* DDHotKeyUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */; };
4C0DD6C618B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0DD6C518B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib */; };
4C0F647817B6B65E00D9522A /* MPSheetWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0F647717B6B65E00D9522A /* MPSheetWindowController.m */; }; 4C0F647817B6B65E00D9522A /* MPSheetWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0F647717B6B65E00D9522A /* MPSheetWindowController.m */; };
4C0F647B17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0F647A17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m */; }; 4C0F647B17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0F647A17B6BC9C00D9522A /* MPSavePanelAccessoryViewController.m */; };
4C10412C178CDD44001B5239 /* NSDate+Humanized.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C10412B178CDD44001B5239 /* NSDate+Humanized.m */; }; 4C10412C178CDD44001B5239 /* NSDate+Humanized.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C10412B178CDD44001B5239 /* NSDate+Humanized.m */; };
@@ -364,6 +365,7 @@
4C08C3AF17B3036500BBBC95 /* KPKLegacyFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KPKLegacyFormat.h; path = Format/KPKLegacyFormat.h; sourceTree = "<group>"; }; 4C08C3AF17B3036500BBBC95 /* KPKLegacyFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KPKLegacyFormat.h; path = Format/KPKLegacyFormat.h; sourceTree = "<group>"; };
4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyUtilities.m; path = DDHotKey/DDHotKeyUtilities.m; sourceTree = "<group>"; }; 4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyUtilities.m; path = DDHotKey/DDHotKeyUtilities.m; sourceTree = "<group>"; };
4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = "<group>"; }; 4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = "<group>"; };
4C0DD6C518B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AutotypeCandidateSelectionWindow.xib; sourceTree = "<group>"; };
4C0F647617B6B65E00D9522A /* MPSheetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSheetWindowController.h; sourceTree = "<group>"; }; 4C0F647617B6B65E00D9522A /* MPSheetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSheetWindowController.h; sourceTree = "<group>"; };
4C0F647717B6B65E00D9522A /* MPSheetWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSheetWindowController.m; sourceTree = "<group>"; }; 4C0F647717B6B65E00D9522A /* MPSheetWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSheetWindowController.m; sourceTree = "<group>"; };
4C0F647917B6BC9C00D9522A /* MPSavePanelAccessoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSavePanelAccessoryViewController.h; sourceTree = "<group>"; }; 4C0F647917B6BC9C00D9522A /* MPSavePanelAccessoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSavePanelAccessoryViewController.h; sourceTree = "<group>"; };
@@ -1762,6 +1764,7 @@
4CD5D701177A5EE400100649 /* DatabaseSettingsWindow.xib */, 4CD5D701177A5EE400100649 /* DatabaseSettingsWindow.xib */,
4C0728B917B5B7A4005A7DD9 /* PasswordEditWindow.xib */, 4C0728B917B5B7A4005A7DD9 /* PasswordEditWindow.xib */,
4C68456E17BC2A0700FCDBFC /* WelcomeWindow.xib */, 4C68456E17BC2A0700FCDBFC /* WelcomeWindow.xib */,
4C0DD6C518B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib */,
); );
name = Windows; name = Windows;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -2008,6 +2011,7 @@
4C7ABA4917BAEC6700FF5799 /* 16_BrowserTemplate.pdf in Resources */, 4C7ABA4917BAEC6700FF5799 /* 16_BrowserTemplate.pdf in Resources */,
4C7ABA4A17BAEC6700FF5799 /* 17_CDRomTemplate.pdf in Resources */, 4C7ABA4A17BAEC6700FF5799 /* 17_CDRomTemplate.pdf in Resources */,
4C7ABA4B17BAEC6700FF5799 /* 19_EmailTemplate.pdf in Resources */, 4C7ABA4B17BAEC6700FF5799 /* 19_EmailTemplate.pdf in Resources */,
4C0DD6C618B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib in Resources */,
4C7ABA4C17BAEC6700FF5799 /* 20_MiscTemplate.pdf in Resources */, 4C7ABA4C17BAEC6700FF5799 /* 20_MiscTemplate.pdf in Resources */,
4C7ABA4E17BAEC7000FF5799 /* addEntryTemplate.pdf in Resources */, 4C7ABA4E17BAEC7000FF5799 /* addEntryTemplate.pdf in Resources */,
4C53A7A51864C39D000DFF0D /* KPKLocalizeable.strings in Resources */, 4C53A7A51864C39D000DFF0D /* KPKLocalizeable.strings in Resources */,

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPAutotypeDaemon">
<connections>
<outlet property="matchSelectionButton" destination="tAw-72-pSm" id="2a0-3C-UUB"/>
<outlet property="matchSelectionWindow" destination="1" id="ZYa-oC-Nfs"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<window title="Autotype Selection" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" wantsToBeColor="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="196" y="240" width="370" height="156"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="370" height="156"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NdQ-vM-dHT">
<rect key="frame" x="123" y="13" width="82" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="WJJ-kW-fak">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
</buttonCell>
<connections>
<action selector="orderOut:" target="-1" id="dcI-TT-kq3"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Jlm-i9-jVy">
<rect key="frame" x="205" y="13" width="151" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Perform Autotype" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="AER-eU-kcu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tAw-72-pSm">
<rect key="frame" x="111" y="58" width="242" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="TAr-ZQ-aDu">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<menu key="menu" title="OtherViews" id="7RT-wh-F0R">
<items>
<menuItem title="Item 3" id="HzV-Dh-6B9"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="q1d-ED-T5M">
<rect key="frame" x="18" y="102" width="334" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="There are multiple matches for the current Window. Please select which macht should be used." id="ehp-xc-B5g">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Epz-xU-9TM">
<rect key="frame" x="18" y="64" width="89" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Match to use:" id="pLz-Kc-yPh">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="NdQ-vM-dHT" firstAttribute="top" secondItem="tAw-72-pSm" secondAttribute="bottom" constant="20" symbolic="YES" id="7nN-gT-KRY"/>
<constraint firstItem="tAw-72-pSm" firstAttribute="trailing" secondItem="Jlm-i9-jVy" secondAttribute="trailing" id="BUy-GV-a8U"/>
<constraint firstItem="tAw-72-pSm" firstAttribute="top" secondItem="q1d-ED-T5M" secondAttribute="bottom" constant="20" id="Bwf-bJ-2AY"/>
<constraint firstItem="Jlm-i9-jVy" firstAttribute="leading" secondItem="NdQ-vM-dHT" secondAttribute="trailing" constant="12" symbolic="YES" id="DHs-Xz-gcZ"/>
<constraint firstAttribute="bottom" secondItem="NdQ-vM-dHT" secondAttribute="bottom" constant="20" symbolic="YES" id="Eua-I4-kKg"/>
<constraint firstItem="tAw-72-pSm" firstAttribute="trailing" secondItem="q1d-ED-T5M" secondAttribute="trailing" id="MsD-dU-YC8"/>
<constraint firstItem="Epz-xU-9TM" firstAttribute="baseline" secondItem="tAw-72-pSm" secondAttribute="baseline" id="O99-nG-qmf"/>
<constraint firstItem="Epz-xU-9TM" firstAttribute="leading" secondItem="q1d-ED-T5M" secondAttribute="leading" id="Vcg-aa-5pd"/>
<constraint firstAttribute="trailing" secondItem="q1d-ED-T5M" secondAttribute="trailing" constant="20" symbolic="YES" id="Wcu-aH-ONq"/>
<constraint firstItem="q1d-ED-T5M" firstAttribute="top" secondItem="2" secondAttribute="top" constant="20" symbolic="YES" id="eAk-Qk-bjO"/>
<constraint firstItem="q1d-ED-T5M" firstAttribute="top" relation="greaterThanOrEqual" secondItem="2" secondAttribute="top" constant="20" symbolic="YES" id="fCH-CB-BfF"/>
<constraint firstItem="Jlm-i9-jVy" firstAttribute="baseline" secondItem="NdQ-vM-dHT" secondAttribute="baseline" id="tOu-bn-J1u"/>
<constraint firstItem="q1d-ED-T5M" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="20" symbolic="YES" id="uCQ-aQ-3je"/>
<constraint firstItem="tAw-72-pSm" firstAttribute="leading" secondItem="Epz-xU-9TM" secondAttribute="trailing" constant="8" symbolic="YES" id="wJ9-T1-rT8"/>
</constraints>
</view>
</window>
</objects>
</document>

View File

@@ -15,6 +15,16 @@
*/ */
@interface MPAutotypeDaemon : NSObject @interface MPAutotypeDaemon : NSObject
@property (strong) IBOutlet NSWindow *matchSelectionWindow;
@property (weak) IBOutlet NSPopUpButton *matchSelectionButton;
@property (weak) IBOutlet NSButton *performAutotypeButton;
- (void)exectureAutotypeForEntry:(KPKEntry *)entry withWindowTitle:(NSString *)title; - (void)exectureAutotypeForEntry:(KPKEntry *)entry withWindowTitle:(NSString *)title;
/**
* Called by the selection window to start the autotype sequence
*
* @param sender sender of the action.
*/
- (IBAction)executeAutotypeWithSelectedMatch:(id)sender;
@end @end

View File

@@ -34,6 +34,11 @@ NSString *const kMPApplciationNameKey = @"applicationName";
NSAssert(NO,@"Not Implemented"); NSAssert(NO,@"Not Implemented");
} }
- (void)executeAutotypeWithSelectedMatch:(id)sender {
NSMenuItem *item = [self.matchSelectionButton selectedItem];
MPAutotypeContext *context = [item representedObject];
}
- (void)_didPressHotKey { - (void)_didPressHotKey {
NSArray *documents = [NSApp orderedDocuments]; NSArray *documents = [NSApp orderedDocuments];
MPDocument *currentDocument = nil; MPDocument *currentDocument = nil;
@@ -59,14 +64,14 @@ NSString *const kMPApplciationNameKey = @"applicationName";
Query the document to generate a autotype command list for the window title Query the document to generate a autotype command list for the window title
We do not care where this came form, just get the autotype commands We do not care where this came form, just get the autotype commands
*/ */
NSArray *autotypeCandidates = [[currentDocument autotypContextsForWindowTitle:windowTitle] lastObject]; NSArray *autotypeCandidates = [currentDocument autotypContextsForWindowTitle:windowTitle];
NSUInteger candiates = [autotypeCandidates count]; NSUInteger candiates = [autotypeCandidates count];
if(candiates == 0) { if(candiates == 0) {
return; // No Entries found. return; // No Entries found.
} }
if(candiates > 1) { if(candiates > 1) {
// open Dialog to select from possible entries [self _presentSelectionWindow];
return; // Nothing to do, we get called back by the window
} }
/* Just in case it's not there anymore, order the app for the window we want to autotype back to the foreground! */ /* Just in case it's not there anymore, order the app for the window we want to autotype back to the foreground! */
[self _orderApplicationToFront:applicationName]; [self _orderApplicationToFront:applicationName];
@@ -113,6 +118,16 @@ NSString *const kMPApplciationNameKey = @"applicationName";
return nil; return nil;
} }
- (void)_presentSelectionWindow {
if(!self.matchSelectionWindow) {
[[NSBundle mainBundle] loadNibNamed:@"AutotypeCandidateSelectionWindow" owner:self topLevelObjects:nil];
[self.performAutotypeButton setTarget:self];
[self.performAutotypeButton setAction:@selector(executeAutotypeWithSelectedMatch:)];
}
[self.matchSelectionWindow makeKeyAndOrderFront:self];
/* Setup Items in Popup */
}
- (void)_orderApplicationToFront:(NSString *)applicationName { - (void)_orderApplicationToFront:(NSString *)applicationName {
NSString *appleScript = [[NSString alloc] initWithFormat:@"activate application %@", applicationName]; NSString *appleScript = [[NSString alloc] initWithFormat:@"activate application %@", applicationName];
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:appleScript]; NSAppleScript *script = [[NSAppleScript alloc] initWithSource:appleScript];
@@ -120,4 +135,5 @@ NSString *const kMPApplciationNameKey = @"applicationName";
[script executeAndReturnError:&error]; [script executeAndReturnError:&error];
} }
@end @end

View File

@@ -31,6 +31,9 @@
@implementation MPDocument (Autotype) @implementation MPDocument (Autotype)
- (NSArray *)autotypContextsForWindowTitle:(NSString *)windowTitle { - (NSArray *)autotypContextsForWindowTitle:(NSString *)windowTitle {
if(!windowTitle) {
return nil;
}
NSArray *autotypeEntries = [self.root autotypeableChildEntries]; NSArray *autotypeEntries = [self.root autotypeableChildEntries];
NSMutableArray *contexts = [[NSMutableArray alloc] initWithCapacity:ceil([autotypeEntries count] / 4.0)]; NSMutableArray *contexts = [[NSMutableArray alloc] initWithCapacity:ceil([autotypeEntries count] / 4.0)];
for(KPKEntry *entry in autotypeEntries) { for(KPKEntry *entry in autotypeEntries) {