save each individual inspector tab's size separately

This commit is contained in:
Mitchell Livingston 2008-02-27 01:57:13 +00:00
parent 265c29b907
commit b2cb5f6fe3
1 changed files with 59 additions and 17 deletions

View File

@ -168,9 +168,21 @@ typedef enum
- (void) dealloc - (void) dealloc
{ {
//save resizeable view height //save resizeable view height
if (fCurrentTabTag == TAB_TRACKER_TAG || fCurrentTabTag == TAB_PEERS_TAG || fCurrentTabTag == TAB_FILES_TAG) NSString * resizeSaveKey = nil;
[[NSUserDefaults standardUserDefaults] setFloat: [[self tabViewForTag: fCurrentTabTag] frame].size.height switch (fCurrentTabTag)
forKey: @"InspectorContentHeight"]; {
case TAB_TRACKER_TAG:
resizeSaveKey = @"InspectorContentHeightTracker";
break;
case TAB_PEERS_TAG:
resizeSaveKey = @"InspectorContentHeightPeers";
break;
case TAB_FILES_TAG:
resizeSaveKey = @"InspectorContentHeightFiles";
break;
}
if (resizeSaveKey)
[[NSUserDefaults standardUserDefaults] setFloat: [[self tabViewForTag: fCurrentTabTag] frame].size.height forKey: resizeSaveKey];
[[NSNotificationCenter defaultCenter] removeObserver: self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
@ -573,9 +585,40 @@ typedef enum
{ {
[self updateInfoStats]; [self updateInfoStats];
BOOL oldCanResizeVertical = fCurrentTabTag == TAB_TRACKER_TAG || fCurrentTabTag == TAB_PEERS_TAG || fCurrentTabTag == TAB_FILES_TAG, //save old heights
canResizeVertical;
int oldTabTag = fCurrentTabTag; int oldTabTag = fCurrentTabTag;
NSView * oldView = [self tabViewForTag: oldTabTag];
BOOL oldCanResizeVertical;
NSString * oldResizeSaveKey;
switch (fCurrentTabTag)
{
case TAB_TRACKER_TAG:
oldResizeSaveKey = @"InspectorContentHeightTracker";
oldCanResizeVertical = YES;
break;
case TAB_PEERS_TAG:
oldResizeSaveKey = @"InspectorContentHeightPeers";
oldCanResizeVertical = YES;
break;
case TAB_FILES_TAG:
oldResizeSaveKey = @"InspectorContentHeightFiles";
oldCanResizeVertical = YES;
break;
default:
oldCanResizeVertical = NO;
}
float oldHeight = 0;
if (oldTabTag != INVALID)
oldHeight = [oldView frame].size.height;
if (oldCanResizeVertical)
[[NSUserDefaults standardUserDefaults] setFloat: [oldView frame].size.height forKey: oldResizeSaveKey];
//set current tag
BOOL canResizeVertical;
NSString * resizeSaveKey;
fCurrentTabTag = [fTabMatrix selectedTag]; fCurrentTabTag = [fTabMatrix selectedTag];
NSView * view; NSView * view;
@ -600,18 +643,24 @@ typedef enum
view = fTrackerView; view = fTrackerView;
identifier = TAB_TRACKER_IDENT; identifier = TAB_TRACKER_IDENT;
title = NSLocalizedString(@"Tracker", "Inspector -> title"); title = NSLocalizedString(@"Tracker", "Inspector -> title");
resizeSaveKey = @"InspectorContentHeightTracker";
canResizeVertical = YES; canResizeVertical = YES;
break; break;
case TAB_PEERS_TAG: case TAB_PEERS_TAG:
view = fPeersView; view = fPeersView;
identifier = TAB_PEERS_IDENT; identifier = TAB_PEERS_IDENT;
title = NSLocalizedString(@"Peers", "Inspector -> title"); title = NSLocalizedString(@"Peers", "Inspector -> title");
resizeSaveKey = @"InspectorContentHeightPeers";
canResizeVertical = YES; canResizeVertical = YES;
break; break;
case TAB_FILES_TAG: case TAB_FILES_TAG:
view = fFilesView; view = fFilesView;
identifier = TAB_FILES_IDENT; identifier = TAB_FILES_IDENT;
title = NSLocalizedString(@"Files", "Inspector -> title"); title = NSLocalizedString(@"Files", "Inspector -> title");
resizeSaveKey = @"InspectorContentHeightFiles";
canResizeVertical = YES; canResizeVertical = YES;
break; break;
case TAB_OPTIONS_TAG: case TAB_OPTIONS_TAG:
@ -628,25 +677,18 @@ typedef enum
NSWindow * window = [self window]; NSWindow * window = [self window];
float oldHeight = 0; /*if (fCurrentTabTag == oldTabTag)
return;*/
#warning move?
if (oldTabTag != INVALID) if (oldTabTag != INVALID)
{ {
if (fCurrentTabTag == oldTabTag)
return;
//deselect old tab item //deselect old tab item
[(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO]; [(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO];
//get old view //get old view
NSView * oldView = [self tabViewForTag: oldTabTag];
[oldView setHidden: YES]; [oldView setHidden: YES];
[oldView removeFromSuperview]; [oldView removeFromSuperview];
oldHeight = [oldView frame].size.height;
//save old size
if (oldCanResizeVertical)
[[NSUserDefaults standardUserDefaults] setFloat: [oldView frame].size.height forKey: @"InspectorContentHeight"];
} }
[window setTitle: [NSString stringWithFormat: @"%@ - %@", title, NSLocalizedString(@"Torrent Inspector", "Inspector -> title")]]; [window setTitle: [NSString stringWithFormat: @"%@ - %@", title, NSLocalizedString(@"Torrent Inspector", "Inspector -> title")]];
@ -658,7 +700,7 @@ typedef enum
if (canResizeVertical) if (canResizeVertical)
{ {
float height = [[NSUserDefaults standardUserDefaults] floatForKey: @"InspectorContentHeight"]; float height = [[NSUserDefaults standardUserDefaults] floatForKey: resizeSaveKey];
if (height != 0) if (height != 0)
viewRect.size.height = MAX(height, TAB_MIN_HEIGHT); viewRect.size.height = MAX(height, TAB_MIN_HEIGHT);
} }