mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
skeleton for priorities in the Mac UI - still lacks ability to actually change the priority
This commit is contained in:
@@ -287,7 +287,7 @@ typedef enum
|
||||
|
||||
- (void) setPriority: (id) sender
|
||||
{
|
||||
NSInteger priority;
|
||||
tr_priority_t priority;
|
||||
switch ([sender tag])
|
||||
{
|
||||
case FILE_PRIORITY_HIGH_TAG:
|
||||
@@ -374,7 +374,7 @@ typedef enum
|
||||
|
||||
//determine which priorities are checked
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
NSInteger priority;
|
||||
tr_priority_t priority;
|
||||
switch ([menuItem tag])
|
||||
{
|
||||
case FILE_PRIORITY_HIGH_TAG:
|
||||
|
||||
@@ -123,6 +123,9 @@ typedef enum
|
||||
- (void) setWaitToStart: (BOOL) wait;
|
||||
- (BOOL) waitingToStart;
|
||||
|
||||
- (tr_priority_t) priority;
|
||||
- (void) setPriority: (tr_priority_t) priority;
|
||||
|
||||
- (void) revealData;
|
||||
- (void) revealPublicTorrent;
|
||||
- (void) trashData;
|
||||
@@ -243,8 +246,8 @@ typedef enum
|
||||
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
|
||||
- (NSInteger) checkForFiles: (NSIndexSet *) indexSet;
|
||||
- (void) setFileCheckState: (NSInteger) state forIndexes: (NSIndexSet *) indexSet;
|
||||
- (void) setFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet;
|
||||
- (BOOL) hasFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet;
|
||||
- (void) setFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet;
|
||||
- (BOOL) hasFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet;
|
||||
- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
|
||||
|
||||
- (NSDate *) dateAdded;
|
||||
|
||||
@@ -444,6 +444,16 @@ int trashDataFile(const char * filename)
|
||||
return fWaitToStart;
|
||||
}
|
||||
|
||||
- (tr_priority_t) priority
|
||||
{
|
||||
return tr_torrentGetPriority(fHandle);
|
||||
}
|
||||
|
||||
- (void) setPriority: (tr_priority_t) priority
|
||||
{
|
||||
return tr_torrentSetPriority(fHandle, priority);
|
||||
}
|
||||
|
||||
- (void) revealData
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] selectFile: [self dataLocation] inFileViewerRootedAtPath: nil];
|
||||
@@ -1458,7 +1468,7 @@ int trashDataFile(const char * filename)
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFileCheckChange" object: self];
|
||||
}
|
||||
|
||||
- (void) setFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet
|
||||
- (void) setFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet
|
||||
{
|
||||
const NSUInteger count = [indexSet count];
|
||||
tr_file_index_t * files = malloc(count * sizeof(tr_file_index_t));
|
||||
@@ -1469,7 +1479,7 @@ int trashDataFile(const char * filename)
|
||||
free(files);
|
||||
}
|
||||
|
||||
- (BOOL) hasFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet
|
||||
- (BOOL) hasFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet
|
||||
{
|
||||
for (NSInteger index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
if (priority == tr_torrentGetFilePriority(fHandle, index) && [self canChangeDownloadCheckForFile: index])
|
||||
@@ -1487,7 +1497,7 @@ int trashDataFile(const char * filename)
|
||||
if (![self canChangeDownloadCheckForFile: index])
|
||||
continue;
|
||||
|
||||
const NSInteger priority = tr_torrentGetFilePriority(fHandle, index);
|
||||
const tr_priority_t priority = tr_torrentGetFilePriority(fHandle, index);
|
||||
if (priority == TR_PRI_LOW)
|
||||
{
|
||||
if (low)
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
BOOL fTracking, fMouseDownControlButton, fMouseDownRevealButton, fMouseDownActionButton,
|
||||
fHoverControl, fHoverReveal, fHoverAction;
|
||||
|
||||
NSImage * fHighPriorityImage, * fLowPriorityImage;
|
||||
|
||||
NSColor * fBarBorderColor, * fBluePieceColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
#define NORMAL_BUTTON_WIDTH 14.0f
|
||||
#define ACTION_BUTTON_WIDTH 16.0f
|
||||
|
||||
#define PRIORITY_ICON_WIDTH 14.0f
|
||||
#define PRIORITY_ICON_HEIGHT 14.0f
|
||||
|
||||
//ends up being larger than font height
|
||||
#define HEIGHT_TITLE 16.0f
|
||||
#define HEIGHT_STATUS 12.0f
|
||||
@@ -43,6 +46,7 @@
|
||||
#define PADDING_HORIZONTAL 3.0f
|
||||
#define PADDING_BETWEEN_IMAGE_AND_TITLE 5.0f
|
||||
#define PADDING_BETWEEN_IMAGE_AND_BAR 7.0f
|
||||
#define PADDING_BETWEEN_TITLE_AND_PRIORITY 4.0f
|
||||
#define PADDING_ABOVE_TITLE 4.0f
|
||||
#define PADDING_ABOVE_MIN_STATUS 4.0f
|
||||
#define PADDING_BETWEEN_TITLE_AND_MIN_STATUS 2.0f
|
||||
@@ -98,6 +102,12 @@
|
||||
|
||||
fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0f green: 0.4f blue: 0.8f alpha: 1.0f] retain];
|
||||
fBarBorderColor = [[NSColor colorWithCalibratedWhite: 0.0f alpha: 0.2f] retain];
|
||||
|
||||
fHighPriorityImage = [[NSImage imageNamed: @"PriorityHigh.png"] copy];
|
||||
[fHighPriorityImage setFlipped: YES];
|
||||
|
||||
fLowPriorityImage = [[NSImage imageNamed: @"PriorityLow.png"] copy];
|
||||
[fLowPriorityImage setFlipped: YES];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -455,6 +465,17 @@
|
||||
NSRect titleRect = [self rectForTitleWithString: titleString basedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame];
|
||||
[titleString drawInRect: titleRect];
|
||||
|
||||
//priority icon
|
||||
if ([torrent priority] != TR_PRI_NORMAL)
|
||||
{
|
||||
NSImage * priorityImage = [torrent priority] == TR_PRI_HIGH ? fHighPriorityImage : fLowPriorityImage;
|
||||
|
||||
NSRect priorityRect = NSMakeRect(NSMaxX(titleRect) + PADDING_BETWEEN_TITLE_AND_PRIORITY,
|
||||
titleRect.origin.y - (PRIORITY_ICON_HEIGHT - titleRect.size.height) / 2.0,
|
||||
PRIORITY_ICON_WIDTH, PRIORITY_ICON_HEIGHT);
|
||||
[priorityImage drawInRect: priorityRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
|
||||
}
|
||||
|
||||
//progress
|
||||
if (!minimal)
|
||||
{
|
||||
@@ -718,7 +739,7 @@
|
||||
- (NSRect) rectForTitleWithString: (NSAttributedString *) string basedOnMinimalStatusRect: (NSRect) statusRect
|
||||
inBounds: (NSRect) bounds
|
||||
{
|
||||
BOOL minimal = [fDefaults boolForKey: @"SmallView"];
|
||||
const BOOL minimal = [fDefaults boolForKey: @"SmallView"];
|
||||
|
||||
NSRect result = bounds;
|
||||
result.origin.y += PADDING_ABOVE_TITLE;
|
||||
@@ -726,7 +747,8 @@
|
||||
|
||||
result.size = [string size];
|
||||
result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL
|
||||
- (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + statusRect.size.width : 0));
|
||||
- (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + statusRect.size.width : 0.0)
|
||||
- ([[self representedObject] priority] != TR_PRI_NORMAL ? PRIORITY_ICON_WIDTH + PADDING_BETWEEN_TITLE_AND_PRIORITY: 0.0));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user