Changeset 5135


Ignore:
Timestamp:
Feb 27, 2008, 1:57:13 AM (14 years ago)
Author:
livings124
Message:

save each individual inspector tab's size separately

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r5134 r5135  
    169169{
    170170    //save resizeable view height
    171     if (fCurrentTabTag == TAB_TRACKER_TAG || fCurrentTabTag == TAB_PEERS_TAG || fCurrentTabTag == TAB_FILES_TAG)
    172         [[NSUserDefaults standardUserDefaults] setFloat: [[self tabViewForTag: fCurrentTabTag] frame].size.height
    173             forKey: @"InspectorContentHeight"];
     171    NSString * resizeSaveKey = nil;
     172    switch (fCurrentTabTag)
     173    {
     174        case TAB_TRACKER_TAG:
     175            resizeSaveKey = @"InspectorContentHeightTracker";
     176            break;
     177        case TAB_PEERS_TAG:
     178            resizeSaveKey = @"InspectorContentHeightPeers";
     179            break;
     180        case TAB_FILES_TAG:
     181            resizeSaveKey = @"InspectorContentHeightFiles";
     182            break;
     183    }
     184    if (resizeSaveKey)
     185        [[NSUserDefaults standardUserDefaults] setFloat: [[self tabViewForTag: fCurrentTabTag] frame].size.height forKey: resizeSaveKey];
    174186   
    175187    [[NSNotificationCenter defaultCenter] removeObserver: self];
     
    574586    [self updateInfoStats];
    575587   
    576     BOOL oldCanResizeVertical = fCurrentTabTag == TAB_TRACKER_TAG || fCurrentTabTag == TAB_PEERS_TAG || fCurrentTabTag == TAB_FILES_TAG,
    577         canResizeVertical;
     588    //save old heights
    578589    int oldTabTag = fCurrentTabTag;
     590    NSView * oldView = [self tabViewForTag: oldTabTag];
     591   
     592    BOOL oldCanResizeVertical;
     593    NSString * oldResizeSaveKey;
     594    switch (fCurrentTabTag)
     595    {
     596        case TAB_TRACKER_TAG:
     597            oldResizeSaveKey = @"InspectorContentHeightTracker";
     598            oldCanResizeVertical = YES;
     599            break;
     600        case TAB_PEERS_TAG:
     601            oldResizeSaveKey = @"InspectorContentHeightPeers";
     602            oldCanResizeVertical = YES;
     603            break;
     604        case TAB_FILES_TAG:
     605            oldResizeSaveKey = @"InspectorContentHeightFiles";
     606            oldCanResizeVertical = YES;
     607            break;
     608        default:
     609            oldCanResizeVertical = NO;
     610    }
     611   
     612    float oldHeight = 0;
     613   
     614    if (oldTabTag != INVALID)
     615        oldHeight = [oldView frame].size.height;
     616    if (oldCanResizeVertical)
     617        [[NSUserDefaults standardUserDefaults] setFloat: [oldView frame].size.height forKey: oldResizeSaveKey];
     618   
     619    //set current tag
     620    BOOL canResizeVertical;
     621    NSString * resizeSaveKey;
    579622    fCurrentTabTag = [fTabMatrix selectedTag];
    580623   
     
    601644            identifier = TAB_TRACKER_IDENT;
    602645            title = NSLocalizedString(@"Tracker", "Inspector -> title");
     646           
     647            resizeSaveKey = @"InspectorContentHeightTracker";
    603648            canResizeVertical = YES;
    604649            break;
     
    607652            identifier = TAB_PEERS_IDENT;
    608653            title = NSLocalizedString(@"Peers", "Inspector -> title");
     654           
     655            resizeSaveKey = @"InspectorContentHeightPeers";
    609656            canResizeVertical = YES;
    610657            break;
     
    613660            identifier = TAB_FILES_IDENT;
    614661            title = NSLocalizedString(@"Files", "Inspector -> title");
     662           
     663            resizeSaveKey = @"InspectorContentHeightFiles";
    615664            canResizeVertical = YES;
    616665            break;
     
    629678    NSWindow * window = [self window];
    630679   
    631     float oldHeight = 0;
     680    /*if (fCurrentTabTag == oldTabTag)
     681        return;*/
     682   
     683    #warning move?
    632684    if (oldTabTag != INVALID)
    633685    {
    634         if (fCurrentTabTag == oldTabTag)
    635             return;
    636        
    637686        //deselect old tab item
    638687        [(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO];
    639688       
    640689        //get old view
    641         NSView * oldView = [self tabViewForTag: oldTabTag];
    642690        [oldView setHidden: YES];
    643691        [oldView removeFromSuperview];
    644        
    645         oldHeight = [oldView frame].size.height;
    646        
    647         //save old size
    648         if (oldCanResizeVertical)
    649             [[NSUserDefaults standardUserDefaults] setFloat: [oldView frame].size.height forKey: @"InspectorContentHeight"];
    650692    }
    651693   
     
    659701    if (canResizeVertical)
    660702    {
    661         float height = [[NSUserDefaults standardUserDefaults] floatForKey: @"InspectorContentHeight"];
     703        float height = [[NSUserDefaults standardUserDefaults] floatForKey: resizeSaveKey];
    662704        if (height != 0)
    663705            viewRect.size.height = MAX(height, TAB_MIN_HEIGHT);
Note: See TracChangeset for help on using the changeset viewer.