mirror of
https://github.com/transmission/transmission
synced 2025-03-10 06:02:57 +00:00
cleanup for last commit
This commit is contained in:
parent
b2cb5f6fe3
commit
c24432c129
1 changed files with 38 additions and 58 deletions
|
@ -583,43 +583,46 @@ typedef enum
|
|||
|
||||
- (void) setTab: (id) sender
|
||||
{
|
||||
int oldTabTag = fCurrentTabTag;
|
||||
fCurrentTabTag = [fTabMatrix selectedTag];
|
||||
if (fCurrentTabTag == oldTabTag)
|
||||
return;
|
||||
|
||||
[self updateInfoStats];
|
||||
|
||||
//save old heights
|
||||
int oldTabTag = fCurrentTabTag;
|
||||
NSView * oldView = [self tabViewForTag: oldTabTag];
|
||||
//take care of old view
|
||||
float oldHeight = 0;
|
||||
NSString * oldResizeSaveKey = nil;
|
||||
if (oldTabTag != INVALID)
|
||||
{
|
||||
//deselect old tab item
|
||||
[(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO];
|
||||
|
||||
BOOL oldCanResizeVertical;
|
||||
NSString * oldResizeSaveKey;
|
||||
switch (fCurrentTabTag)
|
||||
switch (oldTabTag)
|
||||
{
|
||||
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)
|
||||
NSView * oldView = [self tabViewForTag: oldTabTag];
|
||||
oldHeight = [oldView frame].size.height;
|
||||
if (oldCanResizeVertical)
|
||||
[[NSUserDefaults standardUserDefaults] setFloat: [oldView frame].size.height forKey: oldResizeSaveKey];
|
||||
if (oldResizeSaveKey)
|
||||
[[NSUserDefaults standardUserDefaults] setFloat: oldHeight forKey: oldResizeSaveKey];
|
||||
|
||||
//get old view
|
||||
[oldView setHidden: YES];
|
||||
[oldView removeFromSuperview];
|
||||
}
|
||||
|
||||
//set current tag
|
||||
BOOL canResizeVertical;
|
||||
NSString * resizeSaveKey;
|
||||
fCurrentTabTag = [fTabMatrix selectedTag];
|
||||
NSString * resizeSaveKey = nil;
|
||||
|
||||
NSView * view;
|
||||
NSString * identifier, * title;
|
||||
|
@ -629,13 +632,11 @@ typedef enum
|
|||
view = fInfoView;
|
||||
identifier = TAB_INFO_IDENT;
|
||||
title = NSLocalizedString(@"General Info", "Inspector -> title");
|
||||
canResizeVertical = NO;
|
||||
break;
|
||||
case TAB_ACTIVITY_TAG:
|
||||
view = fActivityView;
|
||||
identifier = TAB_ACTIVITY_IDENT;
|
||||
title = NSLocalizedString(@"Activity", "Inspector -> title");
|
||||
canResizeVertical = NO;
|
||||
|
||||
[fPiecesView updateView: YES];
|
||||
break;
|
||||
|
@ -643,31 +644,24 @@ typedef enum
|
|||
view = fTrackerView;
|
||||
identifier = TAB_TRACKER_IDENT;
|
||||
title = NSLocalizedString(@"Tracker", "Inspector -> title");
|
||||
|
||||
resizeSaveKey = @"InspectorContentHeightTracker";
|
||||
canResizeVertical = YES;
|
||||
break;
|
||||
case TAB_PEERS_TAG:
|
||||
view = fPeersView;
|
||||
identifier = TAB_PEERS_IDENT;
|
||||
title = NSLocalizedString(@"Peers", "Inspector -> title");
|
||||
|
||||
resizeSaveKey = @"InspectorContentHeightPeers";
|
||||
canResizeVertical = YES;
|
||||
break;
|
||||
case TAB_FILES_TAG:
|
||||
view = fFilesView;
|
||||
identifier = TAB_FILES_IDENT;
|
||||
title = NSLocalizedString(@"Files", "Inspector -> title");
|
||||
|
||||
resizeSaveKey = @"InspectorContentHeightFiles";
|
||||
canResizeVertical = YES;
|
||||
break;
|
||||
case TAB_OPTIONS_TAG:
|
||||
view = fOptionsView;
|
||||
identifier = TAB_OPTIONS_IDENT;
|
||||
title = NSLocalizedString(@"Options", "Inspector -> title");
|
||||
canResizeVertical = NO;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
@ -677,20 +671,6 @@ typedef enum
|
|||
|
||||
NSWindow * window = [self window];
|
||||
|
||||
/*if (fCurrentTabTag == oldTabTag)
|
||||
return;*/
|
||||
|
||||
#warning move?
|
||||
if (oldTabTag != INVALID)
|
||||
{
|
||||
//deselect old tab item
|
||||
[(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO];
|
||||
|
||||
//get old view
|
||||
[oldView setHidden: YES];
|
||||
[oldView removeFromSuperview];
|
||||
}
|
||||
|
||||
[window setTitle: [NSString stringWithFormat: @"%@ - %@", title, NSLocalizedString(@"Torrent Inspector", "Inspector -> title")]];
|
||||
|
||||
//selected tab item
|
||||
|
@ -698,7 +678,7 @@ typedef enum
|
|||
|
||||
NSRect windowRect = [window frame], viewRect = [view frame];
|
||||
|
||||
if (canResizeVertical)
|
||||
if (resizeSaveKey)
|
||||
{
|
||||
float height = [[NSUserDefaults standardUserDefaults] floatForKey: resizeSaveKey];
|
||||
if (height != 0)
|
||||
|
@ -709,9 +689,9 @@ typedef enum
|
|||
windowRect.origin.y -= difference;
|
||||
windowRect.size.height += difference;
|
||||
|
||||
if (canResizeVertical)
|
||||
if (resizeSaveKey)
|
||||
{
|
||||
if (!oldCanResizeVertical)
|
||||
if (!oldResizeSaveKey)
|
||||
{
|
||||
[window setMinSize: NSMakeSize([window minSize].width, windowRect.size.height - viewRect.size.height + TAB_MIN_HEIGHT)];
|
||||
[window setMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)];
|
||||
|
|
Loading…
Add table
Reference in a new issue