From 480e035307bfc2dfa5feee16dacd43150b520d6a Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 28 Aug 2009 16:27:20 +0000 Subject: =?UTF-8?q?=E2=80=A2=20moved=20"Replace=20Editor=20Content"=20(Fav?= =?UTF-8?q?orites/History)=20settings=20from=20popup=20lists=20to=20gear?= =?UTF-8?q?=20menu=20since=20these=20are=20settings=20=E2=80=A2=20revert?= =?UTF-8?q?=20the=20actual=20behaviour=20for=20"Save=20...=20to=20Favorite?= =?UTF-8?q?"=20to=20"Save=20All=20to=20Favorite"=20since=20this=20was=20th?= =?UTF-8?q?e=20default=20behaviour=20in=20previous=20releases=20-=20to=20r?= =?UTF-8?q?estrict=20what=20should=20be=20save=20as=20favorite=20press=20?= =?UTF-8?q?=E2=8C=98=20to=20toggle=20"Save=20All=20to=20Favorite"=20into?= =?UTF-8?q?=20"Save=20current=20query/selection=20to=20Favorite"=20?= =?UTF-8?q?=E2=80=A2=20while=20choosing=20a=20favorite=20or=20history=20it?= =?UTF-8?q?em=20each=20modifier=20key=20=E2=87=A7,^,=E2=8C=A5,=20or=20?= =?UTF-8?q?=E2=8C=98=20inverts=20the=20current=20setting=20for=20"Replace?= =?UTF-8?q?=20Editor=20Content"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DBView.xib | 277 ++++++++++++++++++++---------------- Source/CustomQuery.m | 77 +++++++--- 2 files changed, 206 insertions(+), 148 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index b1d78499..35c6f941 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -8,7 +8,6 @@ 353.00 YES - YES @@ -47,7 +46,7 @@ {3.40282e+38, 3.40282e+38} {780, 480} - + 256 YES @@ -2856,29 +2855,6 @@ 6418 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - CorePasteboardFlavorType 0x75726C20 - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - NeXT font pasteboard type - NeXT ruler pasteboard type - WebURLsWithTitlesPboardType - - {688, 14} @@ -3143,30 +3119,9 @@ YES - - - Replace Editor Content - - 2147483647 - - - _popUpItemAction: - - - - - YES - YES - - - 2147483647 - - - _popUpItemAction: - - + YES ..placeholder for seachfield.. 2147483647 @@ -3177,7 +3132,6 @@ - 1 YES 3 YES @@ -3233,14 +3187,16 @@ 1000 - + - Replace Editor Content + YES + Save All to Favorites 2147483647 _popUpItemAction: + 1001 @@ -3278,7 +3234,7 @@ - 2 + 1 YES 3 YES @@ -3398,6 +3354,16 @@ 5 + + + History Replaces Editor Content + + 2147483647 + + + _popUpItemAction: + + YES @@ -3410,6 +3376,28 @@ _popUpItemAction: + + + Favorite Replaces Editor Content + + 2147483647 + + + _popUpItemAction: + + + + + YES + YES + + + 2147483647 + + + _popUpItemAction: + + Shift Right @@ -3540,7 +3528,7 @@ YES - 15 + 18 YES 1 YES @@ -4749,7 +4737,6 @@ {944, 550} - {{0, 0}, {1920, 1178}} {780, 502} @@ -11360,7 +11347,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 NSView - + 4364 YES @@ -11369,7 +11356,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 268 {{20, 1}, {176, 19}} - YES 343014976 @@ -11431,12 +11417,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {217, 20} - - NSView - + 4364 YES @@ -11445,7 +11429,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 268 {{20, 1}, {176, 19}} - YES 343014976 @@ -11507,8 +11490,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {217, 20} - - NSView @@ -15282,22 +15263,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6421 - - - value: values.QueryFavoriteReplacesContent - - - - - - value: values.QueryFavoriteReplacesContent - value - values.QueryFavoriteReplacesContent - 2 - - - 6428 - queryFavoritesSearchMenuItem @@ -15346,22 +15311,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6440 - - - value: values.QueryHistoryReplacesContent - - - - - - value: values.QueryHistoryReplacesContent - value - values.QueryHistoryReplacesContent - 2 - - - 6443 - queryHistorySearchMenuItem @@ -15434,6 +15383,54 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6459 + + + value: values.QueryFavoriteReplacesContent + + + + + + value: values.QueryFavoriteReplacesContent + value + values.QueryFavoriteReplacesContent + 2 + + + 6464 + + + + value: values.QueryHistoryReplacesContent + + + + + + value: values.QueryHistoryReplacesContent + value + values.QueryHistoryReplacesContent + 2 + + + 6465 + + + + nextKeyView + + + + 6467 + + + + nextKeyView + + + + 6468 + @@ -18222,6 +18219,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + + @@ -18333,8 +18333,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - + @@ -18368,8 +18368,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 YES - - @@ -21601,11 +21599,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - - 6423 - - - 6424 @@ -21635,16 +21628,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - - 6441 - - - - - 6444 - - - 6445 @@ -21674,6 +21657,26 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + 6460 + + + + + 6461 + + + + + 6462 + + + + + 6466 + + + @@ -21778,6 +21781,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 1178.IBEditorWindowLastContentRect 1178.IBPluginDependency 1178.ImportedFromIB2 + 1180.IBAttributePlaceholdersKey 1180.IBPluginDependency 1180.ImportedFromIB2 1181.IBPluginDependency @@ -22950,21 +22954,23 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6413.IBPluginDependency 6414.IBPluginDependency 6422.IBPluginDependency - 6423.IBPluginDependency 6424.IBPluginDependency 6431.IBEditorWindowLastContentRect 6431.IBPluginDependency 6432.IBAttributePlaceholdersKey 6432.IBPluginDependency 6433.IBPluginDependency - 6441.IBPluginDependency - 6444.IBPluginDependency 6445.IBPluginDependency 6447.IBEditorWindowLastContentRect 6447.IBPluginDependency 6448.IBAttributePlaceholdersKey 6448.IBPluginDependency 6449.IBPluginDependency + 6460.IBPluginDependency + 6461.IBPluginDependency + 6462.IBPluginDependency + 6466.IBAttributePlaceholdersKey + 6466.IBPluginDependency 654.IBPluginDependency 654.ImportedFromIB2 655.IBPluginDependency @@ -23284,7 +23290,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 ToolTip - Choose a query from your recent queries + Q2hvb3NlIGEgcXVlcnkgZnJvbSB5b3VyIHJlY2VudCBxdWVyaWVzICjijKXijJhIKQ com.apple.InterfaceBuilder.CocoaPlugin @@ -23293,9 +23299,17 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin - {{424, 709}, {215, 98}} + {{323, 485}, {215, 98}} com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Save current query, selection, or - if no selection or current query could be found - the entire content to Favorite. + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -23305,12 +23319,13 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 ToolTip - Choose a favorite from the menu or save the current query to the favorites + Q2hvb3NlIGEgZmF2b3JpdGUgZnJvbSB0aGUgbWVudSBvciBzYXZlIHF1ZXJpZXMgdG8gdGhlIGZhdm9y +aXRlcyAo4oyl4oyYRik com.apple.InterfaceBuilder.CocoaPlugin - {{542, 743}, {215, 64}} + {{516, 546}, {215, 37}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -23969,9 +23984,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{167, 430}, {944, 550}} + {{66, 206}, {944, 550}} - {{167, 430}, {944, 550}} + {{66, 206}, {944, 550}} {{62, 352}, {845, 504}} @@ -24137,7 +24152,7 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{381, 414}, {236, 305}} + {{350, 236}, {259, 349}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -24794,8 +24809,7 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{409, 828}, {217, 20}} + {{409, 736}, {217, 20}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -24809,8 +24823,6 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin {{419, 772}, {217, 20}} com.apple.InterfaceBuilder.CocoaPlugin @@ -24825,6 +24837,19 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + U2F2ZSBlZGl0b3IgY29udGVudCB0byBGYXZvcml0ZS4gUHJlc3Mg4oyYIHRvIHJlc3RyaWN0IGZvciBj +dXJyZW50IHF1ZXJ5IG9yIHNlbGVjdGlvbi4 + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -25020,7 +25045,7 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik - 6459 + 6468 diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 48d3eb96..17ca6d35 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -147,12 +147,28 @@ NSLocalizedString(@"Cannot save an empty query.", @"empty query informative message")); return; } + + [NSApp beginSheet:queryFavoritesSheet + modalForWindow:tableWindow + modalDelegate:self + didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo:@"addSelectionToNewQueryFavorite"]; + } + if ([queryFavoritesButton indexOfSelectedItem] == 2) { + // This should never evaluate to true as we are now performing menu validation, meaning the 'Save Query to Favorites' menu item will + // only be enabled if the query text view has at least one character present. + if ([[textView string] isEqualToString:@""]) { + NSBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + NSLocalizedString(@"Cannot save an empty query.", @"empty query informative message")); + return; + } + [NSApp beginSheet:queryFavoritesSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) - contextInfo:@"addNewQueryFavorite"]; + contextInfo:@"addAllToNewQueryFavorite"]; } else if ([queryFavoritesButton indexOfSelectedItem] == 3) { // Open query favorite manager @@ -164,7 +180,11 @@ } else if ([queryFavoritesButton indexOfSelectedItem] > 5) { // Choose favorite - if([prefs boolForKey:@"QueryFavoriteReplacesContent"]) + BOOL replaceContent = [prefs boolForKey:@"QueryFavoriteReplacesContent"]; + + if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) + replaceContent = !replaceContent; + if(replaceContent) [textView setSelectedRange:NSMakeRange(0,[[textView string] length])]; [textView insertText:[[[prefs objectForKey:@"queryFavorites"] objectAtIndex:([queryFavoritesButton indexOfSelectedItem] - 6)] objectForKey:@"query"]]; @@ -177,9 +197,15 @@ - (IBAction)chooseQueryHistory:(id)sender { // Choose history item - if ([queryHistoryButton indexOfSelectedItem] > 3) { - if([prefs boolForKey:@"QueryHistoryReplacesContent"]) + if ([queryHistoryButton indexOfSelectedItem] > 1) { +; + BOOL replaceContent = [prefs boolForKey:@"QueryHistoryReplacesContent"]; + + if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) + replaceContent = !replaceContent; + if(replaceContent) [textView setSelectedRange:NSMakeRange(0,[[textView string] length])]; + [textView insertText:[queryHistoryButton titleOfSelectedItem]]; } } @@ -202,7 +228,7 @@ // "Clear History" menu item - clear query history if (sender == clearHistoryMenuItem) { // Remove all history buttons beginning from the end - while([queryHistoryButton numberOfItems] > 4) + while([queryHistoryButton numberOfItems] > 2) [queryHistoryButton removeItemAtIndex:[queryHistoryButton numberOfItems]-1]; // [queryHistoryButton addItemWithTitle:NSLocalizedString(@"Query History…",@"Title of query history popup button")]; @@ -452,14 +478,14 @@ // if(!queriesSeparatedByDelimiter) { // TODO only add to history if no “delimiter” command was used if(!tableReloadAfterEditing && [usedQuery length]) { - [queryHistoryButton insertItemWithTitle:usedQuery atIndex:4]; + [queryHistoryButton insertItemWithTitle:usedQuery atIndex:2]; int maxHistoryItems = [[prefs objectForKey:@"CustomQueryMaxHistoryItems"] intValue]; - while ( [queryHistoryButton numberOfItems] > maxHistoryItems + 4 ) + while ( [queryHistoryButton numberOfItems] > maxHistoryItems + 2 ) [queryHistoryButton removeItemAtIndex:[queryHistoryButton numberOfItems]-1]; - for ( i = 4 ; i < [queryHistoryButton numberOfItems] ; i++ ) + for ( i = 2 ; i < [queryHistoryButton numberOfItems] ; i++ ) [menuItems addObject:[queryHistoryButton itemTitleAtIndex:i]]; [prefs setObject:menuItems forKey:@"queryHistory"]; @@ -1831,11 +1857,9 @@ [saveQueryFavoriteButton setEnabled:[[queryFavoriteNameTextField stringValue] length]]; else if ([notification object] == queryFavoritesSearchField){ [self filterQueryFavorites:nil]; - [[saveQueryFavoriteButton menu] sizeToFit]; } else if ([notification object] == queryHistorySearchField) { [self filterQueryHistory:nil]; - [[queryHistoryButton menu] sizeToFit]; } } @@ -2408,25 +2432,30 @@ */ - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo { - if ([contextInfo isEqualToString:@"addNewQueryFavorite"]) { + if ([contextInfo isEqualToString:@"addAllToNewQueryFavorite"] || [contextInfo isEqualToString:@"addSelectionToNewQueryFavorite"]) { if (returnCode == NSOKButton) { // Add the new query favorite directly the user's preferences here instead of asking the manager to do it // as it may not have been fully initialized yet. NSMutableArray *favorites = [NSMutableArray arrayWithArray:[prefs objectForKey:@"queryFavorites"]]; - + // What should be saved NSString *queryToBeAddded; - // First check for a selection - if([textView selectedRange].length) - queryToBeAddded = [[textView string] substringWithRange:[textView selectedRange]]; - // then for a current query - else if(currentQueryRange.length) - queryToBeAddded = [[textView string] substringWithRange:currentQueryRange]; - // otherwise take the entire string - else + + if([contextInfo isEqualToString:@"addSelectionToNewQueryFavorite"]) { + // First check for a selection + if([textView selectedRange].length) + queryToBeAddded = [[textView string] substringWithRange:[textView selectedRange]]; + // then for a current query + else if(currentQueryRange.length) + queryToBeAddded = [[textView string] substringWithRange:currentQueryRange]; + // otherwise take the entire string + else + queryToBeAddded = [textView string]; + } else { queryToBeAddded = [textView string]; - + } + [favorites addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[queryFavoriteNameTextField stringValue], queryToBeAddded, nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]]; [prefs setObject:favorites forKey:@"queryFavorites"]; @@ -2454,6 +2483,10 @@ else [menuItem setTitle:NSLocalizedString(@"Save All to Favorites",@"Save All to Favorites")]; } + // Control "Save All to Favorites" = tag is set to 1001 + if ( [menuItem tag] == 1001 ) { + if ([[textView string] length] < 1) return NO; + } return YES; } @@ -2513,7 +2546,7 @@ { int i; NSMenu *menu = [queryHistoryButton menu]; - for (i=4; i< [menu numberOfItems]; i++) + for (i=2; i< [menu numberOfItems]; i++) [[menu itemAtIndex:i] setHidden:(![[[menu itemAtIndex:i] title] isMatchedByRegex:[NSString stringWithFormat:@"(?i).*%@.*", [queryHistorySearchField stringValue]]])]; } -- cgit v1.2.3