Skip to content

Commit

Permalink
Update the search object and the actions in a more user friendly way
Browse files Browse the repository at this point in the history
* I've tidied up the code changes I made at 910accd (removed the tempNewObject and tempCurrentObject objects)
* Added the changes I made in 910accd to the `setObjectValue` method (to reduce the number of 'searchObjectChanged' messages sent)
* Added the previous and current objects to the QSSearchObjectChanged `userInfo` dictionary (so that methods receiving the notif can see the different)
* Made the actions reload only if the previous and new object's types are different (if the types are the same then the actions will be the same)
* Altered the `updateActions` and `updateActionsNow` methods so that the latter clears the action pane. This means that you won't get a 'blinking' effect for 0.1s (the time between `updateActions` and `updateActionsNow` being called) while the 2nd pane is empty
  • Loading branch information
pjrobertson committed Apr 30, 2012
1 parent d976092 commit f113ef6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
12 changes: 10 additions & 2 deletions Quicksilver/Code-QuickStepInterface/QSInterfaceController.m
Expand Up @@ -291,12 +291,14 @@ - (NSArray *)rankedActions {
}

- (void)updateActions {
[aSelector setResultArray:nil];
[aSelector clearObjectValue];
// update the actions after a delay (see setActionUpdateTimer for the delay length)
[self performSelectorOnMainThread:@selector(setActionUpdateTimer) withObject:nil waitUntilDone:YES];
}

- (void)updateActionsNow {
// Clear the current results in the aSelector ready for the new results
[aSelector setResultArray:nil];
[aSelector clearObjectValue];
[actionsUpdateTimer invalidate];

[aSelector setEnabled:YES];
Expand Down Expand Up @@ -390,12 +392,18 @@ - (void)objectIconModified:(NSNotification *)notif {

}

/* [notif userInfo] contains 2 objects and keys: a 'previousObject' key and a 'currentObject' key
corresponding to the previously selected object and the current selected object respectively */
- (void)searchObjectChanged:(NSNotification*)notif {
[[self window] disableFlushWindow];
if ([notif object] == dSelector) {
// If the previous and current objects have the same primary type, don't update the action
if (![[[[notif userInfo] objectForKey:@"previousObject"] types] isEqual:[[[notif userInfo] objectForKey:@"currentObject"] types]]
) {
[iSelector setObjectValue:nil];
[self updateActions];
[self updateViewLocations];
}
} else if ([notif object] == aSelector) {
QSAction *obj = [aSelector objectValue];
if ([obj isKindOfClass:[QSRankedObject class]])
Expand Down
37 changes: 23 additions & 14 deletions Quicksilver/Code-QuickStepInterface/QSSearchObjectView.m
Expand Up @@ -584,29 +584,38 @@ - (IBAction)updateResultView:(id)sender {
#pragma mark Object Value
- (void)selectObjectValue:(QSObject *)newObject {
QSObject *currentObject = [self objectValue];
QSObject *tempNewObject;
QSObject *tempCurrentObject;

// resolve the current and new objects in order to compare them
if ([newObject isKindOfClass:[QSRankedObject class]]) {
tempNewObject = [(QSRankedObject *)newObject object];
newObject = [(QSRankedObject *)newObject object];
}
if ([currentObject isKindOfClass:[QSRankedObject class]]) {
tempCurrentObject = [(QSRankedObject *)currentObject object];
currentObject = [(QSRankedObject *)currentObject object];
}
if ((tempNewObject ? tempNewObject : newObject) != (tempCurrentObject ? tempCurrentObject : currentObject)) {
// if the two objects are not the same, send an 'object chagned' notif
if (newObject != currentObject) {
[super setObjectValue:newObject];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SearchObjectChanged" object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SearchObjectChanged" object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:currentObject,@"previousObject",newObject,@"currentObject",nil]];
}
}

- (void)setObjectValue:(QSBasicObject *)newObject {
//if (newObject) NSLog(@"%p set value %@", self, newObject);
[self hideResultView:self];
[self clearSearch];
[parentStack removeAllObjects];
[self setResultArray:[NSArray arrayWithObjects:newObject, nil]];
[super setObjectValue:newObject];

[[NSNotificationCenter defaultCenter] postNotificationName:@"SearchObjectChanged" object:self];
QSObject *currentObject = [self objectValue];
if ([newObject isKindOfClass:[QSRankedObject class]]) {
newObject = [(QSRankedObject *)newObject object];
}
if ([currentObject isKindOfClass:[QSRankedObject class]]) {
currentObject = [(QSRankedObject *)currentObject object];
}
if (newObject != currentObject) {
[self hideResultView:self];
[self clearSearch];
[parentStack removeAllObjects];
[self setResultArray:[NSArray arrayWithObjects:newObject, nil]];
[super setObjectValue:newObject];

[[NSNotificationCenter defaultCenter] postNotificationName:@"SearchObjectChanged" object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:currentObject,@"previousObject",newObject,@"currentObject",nil]];
}
}

- (void)clearObjectValue {
Expand Down

0 comments on commit f113ef6

Please sign in to comment.