1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-30 19:46:56 +00:00
transmission/macosx/WebSeedTableView.mm
2022-02-22 10:04:20 -06:00

42 lines
1.1 KiB
Text

// This file Copyright © 2012-2022 Transmission authors and contributors.
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.
#import "WebSeedTableView.h"
@implementation WebSeedTableView
- (void)mouseDown:(NSEvent*)event
{
[self.window makeKeyWindow];
[super mouseDown:event];
}
- (void)copy:(id)sender
{
NSIndexSet* indexes = self.selectedRowIndexes;
NSMutableArray* addresses = [NSMutableArray arrayWithCapacity:indexes.count];
[self.webSeeds enumerateObjectsAtIndexes:indexes options:0 usingBlock:^(NSDictionary* webSeed, NSUInteger idx, BOOL* stop) {
[addresses addObject:webSeed[@"Address"]];
}];
NSString* text = [addresses componentsJoinedByString:@"\n"];
NSPasteboard* pb = NSPasteboard.generalPasteboard;
[pb clearContents];
[pb writeObjects:@[ text ]];
}
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem
{
SEL const action = menuItem.action;
if (action == @selector(copy:))
{
return self.numberOfSelectedRows > 0;
}
return YES;
}
@end