2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2007-2022 Transmission authors and contributors.
|
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-11-17 15:55:23 +00:00
|
|
|
|
|
|
|
#import "FilterButton.h"
|
2010-11-14 20:26:58 +00:00
|
|
|
#import "NSStringAdditions.h"
|
2007-11-17 15:55:23 +00:00
|
|
|
|
|
|
|
@implementation FilterButton
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (instancetype)initWithCoder:(NSCoder*)coder
|
2007-11-17 15:55:23 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
if ((self = [super initWithCoder:coder]))
|
2007-11-17 16:35:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
_count = NSNotFound;
|
2007-11-17 16:52:56 +00:00
|
|
|
}
|
|
|
|
return self;
|
2007-11-17 15:55:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setCount:(NSUInteger)count
|
2007-11-17 15:55:23 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
if (count == _count)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2007-11-17 15:55:23 +00:00
|
|
|
return;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
_count = count;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.toolTip = _count == 1 ? NSLocalizedString(@"1 transfer", "Filter Button -> tool tip") :
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSString stringWithFormat:NSLocalizedString(@"%@ transfers", "Filter Bar Button -> tool tip"),
|
2022-02-22 16:04:20 +00:00
|
|
|
[NSString formattedUInteger:_count]];
|
2007-11-17 15:55:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|