From aa4389082a2b33720794fbb5843b9d0ebcaa91bd Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 27 Nov 2009 20:47:03 +0000 Subject: [PATCH] update some fields in the inspector and main window for magnetized transfers --- macosx/DragOverlayWindow.m | 7 ++- macosx/InfoWindowController.m | 86 +++++++++++++++++++++------- macosx/MessageWindowController.m | 2 +- macosx/Torrent.m | 7 ++- macosx/en.lproj/Localizable.strings | Bin 65088 -> 65742 bytes 5 files changed, 74 insertions(+), 28 deletions(-) diff --git a/macosx/DragOverlayWindow.m b/macosx/DragOverlayWindow.m index f031e7b44..786c7fbc4 100644 --- a/macosx/DragOverlayWindow.m +++ b/macosx/DragOverlayWindow.m @@ -35,8 +35,8 @@ { fLib = lib; - [self setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.0f alpha: 0.5f]]; - [self setAlphaValue: 0.0f]; + [self setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.5]]; + [self setAlphaValue: 0.0]; [self setOpaque: NO]; [self setHasShadow: NO]; @@ -145,6 +145,7 @@ - (void) setURL: (NSString *) url { + #warning get magnet image/phrase [[self contentView] setOverlay: [NSImage imageNamed: @"Globe.png"] mainLine: NSLocalizedString(@"Web Address", "Drag overlay -> url") subLine: url]; [self fadeIn]; @@ -170,7 +171,7 @@ [fFadeInAnimation stopAnimation]; [fFadeOutAnimation setCurrentProgress: 1.0 - [fFadeInAnimation currentProgress]]; } - if ([self alphaValue] > 0.0f) + if ([self alphaValue] > 0.0) [fFadeOutAnimation startAnimation]; } diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 60c10df37..3a3008ec3 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -1140,7 +1140,7 @@ typedef enum - (void) resetInfo { - NSUInteger numberSelected = [fTorrents count]; + const NSUInteger numberSelected = [fTorrents count]; if (numberSelected != 1) { if (numberSelected > 0) @@ -1151,19 +1151,51 @@ typedef enum "Inspector -> selected torrents"), numberSelected]]; uint64_t size = 0; - NSInteger fileCount = 0; + NSUInteger fileCount = 0, magnetCount = 0; for (Torrent * torrent in fTorrents) { size += [torrent size]; fileCount += [torrent fileCount]; + if ([torrent isMagnet]) + ++magnetCount; } - [fBasicInfoField setStringValue: [NSString stringWithFormat: @"%@, %@", - [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount], - [NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"), - [NSString stringForFileSize: size]]]]; - [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"), - size]]; + NSMutableArray * fileStrings = [NSMutableArray arrayWithCapacity: 2]; + if (fileCount > 0) + { + NSString * fileString; + if (fileCount == 1) + fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents"); + else + fileString = [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount]; + [fileStrings addObject: fileString]; + } + if (magnetCount > 0) + { + NSString * magnetString; + if (magnetCount == 1) + magnetString = NSLocalizedString(@"1 magnetized transfer", "Inspector -> selected torrents"); + else + magnetString = [NSString stringWithFormat: NSLocalizedString(@"%d magnetized transfers", + "Inspector -> selected torrents"), magnetCount]; + [fileStrings addObject: magnetString]; + } + + NSString * fileString = [fileStrings componentsJoinedByString: @" + "]; + + if (magnetCount < numberSelected) + { + [fBasicInfoField setStringValue: [NSString stringWithFormat: @"%@, %@", fileString, + [NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"), + [NSString stringForFileSize: size]]]]; + [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"), + size]]; + } + else + { + [fBasicInfoField setStringValue: fileString]; + [fBasicInfoField setToolTip: nil]; + } } else { @@ -1291,24 +1323,34 @@ typedef enum [fNameField setStringValue: name]; [fNameField setToolTip: name]; - NSString * basicString = [NSString stringForFileSize: [torrent size]]; - if ([torrent isFolder]) + if (![torrent isMagnet]) { - NSString * fileString; - NSInteger fileCount = [torrent fileCount]; - if (fileCount == 1) - fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents"); - else - fileString= [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount]; - basicString = [NSString stringWithFormat: @"%@, %@", fileString, basicString]; + NSString * basicString = [NSString stringForFileSize: [torrent size]]; + if ([torrent isFolder]) + { + NSString * fileString; + NSInteger fileCount = [torrent fileCount]; + if (fileCount == 1) + fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents"); + else + fileString= [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount]; + basicString = [NSString stringWithFormat: @"%@, %@", fileString, basicString]; + } + [fBasicInfoField setStringValue: basicString]; + [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"), + [torrent size]]]; + } + else + { + [fBasicInfoField setStringValue: NSLocalizedString(@"Magnetized transfer", "Inspector -> selected torrents")]; + [fBasicInfoField setToolTip: nil]; } - [fBasicInfoField setStringValue: basicString]; - [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"), - [torrent size]]]; + NSString * piecesString = ![torrent isMagnet] ? [NSString stringWithFormat: @"%d, %@", [torrent pieceCount], + [NSString stringForFileSize: [torrent pieceSize]]] : @""; + [fPiecesField setStringValue: piecesString]; + NSString * hashString = [torrent hashString]; - [fPiecesField setStringValue: [NSString stringWithFormat: @"%d, %@", [torrent pieceCount], - [NSString stringForFileSize: [torrent pieceSize]]]]; [fHashField setStringValue: hashString]; [fHashField setToolTip: hashString]; [fSecureField setStringValue: [torrent privateTorrent] diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index 0f8063876..11f38c54e 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -153,7 +153,7 @@ NSString * name = currentMessage->name != NULL ? [NSString stringWithUTF8String: currentMessage->name] : [[NSProcessInfo processInfo] processName]; - NSString * file = [NSString stringWithFormat: @"%@:%d", [[NSString stringWithUTF8String: currentMessage->file] lastPathComponent], + NSString * file = [[[NSString stringWithUTF8String: currentMessage->file] lastPathComponent] stringByAppendingFormat: @":%d", currentMessage->line]; NSDictionary * message = [NSDictionary dictionaryWithObjectsAndKeys: diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 0d3e916ec..ce54c1156 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -917,8 +917,11 @@ int trashDataFile(const char * filename) { if ([self isMagnet]) { - NSString * progressString = [NSString localizedStringWithFormat: @"%.2f%% of torrent metadata retrieved", - fStat->metadataPercentComplete]; + NSString * progressString = fStat->metadataPercentComplete > 0.0 + ? [NSString localizedStringWithFormat: NSLocalizedString(@"%.2f%% of torrent metadata retrieved", + "Torrent -> progress string"), fStat->metadataPercentComplete] + : NSLocalizedString(@"torrent metadata needed", "Torrent -> progress string"); + return [NSString stringWithFormat: @"%@ - %@", NSLocalizedString(@"Magnetized transfer", "Torrent -> progress string"), progressString]; } diff --git a/macosx/en.lproj/Localizable.strings b/macosx/en.lproj/Localizable.strings index b14a09ff1cd974dfa126ec22abc227597ba4e983..ab4b11f062663636242606ab8d6a120ce197815e 100644 GIT binary patch delta 359 zcmX@`hxuG1%Y-|V3m)4|jNxO>XGoiTkX_h5mm!s*gdve31&Bek0z(m4q=+FCNS6U| z3WE|*)E0=97*rYb7>pRwfV3)*4>d!cfEkk=nT01eh`TISVC0(Iz+yA`1FryM?&O0x zs*^A93&B||ljS=3CVyDWHu=C4w#|CnRh&@8T&#vb%Rn0Rp{$QN#*;7Ds7!vx%rV)4 zhimgaktN|k#V(UM!~`ZcJl5NMAZJ6_kEOwM`Y1N5~YKbkWqUw*8KAtv}l zcJhSH4wD-muuN`v%CVW{X#nHog6DCYMV{Yd1e<90l5O&a=Nyd1llz}ZPIj9Qv{0O5 Na)XJ>X1kY6q5!{gbtC`) delta 159 zcmX@t$a3Hh^MpH-1L8O~pJKG(+I)bggLAThqRQk092}D$@N#W75ML5LdBQWh&0+Z) z%76?%(M*OshBStJh9ZVshD3%EhD;zkZ}Qt`nzC4B7!-i&QyEexe|$QB@&O*c%>mE* u7$;wd)0=GfhHbLkOODBL0$h{%Uhz$S7t1$!Ly*;GiI+@Fn;TyHi2?wFTRQ;& -- 2.40.0