#6078: Show main window and scroll to torrent on notification click

This commit is contained in:
Mike Gelfand 2016-03-03 17:57:08 +00:00
parent e4f929fba9
commit 375571c9b4
3 changed files with 23 additions and 2 deletions

View File

@ -1991,8 +1991,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
}
NSAssert1(row != -1, @"expected a row to be found for torrent %@", torrent);
[fTableView selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection:NO];
#warning focus the window
[self showMainWindow: nil];
[fTableView selectAndScrollToRow: row];
}
}
}

View File

@ -91,4 +91,6 @@
- (void) togglePiecesBar;
- (CGFloat) piecesBarPercent;
- (void) selectAndScrollToRow: (NSInteger) row;
@end

View File

@ -842,6 +842,24 @@
return fPiecesBarPercent;
}
- (void) selectAndScrollToRow: (NSInteger) row
{
NSParameterAssert(row >= 0);
NSParameterAssert(row < [self numberOfRows]);
[self selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
const NSRect rowRect = [self rectOfRow: row];
const NSRect viewRect = [[self superview] frame];
NSPoint scrollOrigin = rowRect.origin;
scrollOrigin.y += (rowRect.size.height - viewRect.size.height) / 2;
if (scrollOrigin.y < 0)
scrollOrigin.y = 0;
[[[self superview] animator] setBoundsOrigin: scrollOrigin];
}
@end
@implementation TorrentTableView (Private)