save resizable inspector tab size so that they can be restored when switched back
This commit is contained in:
parent
8c54b7eb46
commit
c9366d7ebe
|
@ -36,9 +36,8 @@
|
||||||
//15 spacing at the bottom of each tab
|
//15 spacing at the bottom of each tab
|
||||||
#define TAB_INFO_HEIGHT 268.0
|
#define TAB_INFO_HEIGHT 268.0
|
||||||
#define TAB_ACTIVITY_HEIGHT 274.0
|
#define TAB_ACTIVITY_HEIGHT 274.0
|
||||||
#define TAB_PEERS_HEIGHT 279.0
|
|
||||||
#define TAB_FILES_HEIGHT 279.0
|
|
||||||
#define TAB_OPTIONS_HEIGHT 158.0
|
#define TAB_OPTIONS_HEIGHT 158.0
|
||||||
|
#define TAB_RESIZABLE_MIN_HEIGHT 279.0
|
||||||
|
|
||||||
#define PIECES_CONTROL_PROGRESS 0
|
#define PIECES_CONTROL_PROGRESS 0
|
||||||
#define PIECES_CONTROL_AVAILABLE 1
|
#define PIECES_CONTROL_AVAILABLE 1
|
||||||
|
@ -71,8 +70,6 @@
|
||||||
fAppIcon = [NSImage imageNamed: @"NSApplicationIcon"];
|
fAppIcon = [NSImage imageNamed: @"NSApplicationIcon"];
|
||||||
fDotGreen = [NSImage imageNamed: @"GreenDot.tiff"];
|
fDotGreen = [NSImage imageNamed: @"GreenDot.tiff"];
|
||||||
fDotRed = [NSImage imageNamed: @"RedDot.tiff"];
|
fDotRed = [NSImage imageNamed: @"RedDot.tiff"];
|
||||||
|
|
||||||
fCanResizeVertical = YES;
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -87,9 +84,12 @@
|
||||||
|
|
||||||
//select tab
|
//select tab
|
||||||
NSString * identifier = [[NSUserDefaults standardUserDefaults] stringForKey: @"InspectorSelected"];
|
NSString * identifier = [[NSUserDefaults standardUserDefaults] stringForKey: @"InspectorSelected"];
|
||||||
if ([fTabView indexOfTabViewItemWithIdentifier: identifier] == NSNotFound)
|
|
||||||
|
if (!identifier || [fTabView indexOfTabViewItemWithIdentifier: identifier] == NSNotFound)
|
||||||
identifier = TAB_INFO_IDENT;
|
identifier = TAB_INFO_IDENT;
|
||||||
|
|
||||||
|
fCanResizeVertical = [identifier isEqualToString: TAB_PEERS_IDENT] || [identifier isEqualToString: TAB_FILES_IDENT];
|
||||||
|
|
||||||
[fTabView selectTabViewItemWithIdentifier: identifier];
|
[fTabView selectTabViewItemWithIdentifier: identifier];
|
||||||
[self setWindowForTab: identifier animate: NO];
|
[self setWindowForTab: identifier animate: NO];
|
||||||
|
|
||||||
|
@ -115,6 +115,10 @@
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
if (fCanResizeVertical)
|
||||||
|
[[NSUserDefaults standardUserDefaults] setFloat: [[[fTabView selectedTabViewItem] view] frame].size.height
|
||||||
|
forKey: @"InspectorHeight"];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
[fTorrents release];
|
[fTorrents release];
|
||||||
|
@ -711,15 +715,13 @@
|
||||||
height = TAB_ACTIVITY_HEIGHT;
|
height = TAB_ACTIVITY_HEIGHT;
|
||||||
[fPiecesView updateView: YES];
|
[fPiecesView updateView: YES];
|
||||||
}
|
}
|
||||||
else if ([identifier isEqualToString: TAB_PEERS_IDENT])
|
else if ([identifier isEqualToString: TAB_PEERS_IDENT] || [identifier isEqualToString: TAB_FILES_IDENT])
|
||||||
{
|
{
|
||||||
height = TAB_PEERS_HEIGHT;
|
|
||||||
canResizeVertical = YES;
|
|
||||||
}
|
|
||||||
else if ([identifier isEqualToString: TAB_FILES_IDENT])
|
|
||||||
{
|
|
||||||
height = TAB_FILES_HEIGHT;
|
|
||||||
canResizeVertical = YES;
|
canResizeVertical = YES;
|
||||||
|
|
||||||
|
//height only needed if resize will take place
|
||||||
|
if (!fCanResizeVertical)
|
||||||
|
height = MAX(TAB_RESIZABLE_MIN_HEIGHT, [[NSUserDefaults standardUserDefaults] floatForKey: @"InspectorHeight"]);
|
||||||
}
|
}
|
||||||
else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
|
else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
|
||||||
height = TAB_OPTIONS_HEIGHT;
|
height = TAB_OPTIONS_HEIGHT;
|
||||||
|
@ -730,10 +732,15 @@
|
||||||
NSRect frame = [window frame];
|
NSRect frame = [window frame];
|
||||||
NSView * view = [[fTabView selectedTabViewItem] view];
|
NSView * view = [[fTabView selectedTabViewItem] view];
|
||||||
|
|
||||||
float difference = (height - [view frame].size.height) * [window userSpaceScaleFactor];;
|
//save previous size
|
||||||
|
if (fCanResizeVertical && !canResizeVertical)
|
||||||
|
[[NSUserDefaults standardUserDefaults] setFloat: [view frame].size.height forKey: @"InspectorHeight"];
|
||||||
|
|
||||||
|
float difference = (height - [view frame].size.height) * [window userSpaceScaleFactor];
|
||||||
frame.origin.y -= difference;
|
frame.origin.y -= difference;
|
||||||
frame.size.height += difference;
|
frame.size.height += difference;
|
||||||
|
|
||||||
|
//actually do resize
|
||||||
if (!fCanResizeVertical || !canResizeVertical)
|
if (!fCanResizeVertical || !canResizeVertical)
|
||||||
{
|
{
|
||||||
if (animate)
|
if (animate)
|
||||||
|
@ -746,7 +753,8 @@
|
||||||
[window setFrame: frame display: YES];
|
[window setFrame: frame display: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
[window setMinSize: NSMakeSize([window minSize].width, frame.size.height)];
|
|
||||||
|
[window setMinSize: NSMakeSize([window minSize].width, canResizeVertical ? TAB_RESIZABLE_MIN_HEIGHT : frame.size.height)];
|
||||||
[window setMaxSize: NSMakeSize([window maxSize].width, canResizeVertical ? FLT_MAX : frame.size.height)];
|
[window setMaxSize: NSMakeSize([window maxSize].width, canResizeVertical ? FLT_MAX : frame.size.height)];
|
||||||
|
|
||||||
fCanResizeVertical = canResizeVertical;
|
fCanResizeVertical = canResizeVertical;
|
||||||
|
|
|
@ -425,7 +425,7 @@ static int static_lastid = 0;
|
||||||
[statusString setString: NSLocalizedString(@"Error", "Torrent -> status string")];
|
[statusString setString: NSLocalizedString(@"Error", "Torrent -> status string")];
|
||||||
else
|
else
|
||||||
[statusString setString: [NSLocalizedString(@"Error: ", "Torrent -> status string")
|
[statusString setString: [NSLocalizedString(@"Error: ", "Torrent -> status string")
|
||||||
stringByAppendingString: [self errorMessage]]];
|
stringByAppendingString: errorString]];
|
||||||
}
|
}
|
||||||
else if (fStalled)
|
else if (fStalled)
|
||||||
[statusString insertString: NSLocalizedString(@"Stalled, ", "Torrent -> status string") atIndex: 0];
|
[statusString insertString: NSLocalizedString(@"Stalled, ", "Torrent -> status string") atIndex: 0];
|
||||||
|
|
Loading…
Reference in New Issue