Changeset 852


Ignore:
Timestamp:
Sep 8, 2006, 1:14:31 AM (15 years ago)
Author:
livings124
Message:

Menu item to switch between filters.
Enable some menu items a little differently.

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r847 r852  
    7979                                    * fSeedFilterButton, * fDownloadFilterButton;
    8080    IBOutlet NSSearchField          * fSearchFilterField;
     81    IBOutlet NSMenuItem             * fNextFilterItem, * fPrevFilterItem;
    8182                               
    8283    IBOutlet NSMenuItem             * fNextInfoTabItem, * fPrevInfoTabItem;
     
    148149- (void) applyFilter: (id) sender;
    149150- (void) setFilter: (id) sender;
     151- (void) switchFilter: (id) sender;
    150152
    151153- (void) toggleSpeedLimit: (id) sender;
  • trunk/macosx/Controller.m

    r850 r852  
    149149    [fWindow setContentMinSize: contentMinSize];
    150150   
    151     //set info keyboard shortcuts
    152     unichar ch = NSRightArrowFunctionKey;
    153     [fNextInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & ch length: 1]];
    154     ch = NSLeftArrowFunctionKey;
    155     [fPrevInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & ch length: 1]];
     151    //set info and filter keyboard shortcuts
     152    unichar rightChar = NSRightArrowFunctionKey, leftChar = NSLeftArrowFunctionKey;
     153    [fNextInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & rightChar length: 1]];
     154    [fPrevInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & leftChar length: 1]];
     155   
     156    [fNextFilterItem setKeyEquivalent: [NSString stringWithCharacters: & rightChar length: 1]];
     157    [fNextFilterItem setKeyEquivalentModifierMask: NSCommandKeyMask + NSAlternateKeyMask];
     158    [fPrevFilterItem setKeyEquivalent: [NSString stringWithCharacters: & leftChar length: 1]];
     159    [fPrevFilterItem setKeyEquivalentModifierMask: NSCommandKeyMask + NSAlternateKeyMask];
    156160   
    157161    //set up filter bar
     
    12461250}
    12471251
     1252- (void) switchFilter: (id) sender
     1253{
     1254    NSButton * button;
     1255    if ([fFilterType isEqualToString: @"None"])
     1256        button = sender == fNextFilterItem ? fDownloadFilterButton : fPauseFilterButton;
     1257    else if ([fFilterType isEqualToString: @"Download"])
     1258        button = sender == fNextFilterItem ? fSeedFilterButton : fNoFilterButton;
     1259    else if ([fFilterType isEqualToString: @"Seed"])
     1260        button = sender == fNextFilterItem ? fPauseFilterButton : fDownloadFilterButton;
     1261    else if ([fFilterType isEqualToString: @"Pause"])
     1262        button = sender == fNextFilterItem ? fNoFilterButton : fSeedFilterButton;
     1263    else
     1264        button = fNoFilterButton;
     1265   
     1266    [self setFilter: button];
     1267}
     1268
    12481269- (void) toggleSpeedLimit: (id) sender
    12491270{
     
    20052026
    20062027    //only enable some items if it is in a context menu or the window is useable
    2007     BOOL canUseMenu = [fWindow isKeyWindow] || [[[menuItem menu] title] isEqualToString: @"Context"];
     2028    BOOL canUseTable = [fWindow isKeyWindow] || [[[menuItem menu] title] isEqualToString: @"Context"];
    20082029
    20092030    //enable open items
    20102031    if (action == @selector(openShowSheet:))
    20112032        return [fWindow attachedSheet] == nil;
     2033   
     2034    //enable sort and advanced bar items
     2035    if (action == @selector(setSort:) || action == @selector(toggleAdvancedBar:) || action == @selector(toggleSmallView:))
     2036        return [fWindow isVisible];
    20122037
    20132038    //enable show info
     
    20322057                [menuItem setTitle: title];
    20332058
    2034         return canUseMenu;
     2059        return [fWindow isVisible];
    20352060    }
    20362061   
     
    20422067                [menuItem setTitle: title];
    20432068
    2044         return canUseMenu;
    2045     }
     2069        return [fWindow isVisible];
     2070    }
     2071   
     2072    //enable prev/next filter button
     2073    if (action == @selector(switchFilter:))
     2074        return [fWindow isVisible];
    20462075
    20472076    //enable reveal in finder
    20482077    if (action == @selector(revealFile:))
    2049         return canUseMenu && [fTableView numberOfSelectedRows] > 0;
     2078        return canUseTable && [fTableView numberOfSelectedRows] > 0;
    20502079
    20512080    //enable remove items
     
    20902119        }
    20912120       
    2092         return canUseMenu && canDelete && [fTableView numberOfSelectedRows] > 0;
     2121        return canUseTable && canDelete && [fTableView numberOfSelectedRows] > 0;
    20932122    }
    20942123
     
    21322161    if (action == @selector(stopSelectedTorrents:))
    21332162    {
    2134         if (!canUseMenu)
     2163        if (!canUseTable)
    21352164            return NO;
    21362165   
     
    21512180    if (action == @selector(resumeSelectedTorrents:))
    21522181    {
    2153         if (!canUseMenu)
     2182        if (!canUseTable)
    21542183            return NO;
    21552184   
     
    21672196    }
    21682197   
    2169     //enable sort and advanced bar items
    2170     if (action == @selector(setSort:) || action == @selector(toggleAdvancedBar:)
    2171             || action == @selector(toggleSmallView:))
    2172         return canUseMenu;
    2173    
    21742198    //enable copy torrent file item
    21752199    if (action == @selector(copyTorrentFile:))
    2176         return canUseMenu && [fTableView numberOfSelectedRows] > 0;
     2200        return canUseTable && [fTableView numberOfSelectedRows] > 0;
    21772201
    21782202    return YES;
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r807 r852  
    3131                stopAllTorrents = id;
    3232                stopSelectedTorrents = id;
     33                switchFilter = id;
    3334                toggleAdvancedBar = id;
    3435                toggleFilterBar = id;
     
    5152                fNameSortActionItem = NSMenuItem;
    5253                fNameSortItem = NSMenuItem;
     54                fNextFilterItem = NSMenuItem;
    5355                fNextInfoTabItem = NSMenuItem;
    5456                fNoFilterButton = BarButton;
     
    5759                fOrderSortItem = NSMenuItem;
    5860                fPauseFilterButton = BarButton;
     61                fPrevFilterItem = NSMenuItem;
    5962                fPrevInfoTabItem = NSMenuItem;
    6063                fProgressSortActionItem = NSMenuItem;
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r834 r852  
    3232        <key>IBOpenObjects</key>
    3333        <array>
     34                <integer>21</integer>
    3435                <integer>29</integer>
    35                 <integer>21</integer>
    3636        </array>
    3737        <key>IBSystem Version</key>
Note: See TracChangeset for help on using the changeset viewer.