mirror of
https://github.com/transmission/transmission
synced 2025-02-21 13:46:52 +00:00
update some fields in the inspector and main window for magnetized transfers
This commit is contained in:
parent
2021706c6e
commit
aa4389082a
5 changed files with 74 additions and 28 deletions
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue