From c9366d7ebe5b5ea24fd09009e6da452d24f09be7 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 21 Aug 2007 04:15:22 +0000 Subject: [PATCH] save resizable inspector tab size so that they can be restored when switched back --- macosx/InfoWindowController.m | 36 +++++++++++++++++++++-------------- macosx/Torrent.m | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index dd1b3c39e..f87c08611 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -36,9 +36,8 @@ //15 spacing at the bottom of each tab #define TAB_INFO_HEIGHT 268.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_RESIZABLE_MIN_HEIGHT 279.0 #define PIECES_CONTROL_PROGRESS 0 #define PIECES_CONTROL_AVAILABLE 1 @@ -71,8 +70,6 @@ fAppIcon = [NSImage imageNamed: @"NSApplicationIcon"]; fDotGreen = [NSImage imageNamed: @"GreenDot.tiff"]; fDotRed = [NSImage imageNamed: @"RedDot.tiff"]; - - fCanResizeVertical = YES; } return self; } @@ -87,9 +84,12 @@ //select tab NSString * identifier = [[NSUserDefaults standardUserDefaults] stringForKey: @"InspectorSelected"]; - if ([fTabView indexOfTabViewItemWithIdentifier: identifier] == NSNotFound) + + if (!identifier || [fTabView indexOfTabViewItemWithIdentifier: identifier] == NSNotFound) identifier = TAB_INFO_IDENT; + fCanResizeVertical = [identifier isEqualToString: TAB_PEERS_IDENT] || [identifier isEqualToString: TAB_FILES_IDENT]; + [fTabView selectTabViewItemWithIdentifier: identifier]; [self setWindowForTab: identifier animate: NO]; @@ -115,6 +115,10 @@ - (void) dealloc { + if (fCanResizeVertical) + [[NSUserDefaults standardUserDefaults] setFloat: [[[fTabView selectedTabViewItem] view] frame].size.height + forKey: @"InspectorHeight"]; + [[NSNotificationCenter defaultCenter] removeObserver: self]; [fTorrents release]; @@ -711,15 +715,13 @@ height = TAB_ACTIVITY_HEIGHT; [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; + + //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]) height = TAB_OPTIONS_HEIGHT; @@ -730,10 +732,15 @@ NSRect frame = [window frame]; 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.size.height += difference; + //actually do resize if (!fCanResizeVertical || !canResizeVertical) { if (animate) @@ -746,7 +753,8 @@ [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)]; fCanResizeVertical = canResizeVertical; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index b7999b19d..7f937cfbc 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -425,7 +425,7 @@ static int static_lastid = 0; [statusString setString: NSLocalizedString(@"Error", "Torrent -> status string")]; else [statusString setString: [NSLocalizedString(@"Error: ", "Torrent -> status string") - stringByAppendingString: [self errorMessage]]]; + stringByAppendingString: errorString]]; } else if (fStalled) [statusString insertString: NSLocalizedString(@"Stalled, ", "Torrent -> status string") atIndex: 0];