Skip to content
Newer
Older
100644 799 lines (684 sloc) 25.5 KB
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
1 #import "QSPreferenceKeys.h"
2 #import "QSInterfaceController.h"
3 #import "QSHistoryController.h"
4 #import <Carbon/Carbon.h>
5 #import "QSObject.h"
6
7 #import "QSActionProvider.h"
8
9 #import "QSTypes.h"
10 #import "QSTaskController.h"
11 #import "QSNotifications.h"
12
13 #import "QSObjectCell.h"
14 #import "QSCommand.h"
15 #import "QSInterfaceController.h"
16
17 #import "QSObject_FileHandling.h"
18
19 #import "QSTaskViewer.h"
20 #import "QSNullObject.h"
21 #import "QSTaskController.h"
22 #import "QSController.h"
23 #import "QSInterfaceController.h"
24
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
25 #import "QSAction.h"
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
26 #import "QSWindow.h"
27 #import "QSSearchObjectView.h"
28 #import "QSMnemonics.h"
29 #import "QSLibrarian.h"
30 #import <QSCore/QSExecutor.h>
31 #import <IOKit/IOCFBundle.h>
32 #import <ApplicationServices/ApplicationServices.h>
33
34 #import "QSTextProxy.h"
35 #import "QSMenuButton.h"
36
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
37 #define KeyShift 0x38
38 #define KeyControl 0x3b
39 #define KeyOption 0x3A
40 #define KeyCommand 0x37
41 #define KeyCapsLock 0x39
42 #define KeySpace 0x31
43 #define KeyTabs 0x30
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
44
45 #import "CGSPrivate.h"
46
47 @implementation QSInterfaceController
48
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
49 + (void)initialize {
50 static BOOL initialized = NO;
861a7cf r1690@myBook: tiennou | 2008-10-30 19:19:10 +0100
tiennou7 authored Nov 7, 2008
51 if (!initialized) {
52 [NSApp registerServicesMenuSendTypes:[NSArray arrayWithObjects:NSStringPboardType, NSRTFPboardType, nil]
53 returnTypes:[NSArray arrayWithObjects:NSStringPboardType, NSRTFPboardType, nil]];
54 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
55 }
56
57 + (NSString *)name { return @"DefaultInterface"; }
58
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
59 - (id)init {
60 if (self = [super init]) {
61 [self loadWindow];
62 }
63 return self;
64 }
65
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
66 - (id)initWithWindow:(NSWindow *)window {
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
67 self = [super initWithWindow:window];
68 if (!self) {
69 [super release];
70 return nil;
71 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
72 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
9e96d6e @tiennou Fix the CGErrors when switching applications.
tiennou authored Feb 8, 2011
73 [nc addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:self];
74 [nc addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:self];
b616be9 @pjrobertson defined constants for notifications and given a description
pjrobertson authored Jun 25, 2011
75 [nc addObserver:self selector:@selector(objectModified:) name:QSObjectModified object:nil];
76 [nc addObserver:self selector:@selector(objectIconModified:) name:QSObjectIconModified object:nil];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
77 [nc addObserver:self selector:@selector(searchObjectChanged:) name:@"SearchObjectChanged" object:nil];
2765248 @skurfer allow actions to display multiple results via a notification
skurfer authored Apr 7, 2012
78 [nc addObserver:self selector:@selector(sourceArrayCreated:) name:@"QSSourceArrayCreated" object:nil];
e299637 @skurfer have the interface watch for QSSourceArrayUpdated notifications
skurfer authored Apr 7, 2012
79 [nc addObserver:self selector:@selector(sourceArrayChanged:) name:@"QSSourceArrayUpdated" object:nil];
9953d8b r365@myBook: tiennou | 2008-06-25 01:12:41 +0200
tiennou7 authored Jun 25, 2008
80 [nc addObserver:self selector:@selector(appChanged:) name:QSActiveApplicationChanged object:nil];
be854cd @skurfer remove featureLevel and related variables/methods - closes #341
skurfer authored Aug 31, 2011
81 [QSHistoryController sharedInstance];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
82 return self;
83 }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
84
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
85 - (void)dealloc {
86 if([actionsUpdateTimer isValid])
87 [actionsUpdateTimer invalidate];
88 if([hideTimer isValid])
89 [hideTimer invalidate];
90 [actionsUpdateTimer release];
91 [hideTimer release];
9b89873 @fheckl Fix crashes on interface changing
fheckl authored Feb 5, 2011
92 //[progressIndicator release];
93 //[iSelector release];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
94 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
95 [nc removeObserver:progressIndicator];
96 [nc removeObserver:self];
9b89873 @fheckl Fix crashes on interface changing
fheckl authored Feb 5, 2011
97
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
98 [super dealloc];
99 }
100
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
101 - (void)windowDidLoad {
102 //if (![[self window] setFrameUsingName:[self window] Key]) [[self window] center];
103 [progressIndicator stopAnimation:self];
104 [progressIndicator setDisplayedWhenStopped:NO];
105 [aSelector setEnabled:NO];
106 [aSelector setAllowText:NO];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
107 // [aSelector setInitiatesDrags:NO];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
108 [aSelector setDropMode:QSRejectDropMode];
109
110 [aSelector setSearchMode:SearchFilter];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
111 [aSelector setAllowNonActions:NO];
112
113 [iSelector retain];
114 [self hideIndirectSelector:nil];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
115
116 [[self window] setHidesOnDeactivate:NO];
117 [[self menuButton] setMenu:[(QSController *)[NSApp delegate] statusMenuWithQuit]];
118
119 #if 0
120 QSObjectCell *attachmentCell = [[QSObjectCell alloc] initTextCell:@""];
121 [attachmentCell setRepresentedObject:[QSObject fileObjectWithPath:@"/Volumes/Lore/"]];
122 [[attachmentCell representedObject] loadIcon];
123
124 NSTextAttachment *attachment = [[[NSTextAttachment alloc] init] autorelease];
125 [attachment setAttachmentCell: attachmentCell];
126 #endif
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
127
128 // NSAttributedString *attributedString = [NSAttributedString attributedStringWithAttachment: attachment];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
129 //[[commandView textStorage] appendAttributedString:attributedString];
130 [self searchObjectChanged:nil];
131
132 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
133 [nc addObserver:progressIndicator selector:@selector(startAnimation:) name:QSTasksStartedNotification object:nil];
134 [nc addObserver:progressIndicator selector:@selector(stopAnimation:) name:QSTasksEndedNotification object:nil];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
135 }
136
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
137 - (QSCommand *)currentCommand {
138 return [QSCommand commandWithDirectObject:[dSelector objectValue] actionObject:[aSelector objectValue] indirectObject:[iSelector objectValue]];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
139 }
140
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
141 - (void)setCommand:(QSCommand *)command {
142 [self window];
143 [dSelector setObjectValue:[command dObject]];
144 [aSelector setObjectValue:[command aObject]];
145 [iSelector setObjectValue:[command iObject]];
146 }
147
148 - (void)setCommandWithArray:(NSArray *)array {
149 [dSelector setObjectValue:[array objectAtIndex:0]];
150 [actionsUpdateTimer invalidate];
151 [aSelector setObjectValue:[array objectAtIndex:1]];
152 if ([array count] > 2)
153 [iSelector setObjectValue:[array objectAtIndex:2]];
154 else
155 [iSelector setObjectValue:nil];
156 }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
157
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
158 - (void)selectObject:(QSBasicObject *)object {
159 [dSelector setObjectValue:object];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
160 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
161
162 - (QSBasicObject *)selection {
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
163 return [dSelector objectValue];
164 }
165
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
166 - (void)showMainWindow:(id)sender {
167 [[self window] makeKeyAndOrderFront:sender];
168 if ([[NSUserDefaults standardUserDefaults] boolForKey:kSuppressHotKeysInCommand]) {
169 CGSConnection conn = _CGSDefaultConnection();
170 CGSSetGlobalHotKeyOperatingMode(conn, CGSGlobalHotKeyDisable);
171 }
172 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
173
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
174 - (void)willHideMainWindow:(id)sender {
175 if ([[NSUserDefaults standardUserDefaults] boolForKey:kSuppressHotKeysInCommand]) {
176 CGSConnection conn = _CGSDefaultConnection();
177 CGSSetGlobalHotKeyOperatingMode(conn, CGSGlobalHotKeyEnable);
178 }
179 if ([[self window] isVisible] && ![[self window] attachedSheet]) {
180 [[NSNotificationCenter defaultCenter] postNotificationName:@"InterfaceDeactivated" object:self];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
181 [[self window] makeFirstResponder:nil];
182 }
ebb3804 @pjrobertson Properly deal with responders.
pjrobertson authored Jan 22, 2012
183 // Close the Quicklook panel if the QS window closes
184 if([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible]) {
3a60f5c @pjrobertson Make sure the QL panel is properly closed (and objects released) when…
pjrobertson authored Feb 25, 2012
185 [(QSSearchObjectView *)[[QLPreviewPanel sharedPreviewPanel] delegate] closePreviewPanel];
ebb3804 @pjrobertson Properly deal with responders.
pjrobertson authored Jan 22, 2012
186 }
d6a3b06 @pjrobertson 10.6 QL fix: don't try and close the QS window if QL is open
pjrobertson authored Mar 14, 2012
187 }
188
189 - (void)hideMainWindowWithEffect:(id)effect {
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
190 [self willHideMainWindow:nil];
191 [self setHiding:YES];
192 if (effect && [[NSUserDefaults standardUserDefaults] boolForKey:kUseEffects])
193 [(QSWindow *)[self window] hideWithEffect:effect];
3805bdb @pjrobertson Closing command builder (in triggers prefs) correctly removed the emp…
pjrobertson authored Oct 29, 2011
194 else {
195 if ([self isKindOfClass:[QSCommandBuilder class]]) {
196 [self hideWindows:nil];
197 }
198 else {
199 [[self window] orderOut:nil];
200 }
201 }
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
202 [self setHiding:NO];
203 [[NSNotificationCenter defaultCenter] postNotificationName:QSReleaseOldCachesNotification object:self];
204
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
205 }
206
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
207 - (void)hideMainWindow:(id)sender {
208 [self hideMainWindowWithEffect:nil];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
209 }
210
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
211 - (void)hideMainWindowFromExecution:(id)sender {
212 [self hideMainWindowWithEffect:
213 [[self window] windowPropertyForKey:kQSWindowExecEffect]];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
214 }
215
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
216 - (void)hideMainWindowFromCancel:(id)sender {
217 [self hideMainWindowWithEffect:
218 [[self window] windowPropertyForKey:kQSWindowCancelEffect]];
219 }
220
221 - (void)hideMainWindowFromFade:(id)sender {
222 if ([[self window] respondsToSelector:@selector(windowPropertyForKey:)])
223 [self hideMainWindowWithEffect:
224 [[self window] windowPropertyForKey:kQSWindowFadeEffect]];
225 }
226
227 - (void)showIndirectSelector:(id)sender {
228 [[[self window] contentView] addSubview:iSelector];
229 [aSelector setNextKeyView:iSelector];
230 }
231
232 - (void)hideIndirectSelector:(id)sender {
233 [iSelector removeFromSuperview];
234 }
235
236 - (void)clearObjectView:(QSSearchObjectView *)view {
237 [view setResultArray:nil];
238 [view setSourceArray:nil];
239 [view setMatchedString:nil];
240 [view setSearchString:nil];
241 [view clearObjectValue];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
242 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
243
244 - (void)updateControl:(QSSearchObjectView *)control withArray:(NSArray *)array {
245 id defaultSelection = nil;
246 if ([array count]) {
247 if ([[array lastObject] isKindOfClass:[NSArray class]]) {
248 defaultSelection = [array objectAtIndex:0];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
249 if ([defaultSelection isKindOfClass:[NSNull class]])
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
250 defaultSelection = nil;
251 array = [array lastObject];
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
252
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
253 } else {
254 defaultSelection = [array objectAtIndex:0];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
255 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
256 } else {
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
257 [control clearObjectValue];
258 }
259 [control clearSearch];
260 [control setSourceArray:(NSMutableArray *)array];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
261 [control setResultArray:(NSMutableArray *)array];
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
262
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
263 [control selectObject:defaultSelection];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
264 }
265
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
266 - (void)setActionUpdateTimer {
267 if ([actionsUpdateTimer isValid]) {
268 // *** this was causing actions not to update for the search contents action
7f2a18d @pjrobertson Reduce actions update timer from 0.3s to 0.1s
pjrobertson authored Mar 30, 2012
269 [actionsUpdateTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:0.10]];
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
270 //[actionsUpdateTimer fire];
271 // NSLog(@"action %@", [actionsUpdateTimer fireDate]);
272 } else {
273 [actionsUpdateTimer invalidate];
274 [actionsUpdateTimer release];
7f2a18d @pjrobertson Reduce actions update timer from 0.3s to 0.1s
pjrobertson authored Mar 30, 2012
275 actionsUpdateTimer = [[NSTimer scheduledTimerWithTimeInterval:0.10 target:self selector:@selector(updateActionsNow) userInfo:nil repeats:NO] retain];
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
276 }
277 }
278
279 - (void)fireActionUpdateTimer {
280 [actionsUpdateTimer fire];
281 }
282
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
283 - (NSArray *)rankedActions {
c696fb1 r2076@wrk-149: tiennou | 2008-11-25 13:15:53 +0100
tiennou7 authored Nov 25, 2008
284 id dObject = [dSelector objectValue];
285 id iObject = [iSelector objectValue];
286 if([dObject isKindOfClass:[QSRankedObject class]])
287 dObject = [dObject object];
288
289 if([iObject isKindOfClass:[QSRankedObject class]])
cd7fb53 @pjrobertson Fixed iObject actions showing for dObject when closing/reopening QS
pjrobertson authored Jun 17, 2011
290 iObject = [iObject object];
c696fb1 r2076@wrk-149: tiennou | 2008-11-25 13:15:53 +0100
tiennou7 authored Nov 25, 2008
291
292 return [QSExec rankedActionsForDirectObject:dObject indirectObject:iObject];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
293 }
861a7cf r1690@myBook: tiennou | 2008-10-30 19:19:10 +0100
tiennou7 authored Nov 7, 2008
294
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
295 - (void)updateActions {
f113ef6 @pjrobertson Update the search object and the actions in a more user friendly way
pjrobertson authored Apr 30, 2012
296 // update the actions after a delay (see setActionUpdateTimer for the delay length)
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
297 [self performSelectorOnMainThread:@selector(setActionUpdateTimer) withObject:nil waitUntilDone:YES];
298 }
299
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
300 - (void)updateActionsNow {
f113ef6 @pjrobertson Update the search object and the actions in a more user friendly way
pjrobertson authored Apr 30, 2012
301 // Clear the current results in the aSelector ready for the new results
302 [aSelector setResultArray:nil];
303 [aSelector clearObjectValue];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
304 [actionsUpdateTimer invalidate];
305
306 [aSelector setEnabled:YES];
d9393fe @pjrobertson Revert "If the current actions array and the new actions array are th…
pjrobertson authored May 7, 2012
307 NSString *type = [NSString stringWithFormat:@"QSActionMnemonic:%@", [[dSelector objectValue] primaryType]];
308 NSArray *actions = [self rankedActions];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
309
d9393fe @pjrobertson Revert "If the current actions array and the new actions array are th…
pjrobertson authored May 7, 2012
310 [self updateControl:aSelector withArray:actions];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
311
312 [aSelector setMatchedString:type];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
313 [aSelector setSearchString:nil];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
314 }
315
316 - (void)updateIndirectObjects {
317 NSArray *indirects = [[[aSelector objectValue] provider] validIndirectObjectsForAction:[[aSelector objectValue] identifier] directObject:[dSelector objectValue]];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
318 [self updateControl:iSelector withArray:indirects];
319 [iSelector setSearchMode:(indirects?SearchFilter:SearchFilterAll)];
320 }
321
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
322 - (void)updateViewLocations {
2a704ed r1997@wrk-149: tiennou | 2008-11-18 21:28:49 +0100
tiennou7 authored Nov 24, 2008
323 QSAction *obj = [aSelector objectValue];
9438532 stop the attempted creation of an invalid trigger (one with no direct…
neurolepsy authored Mar 14, 2011
324 if (([obj respondsToSelector:@selector(argumentCount)]) && ([obj argumentCount] == 2))
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
325 [self showIndirectSelector:nil];
326 else
327 [self hideIndirectSelector:nil];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
328 }
329
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
330 - (void)performService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error {
331 QSObject *entry;
332 entry = [[QSObject alloc] initWithPasteboard:pboard];
333 [dSelector setObjectValue:entry];
334 [entry release];
335 [self activate:self];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
336 }
337
f0a145b @skurfer the sourceArray is mutable, so keep it the same type throughout
skurfer authored Mar 29, 2012
338 - (void)searchArray:(NSMutableArray *)array {
ac59ffd @skurfer new method that allows the results list to be displayed with and with…
skurfer authored Apr 26, 2011
339 // show the results list with the first pane empty
340 [self showArray:array withDirectObject:nil];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
341 }
342
f0a145b @skurfer the sourceArray is mutable, so keep it the same type throughout
skurfer authored Mar 29, 2012
343 - (void)showArray:(NSMutableArray *)array {
d40b9bf @skurfer when showing an array of children, select the first one by default - …
skurfer authored Apr 26, 2011
344 // display the results list with these items
dba0ec3 @skurfer check that the array isn't empty before trying to return its contents…
skurfer authored Apr 29, 2011
345 if (array && [array count] > 0) {
346 // put the first item from the array into the first pane
347 [self showArray:array withDirectObject:[array objectAtIndex:0]];
348 } else {
349 // nothing to display - present a blank interface
350 [self showArray:array withDirectObject:nil];
351 }
352
d40b9bf @skurfer when showing an array of children, select the first one by default - …
skurfer authored Apr 26, 2011
353 [dSelector showResultView:self];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
354 }
355
f0a145b @skurfer the sourceArray is mutable, so keep it the same type throughout
skurfer authored Mar 29, 2012
356 - (void)showArray:(NSMutableArray *)array withDirectObject:(QSObject *)dObject {
ac59ffd @skurfer new method that allows the results list to be displayed with and with…
skurfer authored Apr 26, 2011
357 [actionsUpdateTimer invalidate];
ea7fc58 @skurfer clearing the object view happens sooner now to avoid wiping out the r…
skurfer authored Apr 27, 2011
358 [self clearObjectView:dSelector];
f0a145b @skurfer the sourceArray is mutable, so keep it the same type throughout
skurfer authored Mar 29, 2012
359 [dSelector setSourceArray:array];
360 [dSelector setResultArray:array];
ac59ffd @skurfer new method that allows the results list to be displayed with and with…
skurfer authored Apr 26, 2011
361 [dSelector setSearchMode:SearchFilter];
362 if (dObject) {
363 // show an item from this array if set
1dba0b4 @skurfer actually show the object passed in instead of hard-coding it to the f…
skurfer authored Apr 29, 2011
364 [dSelector selectObjectValue:dObject];
ac59ffd @skurfer new method that allows the results list to be displayed with and with…
skurfer authored Apr 26, 2011
365 }
366 [self updateViewLocations];
367 [self updateActionsNow];
368 [self showMainWindow:self];
369 [[self window] makeFirstResponder:dSelector];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
370 }
371
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
372 #pragma mark -
373 #pragma mark Notifications
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
374 - (void)objectModified:(NSNotification*)notif {
375 if ([[dSelector objectValue] isEqual:[notif object]]) {
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
376 #ifdef DEBUG
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
377 if (VERBOSE) NSLog(@"Reloading actions for: %@", [notif object]);
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
378 #endif
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
379 [self updateActions];
380 }
4b64d71 @pjrobertson added a new ObjectIconModified notif for less ambiguity
pjrobertson authored Jun 22, 2011
381 }
382
383 - (void)objectIconModified:(NSNotification *)notif {
5208aeb @pjrobertson tidied up objectIconModified method
pjrobertson authored Jun 25, 2011
384 QSObject *object = [notif object];
385 if ([[dSelector objectValue] isEqual:object]) {
4b64d71 @pjrobertson added a new ObjectIconModified notif for less ambiguity
pjrobertson authored Jun 22, 2011
386 // redraw dObject icon
5208aeb @pjrobertson tidied up objectIconModified method
pjrobertson authored Jun 24, 2011
387 [dSelector updateObject:object];
4b64d71 @pjrobertson added a new ObjectIconModified notif for less ambiguity
pjrobertson authored Jun 22, 2011
388 }
5208aeb @pjrobertson tidied up objectIconModified method
pjrobertson authored Jun 24, 2011
389 if ([[iSelector objectValue] isEqual:object]) {
4b64d71 @pjrobertson added a new ObjectIconModified notif for less ambiguity
pjrobertson authored Jun 22, 2011
390 // redraw iObject icon
5208aeb @pjrobertson tidied up objectIconModified method
pjrobertson authored Jun 24, 2011
391 [iSelector updateObject:object];
4b64d71 @pjrobertson added a new ObjectIconModified notif for less ambiguity
pjrobertson authored Jun 22, 2011
392 }
3a68c6f @HenningJ Added a method to QSSearchObjectView (the class that handles each of …
HenningJ authored May 4, 2011
393
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
394 }
395
396 - (void)searchObjectChanged:(NSNotification*)notif {
397 [[self window] disableFlushWindow];
398 if ([notif object] == dSelector) {
f417a79 @pjrobertson Indent code
pjrobertson authored Apr 30, 2012
399 [iSelector setObjectValue:nil];
400 [self updateActions];
401 [self updateViewLocations];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
402 } else if ([notif object] == aSelector) {
2a704ed r1997@wrk-149: tiennou | 2008-11-18 21:28:49 +0100
tiennou7 authored Nov 24, 2008
403 QSAction *obj = [aSelector objectValue];
6614cdc Fix the broken third pane issue (this is all QSRankedObject's fault!).
tiennou7 authored Feb 27, 2009
404 if ([obj isKindOfClass:[QSRankedObject class]])
405 obj = [(QSRankedObject*)obj object];
2a704ed r1997@wrk-149: tiennou | 2008-11-18 21:28:49 +0100
tiennou7 authored Nov 24, 2008
406 if ([obj isKindOfClass:[QSAction class]]) {
2cd6aed @tiennou WIP on 64bit issues
tiennou authored May 23, 2012
407 NSInteger argumentCount = [obj argumentCount];
2a704ed r1997@wrk-149: tiennou | 2008-11-18 21:28:49 +0100
tiennou7 authored Nov 24, 2008
408 if (argumentCount == 2)
409 [self updateIndirectObjects];
410 [self updateViewLocations];
411 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
412 } else if ([notif object] == iSelector) {
413 [self updateViewLocations];
414 }
415 [[self window] enableFlushWindow];
416 }
417
2765248 @skurfer allow actions to display multiple results via a notification
skurfer authored Apr 8, 2012
418 - (void)sourceArrayCreated:(NSNotification *)notif
419 {
19243fe @skurfer use a constant to get the result array from the dictionary
skurfer authored May 3, 2012
420 [self showArray:[[notif userInfo] objectForKey:kQSResultArrayKey]];
2765248 @skurfer allow actions to display multiple results via a notification
skurfer authored Apr 8, 2012
421 }
422
e299637 @skurfer have the interface watch for QSSourceArrayUpdated notifications
skurfer authored Apr 8, 2012
423 - (void)sourceArrayChanged:(NSNotification *)notif
424 {
bc77fbf @skurfer look for the source array in userInfo instead of as the object
skurfer authored Apr 9, 2012
425 //NSLog(@"notif %@ - change to %@", [notif name], [notif userInfo]);
9abeacc @skurfer use resultArray instead of sourceArray
skurfer authored Apr 10, 2012
426 // resultArray and sourceArray point to the same object until the user starts typing.
427 // We want to stop getting updates at that point, so we compare to the resultArray instead.
19243fe @skurfer use a constant to get the result array from the dictionary
skurfer authored May 4, 2012
428 if ([[dSelector resultArray] isEqual:[[notif userInfo] objectForKey:kQSResultArrayKey]]) {
e299637 @skurfer have the interface watch for QSSourceArrayUpdated notifications
skurfer authored Apr 8, 2012
429 //NSLog(@"arraychanged");
430 if ([[dSelector->resultController window] isVisible]) {
431 [dSelector reloadResultTable];
432 [dSelector->resultController updateSelectionInfo];
433 }
9abeacc @skurfer use resultArray instead of sourceArray
skurfer authored Apr 10, 2012
434 if (![[dSelector resultArray] containsObject:[dSelector selectedObject]]) {
435 if ([[dSelector resultArray] count]) {
436 [dSelector selectObjectValue:[[dSelector resultArray] objectAtIndex:0]];
025b235 @skurfer put the first result from the array in the first pane
skurfer authored Apr 7, 2012
437 } else {
438 [dSelector clearObjectValue];
439 }
e299637 @skurfer have the interface watch for QSSourceArrayUpdated notifications
skurfer authored Apr 8, 2012
440 }
441 if ([self respondsToSelector:@selector(searchView:changedResults:)])
442 [self searchView:dSelector changedResults:[dSelector resultArray]];
443 }
444 }
445
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
446 - (void)appChanged:(NSNotification *)aNotification {
7cba769 @pjrobertson Don't attempt to close the QS window even when it's not open
pjrobertson authored May 10, 2012
447 // Close the QS window if it's visible and the Quicksilver itself isn't the application gaining focus
448 if ([[self window] isVisible] && ![[[[NSWorkspace sharedWorkspace] activeApplication] objectForKey:@"NSApplicationBundleIdentifier"] isEqualToString:@"com.blacktree.Quicksilver"]) {
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
449 [self hideWindows:self];
7cba769 @pjrobertson Don't attempt to close the QS window even when it's not open
pjrobertson authored May 10, 2012
450 }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
451 }
452
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
453 - (void)invalidateHide {
454 [hideTimer invalidate];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
455 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
456
457 - (void)timerHide:(NSTimer *)timer {
458 if (preview) return;
8188ba5 @tiennou StillDown() is gone.
tiennou authored May 22, 2012
459 bool stayOpen = [NSEvent pressedMouseButtons];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
460 if (!stayOpen) {
461 // NSLog(@"Window Closing");
462 if ([[NSApp keyWindow] level] <= [[self window] level])
463 // ***warning * this needs to be better
464 [self hideMainWindowFromFade:self];
465 [hideTimer invalidate];
466 } else {
467 // NSLog(@"Window Staying Open");
468 }
469 }
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
470
471 - (void)clear:(NSTimer *)timer {
472 [dSelector clearObjectValue];
473 [self updateActionsNow];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
474 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
475
292ecd3 @skurfer prevent the Command Builder from responding to notifications meant fo…
skurfer authored Apr 7, 2012
476 - (void)ignoreInterfaceNotifications
477 {
478 // subclasses (namely the Command Builder) need a way to overlook notifications meant for the main interface
479 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
480 [nc removeObserver:self name:@"QSSourceArrayCreated" object:nil];
481 [nc removeObserver:self name:@"QSSourceArrayUpdated" object:nil];
482 }
483
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
484 #pragma mark -
485 #pragma mark NSWindow
486 #pragma mark Delegate
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
487 - (BOOL)windowShouldClose:(id)sender {
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
488 [self hideMainWindowFromCancel:self];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
489 return NO;
490 }
491
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
492 #pragma mark Notifications
493 - (void)windowDidResignMain:(NSNotification *)aNotification {}
494
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
495 - (void)windowDidResignKey:(NSNotification *)aNotification {
d6a3b06 @pjrobertson 10.6 QL fix: don't try and close the QS window if QL is open
pjrobertson authored Mar 14, 2012
496 // Close the Quicklook panel if the QS window closes
497 if([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible]) {
498 return;
499 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
500 if ([aNotification object] == [self window]) {
501 if (hidingWindow) return;
502 if ([hideTimer isValid]) {
503 [hideTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
504 } else {
505 [hideTimer release];
506 hideTimer = [[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timerHide:) userInfo:nil repeats:YES] retain];
507 [hideTimer fire];
508 }
509 } else if (![NSApp keyWindow]) {
510 [self hideMainWindowFromFade:self];
511 }
512 }
513
514 - (void)windowDidBecomeKey:(NSNotification *)notification {
515 NSWindow *window = [notification object];
516 if ([[self window] attachedSheet] == window)
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
517 return;
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
518 if (window == [self window]) {
519 [hideTimer invalidate];
90c878e @tiennou 64 bit conversion in progress…
tiennou authored May 23, 2012
520 } else if ([window level] <= [[self window] level]) {
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
521 //NSLog(@"hide! %@", window);
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
522 // ***warning * this needs to be better
523 [self hideWindows:self];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
524 }
525 }
526
e113530 @pjrobertson Make code to display interface and jump to action (if set) common (ne…
pjrobertson authored Jan 19, 2012
527
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
528 #pragma mark -
529 #pragma mark Command Execution
530 - (void)executeCommandThreaded {
dc7014f @pjrobertson Move over to using @autoreleasepool{}
pjrobertson authored Jun 2, 2012
531 @autoreleasepool {
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
532 #ifdef DEBUG
dc7014f @pjrobertson Move over to using @autoreleasepool{}
pjrobertson authored Jun 2, 2012
533 NSDate *startDate = [NSDate date];
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
534 #endif
dc7014f @pjrobertson Move over to using @autoreleasepool{}
pjrobertson authored Jun 2, 2012
535 QSAction *action = [[aSelector objectValue] retain];
536 if ([[NSApp currentEvent] modifierFlags] & NSCommandKeyMask && !([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask) ) {
537 QSAction* alternate = [action alternate];
538 if (alternate != action) {
539 [alternate retain];
540 [action release];
541 action = alternate;
542 }
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
543 #ifdef DEBUG
dc7014f @pjrobertson Move over to using @autoreleasepool{}
pjrobertson authored Jun 2, 2012
544 if (VERBOSE) NSLog(@"Using Alternate Action: %@", action);
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
545 #endif
dc7014f @pjrobertson Move over to using @autoreleasepool{}
pjrobertson authored Jun 2, 2012
546 }
547 QSObject *dObject = [dSelector objectValue];
548 QSObject *iObject = [iSelector objectValue];
549 if( [dObject isKindOfClass:[QSRankedObject class]] )
550 dObject = [(QSRankedObject*)dObject object];
551 if( [iObject isKindOfClass:[QSRankedObject class]] )
552 iObject = [(QSRankedObject*)iObject object];
553 QSCommand *command = [QSCommand commandWithDirectObject:dObject actionObject:action indirectObject:iObject];
554 [command execute];
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
555 #ifdef DEBUG
dc7014f @pjrobertson Move over to using @autoreleasepool{}
pjrobertson authored Jun 2, 2012
556 if (VERBOSE) NSLog(@"Command executed (%ldms) ", (long)(-[startDate timeIntervalSinceNow] *1000));
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
557 #endif
dc7014f @pjrobertson Move over to using @autoreleasepool{}
pjrobertson authored Jun 2, 2012
558 [action release];
559 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
560 }
561
562 - (void)executePartialCommand:(NSArray *)array {
f2d98df @skurfer remove objects selected by the comma trick for triggers that ask for …
skurfer authored Jan 31, 2012
563 // remove objects previously selected by the comma trick
564 [self clearObjectView:dSelector];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
565 [dSelector setObjectValue:[array objectAtIndex:0]];
566 if ([array count] == 1) {
567 [self updateActionsNow];
568 [[self window] makeFirstResponder:aSelector];
569 } else {
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
570 [actionsUpdateTimer invalidate];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
571 [aSelector setObjectValue:[array objectAtIndex:1]];
572 if ([array count] > 2) {
573 [iSelector setObjectValue:[array objectAtIndex:2]];
574 }
575 [[self window] makeFirstResponder:iSelector];
576 }
577 [self updateViewLocations];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
578 [self showInterface:self];
579 }
580
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
581 - (void)executeCommand:(id)sender cont:(BOOL)cont encapsulate:(BOOL)encapsulate {
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
582 if ([actionsUpdateTimer isValid]) {
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
583 [actionsUpdateTimer fire];
584 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
585 if (![aSelector objectValue]) {
586 NSBeep();
587 return;
588 }
39d62e5 @pjrobertson Only add objects to the history if they've been 'acted upon'
pjrobertson authored Mar 30, 2012
589
590 // add the object being executed to the history
591 [dSelector updateHistory];
592
2cd6aed @tiennou WIP on 64bit issues
tiennou authored May 23, 2012
593 NSInteger argumentCount = [(QSAction *)[aSelector objectValue] argumentCount];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
594 if (argumentCount == 2) {
5095ea2 r1312@myBook: tiennou | 2008-09-13 13:12:42 +0200
tiennou7 authored Sep 17, 2008
595 BOOL indirectIsRequired = ![[aSelector objectValue] indirectOptional];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
596 BOOL indirectIsInvalid = ![iSelector objectValue];
597 BOOL indirectIsTextProxy = [[[iSelector objectValue] primaryType] isEqual:QSTextProxyType];
598 if (indirectIsRequired && (indirectIsInvalid || indirectIsTextProxy) ) {
4b64d71 @pjrobertson added a new ObjectIconModified notif for less ambiguity
pjrobertson authored Jun 22, 2011
599 if (indirectIsInvalid) NSBeep();
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
600 [[self window] makeFirstResponder:iSelector];
601 return;
602 }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
603 [QSExec noteIndirect:[iSelector objectValue] forAction:[aSelector objectValue]];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
604 }
605 if (encapsulate) {
606 [self encapsulateCommand];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
607 return;
608 }
73a4002 @skurfer * Add a user preference to jump to the second pane when the interface…
skurfer authored May 9, 2011
609 if (!cont) {
610 [self hideMainWindowFromExecution:self]; // *** this should only hide if no result comes in like 2 seconds
611 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
612 if ([[NSUserDefaults standardUserDefaults] boolForKey:kExecuteInThread] && [[aSelector objectValue] canThread])
613 [NSThread detachNewThreadSelector:@selector(executeCommandThreaded) toTarget:self withObject:nil];
614 else
615 [self executeCommandThreaded];
be854cd @skurfer remove featureLevel and related variables/methods - closes #341
skurfer authored Sep 1, 2011
616 [QSHist addCommand:[self currentCommand]];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
617 [dSelector saveMnemonic];
618 [aSelector saveMnemonic];
73a4002 @skurfer * Add a user preference to jump to the second pane when the interface…
skurfer authored May 9, 2011
619 if (argumentCount == 2) {
620 [iSelector saveMnemonic];
621 }
622 if (cont) {
623 [[self window] makeFirstResponder:aSelector];
624 }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
625 }
626
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
627 - (void)encapsulateCommand {
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
628 #ifdef DEBUG
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
629 if (VERBOSE) NSLog(@"Encapsulating Command");
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
630 #endif
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
631 QSCommand *commandObject = [self currentCommand];
632 [self selectObject:commandObject];
633 [self actionActivate:commandObject];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
634 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
635
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
636
637 #pragma mark -
638 #pragma mark IBActions
639 - (IBAction)showInterface:(id)sender {
6fa813a @pjrobertson Setting Quicksilver as scope of triggers now works
pjrobertson authored Apr 25, 2011
640
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
641 [[NSNotificationCenter defaultCenter] postNotificationName:@"InterfaceActivated" object:self];
642 [self showMainWindow:self];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
643 }
644
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
645 - (IBAction)activate:(id)sender {
4171345 @pjrobertson Remove the hide if pressed when already visible. Enabled by default
pjrobertson authored Mar 31, 2012
646 if ([[self window] isVisible]) {
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
647 [self hideMainWindowFromCancel:sender];
648 return;
649 }
98d6e2f @pjrobertson Further warning tidy ups.
pjrobertson authored Jun 5, 2012
650
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
651 [hideTimer invalidate];
652 [dSelector reset:self];
653 [self updateActions];
654 [iSelector reset:self];
655 [[dSelector objectValue] loadIcon];
656 [self setPreview:NO];
657 [self showInterface:self];
658
659 [[self window] makeFirstResponder:dSelector];
660
661 [dSelector setSearchMode:SearchFilterAll];
662
f1c38cf @pjrobertson Comments - is this methods really necessary?
pjrobertson authored Jun 9, 2012
663 // If the user still has a mofidier key down (just activated the interface) then for 0.075s, ignore the modifiers and post just the letter
664 // incase the user has started typing to search. ***IS THIS REALLY NECESSARY***? p_j_r 09/06/12
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
665 NSEvent *theEvent = [NSApp nextEventMatchingMask:NSKeyDownMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0.075] inMode:NSDefaultRunLoopMode dequeue:YES];
666 #warning dont do this unless the character is alphabetic
667 if (theEvent) {
2a704ed r1997@wrk-149: tiennou | 2008-11-18 21:28:49 +0100
tiennou7 authored Nov 24, 2008
668 theEvent = [NSEvent keyEventWithType:[theEvent type]
669 location:[theEvent locationInWindow]
670 modifierFlags:0
671 timestamp:[theEvent timestamp]
672 windowNumber:[theEvent windowNumber]
673 context:[theEvent context]
674 characters:[theEvent charactersIgnoringModifiers]
675 charactersIgnoringModifiers:[theEvent charactersIgnoringModifiers]
676 isARepeat:[theEvent isARepeat]
677 keyCode:[theEvent keyCode]];
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
678 #ifdef DEBUG
98d6e2f @pjrobertson Further warning tidy ups.
pjrobertson authored Jun 5, 2012
679 NSLog(@"Ignoring Modifiers for characters: %@", [theEvent characters]);
20f0ddb @pjrobertson last changes to all DEBUG parts of the code
pjrobertson authored May 22, 2011
680 #endif
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
681 [NSApp postEvent:theEvent atStart:YES];
682 //NSLog(@"time2 %f", [theEvent timestamp]);
683 }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
684 }
685
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
686 - (IBAction)activateInTextMode:(id)sender {
687 [dSelector transmogrify:sender];
688 [iSelector reset:self];
689 [self showInterface:self];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
690 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
691
137c777 @pjrobertson Use the already made method `actionActivate` but make it honour the s…
pjrobertson authored Jan 20, 2012
692 // Method that detects which pane should be focused on re-activating of Quicksilver interface
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
693 - (IBAction)actionActivate:(id)sender {
137c777 @pjrobertson Use the already made method `actionActivate` but make it honour the s…
pjrobertson authored Jan 20, 2012
694 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QSJumpToActionOnResult"]) {
695 [self updateActionsNow];
696 [iSelector reset:self];
697 [[self window] makeFirstResponder:aSelector];
698 }
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
699 [self showInterface:self];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
700 }
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
701
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
702 - (IBAction)executeCommand:(id)sender {
1938fba @skurfer take `displaysResult` into consideration before setting focus to the …
skurfer authored May 9, 2011
703 // run the action and set focus to the 1st pane
704 [self executeCommand:sender cont:NO encapsulate:NO];
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
705 }
706
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
707 - (IBAction)executeCommandAndContinue:(id)sender {
1938fba @skurfer take `displaysResult` into consideration before setting focus to the …
skurfer authored May 9, 2011
708 // run the action and set focus to the 2nd pane
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
709 [self executeCommand:sender cont:YES encapsulate:NO];
710 }
711
712 - (IBAction)shortCircuit:(id)sender {
713 //NSLog(@"scirr");
714 [self fireActionUpdateTimer];
715 NSArray *array = [aSelector resultArray];
716
2cd6aed @tiennou WIP on 64bit issues
tiennou authored May 23, 2012
717 NSInteger argumentCount = [(QSAction *)[aSelector objectValue] argumentCount];
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
718
719 if (sender == iSelector) {
2cd6aed @tiennou WIP on 64bit issues
tiennou authored May 23, 2012
720 NSInteger index = [array indexOfObject:[aSelector objectValue]];
721 NSInteger count = [array count];
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
722 if (index != count-1)
723 array = [[array subarrayWithRange:NSMakeRange(index+1, count-index-1)] arrayByAddingObjectsFromArray:
724 [array subarrayWithRange:NSMakeRange(0, index+1)]];
725 argumentCount = 0;
726 [[self window] makeFirstResponder:nil];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
727 }
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
728
729 if (argumentCount != 2) {
730 QSAction *action = nil;
731 QSAction *bestAction = nil;
3cde5aa Initial loop optimizations
Paul Kohut authored Dec 5, 2009
732 for(action in array) {
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
733 if ([action argumentCount] == 2) {
734 bestAction = action;
735 [aSelector selectObject:action];
736 [self updateIndirectObjects];
737 break;
738 }
739 }
740 if (!bestAction) {
741 NSBeep();
742 return;
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
743 }
744 }
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
745 [[self window] makeFirstResponder:iSelector];
746 }
747
748 - (IBAction)encapsulateCommand:(id)sender {
2a704ed r1997@wrk-149: tiennou | 2008-11-18 21:28:49 +0100
tiennou7 authored Nov 24, 2008
749 [self executeCommand:sender cont:NO encapsulate:YES];
750 }
751
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
752 - (IBAction)hideWindows:(id)sender {
753 [self hideMainWindow:self];
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
754 }
755
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
756 - (IBAction)showTasks:(id)sender {
757 [[NSClassFromString(@"QSTaskViewer") sharedInstance] showWindow:self];
758 }
759
760 - (IBAction)showAbout:(id)sender {
761 [[NSApp delegate] showAbout:sender];
762 }
763
764 #pragma mark -
765 #pragma mark NSResponder overrides
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
766 - (BOOL)performKeyEquivalent:(NSEvent *)theEvent {
451534b @andreberg Bug fix: We always showed the main window with a result here.
andreberg authored Nov 12, 2009
767 if (([theEvent modifierFlags] & NSCommandKeyMask) &&
768 ([theEvent modifierFlags] & NSShiftKeyMask) &&
769 ([[theEvent characters] length]) &&
770 ([[NSCharacterSet letterCharacterSet] characterIsMember:[[theEvent characters] characterAtIndex:0]])) {
2b08e42 Code cleanup
l33t5p1d0r authored Dec 12, 2007
771 return [[self aSelector] executeText:(NSEvent *)theEvent];
772 }
773 return NO;
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
774 }
775
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
776 #pragma mark -
777 #pragma mark Accessors
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
778
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
779 - (QSSearchObjectView *)dSelector { return dSelector; }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
780
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
781 - (QSSearchObjectView *)aSelector { return aSelector; }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
782
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
783 - (QSSearchObjectView *)iSelector { return iSelector; }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
784
2e432b8 r1691@myBook: tiennou | 2008-10-30 21:14:02 +0100
tiennou7 authored Nov 7, 2008
785 - (QSMenuButton *)menuButton { return menuButton; }
786
787 - (NSProgressIndicator *)progressIndicator { return progressIndicator; }
788
789 - (NSSize) maxIconSize { return NSMakeSize(128, 128); }
790
791 - (BOOL)preview { return preview; }
792 - (void)setPreview: (BOOL)flag { preview = flag; }
793
794 - (BOOL)hiding { return hidingWindow; }
795 - (void)setHiding:(BOOL)flag { hidingWindow = flag; }
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
796
3b0062a Added -setHiding to QSInterfaceController
l33t5p1d0r authored Jul 13, 2008
797
c9993d7 Initial import to GC
jnj authored Oct 30, 2007
798 @end
Something went wrong with that request. Please try again.