Fixed the info panel and refined its look
This commit is contained in:
parent
256bda38ce
commit
5165d09994
|
@ -54,15 +54,17 @@
|
|||
IBOutlet NSTextField * fTotalULField;
|
||||
|
||||
IBOutlet NSPanel * fInfoPanel;
|
||||
IBOutlet NSTextField * fInfoTitle;
|
||||
IBOutlet NSImageView * fInfoImageView;
|
||||
IBOutlet NSTextField * fInfoName;
|
||||
IBOutlet NSTextField * fInfoSize;
|
||||
IBOutlet NSTextField * fInfoTracker;
|
||||
IBOutlet NSTextField * fInfoAnnounce;
|
||||
IBOutlet NSTextField * fInfoSize;
|
||||
IBOutlet NSTextField * fInfoPieces;
|
||||
IBOutlet NSTextField * fInfoPieceSize;
|
||||
IBOutlet NSTextField * fInfoPieces;
|
||||
IBOutlet NSTextField * fInfoHash1;
|
||||
IBOutlet NSTextField * fInfoHash2;
|
||||
IBOutlet NSTextField * fInfoSeeders;
|
||||
IBOutlet NSTextField * fInfoLeechers;
|
||||
IBOutlet NSTextField * fInfoFolder;
|
||||
IBOutlet NSTextField * fInfoDownloaded;
|
||||
IBOutlet NSTextField * fInfoUploaded;
|
||||
|
||||
|
|
|
@ -555,6 +555,52 @@ static void sleepCallBack( void * controller, io_service_t y,
|
|||
}
|
||||
}
|
||||
|
||||
- (void) updateInfoPanel
|
||||
{
|
||||
int row = [fTableView selectedRow];
|
||||
|
||||
if( row < 0 )
|
||||
{
|
||||
[fInfoImageView setImage: [NSApp applicationIconImage]];
|
||||
[fInfoName setStringValue: @"No torrent selected"];
|
||||
[fInfoSize setStringValue: @""];
|
||||
[fInfoTracker setStringValue: @""];
|
||||
[fInfoAnnounce setStringValue: @""];
|
||||
[fInfoPieceSize setStringValue: @""];
|
||||
[fInfoPieces setStringValue: @""];
|
||||
[fInfoHash1 setStringValue: @""];
|
||||
[fInfoHash2 setStringValue: @""];
|
||||
[fInfoSeeders setStringValue: @""];
|
||||
[fInfoLeechers setStringValue: @""];
|
||||
[fInfoDownloaded setStringValue: @""];
|
||||
[fInfoUploaded setStringValue: @""];
|
||||
return;
|
||||
}
|
||||
|
||||
Torrent * torrent = [fTorrents objectAtIndex: row];
|
||||
[fInfoImageView setImage: [torrent iconNonFlipped]];
|
||||
[fInfoName setStringValue: [torrent name]];
|
||||
[fInfoSize setStringValue: [NSString
|
||||
stringForFileSize: [torrent size]]];
|
||||
[fInfoTracker setStringValue: [torrent tracker]];
|
||||
[fInfoAnnounce setStringValue: [torrent announce]];
|
||||
[fInfoPieceSize setStringValue: [NSString
|
||||
stringForFileSize: [torrent pieceSize]]];
|
||||
[fInfoPieces setStringValue: [NSString
|
||||
stringWithInt: [torrent pieceCount]]];
|
||||
[fInfoHash1 setStringValue: [torrent hash1]];
|
||||
[fInfoHash2 setStringValue: [torrent hash2]];
|
||||
int seeders = [torrent seeders], leechers = [torrent leechers];
|
||||
[fInfoSeeders setStringValue: seeders < 0 ?
|
||||
@"?" : [NSString stringWithInt: seeders]];
|
||||
[fInfoLeechers setStringValue: leechers < 0 ?
|
||||
@"?" : [NSString stringWithInt: leechers]];
|
||||
[fInfoDownloaded setStringValue: [NSString
|
||||
stringForFileSize: [torrent downloaded]]];
|
||||
[fInfoUploaded setStringValue: [NSString
|
||||
stringForFileSize: [torrent uploaded]]];
|
||||
}
|
||||
|
||||
- (void) updateUI: (NSTimer *) t
|
||||
{
|
||||
float dl, ul;
|
||||
|
@ -586,17 +632,7 @@ static void sleepCallBack( void * controller, io_service_t y,
|
|||
[fTotalDLField setStringValue: downloadRate];
|
||||
[fTotalULField setStringValue: uploadRate];
|
||||
|
||||
#if 0
|
||||
//Update DL/UL totals in the Info panel
|
||||
row = [fTableView selectedRow];
|
||||
if( row >= 0 )
|
||||
{
|
||||
[fInfoDownloaded setStringValue:
|
||||
[NSString stringForFileSize: fStat[row].downloaded]];
|
||||
[fInfoUploaded setStringValue:
|
||||
[NSString stringForFileSize: fStat[row].uploaded]];
|
||||
}
|
||||
#endif
|
||||
[self updateInfoPanel];
|
||||
|
||||
//badge dock
|
||||
[fBadger updateBadgeWithCompleted: fCompleted
|
||||
|
@ -675,54 +711,7 @@ static void sleepCallBack( void * controller, io_service_t y,
|
|||
|
||||
- (void) tableViewSelectionDidChange: (NSNotification *) n
|
||||
{
|
||||
int row = [fTableView selectedRow];
|
||||
|
||||
if( row < 0 )
|
||||
{
|
||||
[fInfoTitle setStringValue: @"No torrent selected"];
|
||||
[fInfoTracker setStringValue: @""];
|
||||
[fInfoAnnounce setStringValue: @""];
|
||||
[fInfoSize setStringValue: @""];
|
||||
[fInfoPieces setStringValue: @""];
|
||||
[fInfoPieceSize setStringValue: @""];
|
||||
[fInfoFolder setStringValue: @""];
|
||||
[fInfoDownloaded setStringValue: @""];
|
||||
[fInfoUploaded setStringValue: @""];
|
||||
[fInfoSeeders setStringValue: @""];
|
||||
[fInfoLeechers setStringValue: @""];
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Update info window */
|
||||
[fInfoTitle setStringValue: [NSString stringWithUTF8String:
|
||||
fStat[row].info.name]];
|
||||
[fInfoTracker setStringValue: [NSString stringWithFormat:
|
||||
@"%s:%d", fStat[row].info.trackerAddress, fStat[row].info.trackerPort]];
|
||||
[fInfoAnnounce setStringValue: [NSString stringWithCString:
|
||||
fStat[row].info.trackerAnnounce]];
|
||||
[fInfoSize setStringValue:
|
||||
[NSString stringForFileSize: fStat[row].info.totalSize]];
|
||||
[fInfoPieces setStringValue: [NSString stringWithInt:
|
||||
fStat[row].info.pieceCount]];
|
||||
[fInfoPieceSize setStringValue:
|
||||
[NSString stringForFileSize: fStat[row].info.pieceSize]];
|
||||
[fInfoFolder setStringValue: [[NSString stringWithUTF8String:
|
||||
tr_torrentGetFolder( fHandle, row )] lastPathComponent]];
|
||||
|
||||
if ( fStat[row].seeders == -1 ) {
|
||||
[fInfoSeeders setStringValue: [NSString stringWithUTF8String: "?"]];
|
||||
} else {
|
||||
[fInfoSeeders setStringValue: [NSString stringWithInt:
|
||||
fStat[row].seeders]];
|
||||
}
|
||||
if ( fStat[row].leechers == -1 ) {
|
||||
[fInfoLeechers setStringValue: [NSString stringWithUTF8String: "?"]];
|
||||
} else {
|
||||
[fInfoLeechers setStringValue: [NSString stringWithInt:
|
||||
fStat[row].leechers]];
|
||||
}
|
||||
#endif
|
||||
[self updateInfoPanel];
|
||||
}
|
||||
|
||||
- (NSToolbarItem *) toolbar: (NSToolbar *) t itemForItemIdentifier:
|
||||
|
|
|
@ -29,14 +29,16 @@
|
|||
fAdvancedBarItem = NSMenuItem;
|
||||
fInfoAnnounce = NSTextField;
|
||||
fInfoDownloaded = NSTextField;
|
||||
fInfoFolder = NSTextField;
|
||||
fInfoHash1 = NSTextField;
|
||||
fInfoHash2 = NSTextField;
|
||||
fInfoImageView = NSImageView;
|
||||
fInfoLeechers = NSTextField;
|
||||
fInfoName = NSTextField;
|
||||
fInfoPanel = NSPanel;
|
||||
fInfoPieceSize = NSTextField;
|
||||
fInfoPieces = NSTextField;
|
||||
fInfoSeeders = NSTextField;
|
||||
fInfoSize = NSTextField;
|
||||
fInfoTitle = NSTextField;
|
||||
fInfoTracker = NSTextField;
|
||||
fInfoUploaded = NSTextField;
|
||||
fPauseResumeItem = NSMenuItem;
|
||||
|
|
|
@ -25,7 +25,11 @@
|
|||
<string>443.0</string>
|
||||
<key>IBOldestOS</key>
|
||||
<integer>3</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>273</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8H14</string>
|
||||
<string>8G1454</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Binary file not shown.
|
@ -32,6 +32,7 @@
|
|||
BOOL fResumeOnWake;
|
||||
|
||||
NSImage * fIcon;
|
||||
NSImage * fIconNonFlipped;
|
||||
NSMutableString * fStatusString;
|
||||
NSMutableString * fInfoString;
|
||||
NSMutableString * fDownloadString;
|
||||
|
@ -53,9 +54,16 @@
|
|||
- (void) trashData;
|
||||
|
||||
- (NSImage *) icon;
|
||||
- (NSImage *) iconNonFlipped;
|
||||
- (NSString *) path;
|
||||
- (NSString *) name;
|
||||
- (uint64_t) size;
|
||||
- (NSString *) tracker;
|
||||
- (NSString *) announce;
|
||||
- (int) pieceSize;
|
||||
- (int) pieceCount;
|
||||
- (NSString *) hash1;
|
||||
- (NSString *) hash2;
|
||||
|
||||
- (float) progress;
|
||||
- (BOOL) isActive;
|
||||
|
@ -66,5 +74,9 @@
|
|||
- (NSString *) infoString;
|
||||
- (NSString *) downloadString;
|
||||
- (NSString *) uploadString;
|
||||
- (int) seeders;
|
||||
- (int) leechers;
|
||||
- (uint64_t) downloaded;
|
||||
- (uint64_t) uploaded;
|
||||
|
||||
@end
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];
|
||||
[fIcon setFlipped: YES];
|
||||
[fIcon retain];
|
||||
fIconNonFlipped = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];
|
||||
[fIconNonFlipped retain];
|
||||
|
||||
fStatusString = [[NSMutableString alloc] initWithCapacity: 50];
|
||||
fInfoString = [[NSMutableString alloc] initWithCapacity: 50];
|
||||
|
@ -232,6 +234,11 @@
|
|||
return fIcon;
|
||||
}
|
||||
|
||||
- (NSImage *) iconNonFlipped
|
||||
{
|
||||
return fIconNonFlipped;
|
||||
}
|
||||
|
||||
- (NSString *) path
|
||||
{
|
||||
return [NSString stringWithUTF8String: fInfo->torrent];
|
||||
|
@ -247,6 +254,50 @@
|
|||
return fInfo->totalSize;
|
||||
}
|
||||
|
||||
- (NSString *) tracker
|
||||
{
|
||||
return [NSString stringWithFormat: @"%s:%d",
|
||||
fInfo->trackerAddress, fInfo->trackerPort];
|
||||
}
|
||||
|
||||
- (NSString *) announce
|
||||
{
|
||||
return [NSString stringWithUTF8String: fInfo->trackerAnnounce];
|
||||
}
|
||||
|
||||
- (int) pieceSize
|
||||
{
|
||||
return fInfo->pieceSize;
|
||||
}
|
||||
|
||||
- (int) pieceCount
|
||||
{
|
||||
return fInfo->pieceCount;
|
||||
}
|
||||
|
||||
- (NSString *) hash1
|
||||
{
|
||||
NSMutableString * string = [NSMutableString
|
||||
stringWithCapacity: SHA_DIGEST_LENGTH];
|
||||
int i;
|
||||
for( i = 0; i < SHA_DIGEST_LENGTH / 2; i++ )
|
||||
{
|
||||
[string appendFormat: @"%02x", fInfo->hash[i]];
|
||||
}
|
||||
return string;
|
||||
}
|
||||
- (NSString *) hash2
|
||||
{
|
||||
NSMutableString * string = [NSMutableString
|
||||
stringWithCapacity: SHA_DIGEST_LENGTH];
|
||||
int i;
|
||||
for( i = SHA_DIGEST_LENGTH / 2; i < SHA_DIGEST_LENGTH; i++ )
|
||||
{
|
||||
[string appendFormat: @"%02x", fInfo->hash[i]];
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
- (float) progress
|
||||
{
|
||||
return fStat->progress;
|
||||
|
@ -292,6 +343,26 @@
|
|||
return fUploadString;
|
||||
}
|
||||
|
||||
- (int) seeders
|
||||
{
|
||||
return fStat->seeders;
|
||||
}
|
||||
|
||||
- (int) leechers
|
||||
{
|
||||
return fStat->leechers;
|
||||
}
|
||||
|
||||
- (uint64_t) downloaded
|
||||
{
|
||||
return fStat->downloaded;
|
||||
}
|
||||
|
||||
- (uint64_t) uploaded
|
||||
{
|
||||
return fStat->uploaded;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue