summaryrefslogtreecommitdiffstats
path: root/macosx/HBQueueActionItem.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2020-09-11 18:02:23 +0200
committerDamiano Galassi <[email protected]>2020-09-11 18:02:23 +0200
commit3a90d6a6ad023ff1b066c2890315d51ee0ea0612 (patch)
treee9981f19c3f2a36cfc5e2a6a166cf52738830118 /macosx/HBQueueActionItem.m
parentf6bb5723d1d4a23a3878628bb6fe146f536d1f8a (diff)
MacGui: show a stop row in the queue when 'Stop after current job' option is selected.
Diffstat (limited to 'macosx/HBQueueActionItem.m')
-rw-r--r--macosx/HBQueueActionItem.m68
1 files changed, 68 insertions, 0 deletions
diff --git a/macosx/HBQueueActionItem.m b/macosx/HBQueueActionItem.m
new file mode 100644
index 000000000..41401f271
--- /dev/null
+++ b/macosx/HBQueueActionItem.m
@@ -0,0 +1,68 @@
+/* HBQueueActionItem.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import "HBQueueActionItem.h"
+#import "HBCodingUtilities.h"
+
+@implementation HBQueueActionStopItem
+
+#pragma mark - NSSecureCoding
+
+- (instancetype)init
+{
+ self = [super init];
+ if (self) {
+ _state = HBQueueItemStateReady;
+ }
+ return self;
+}
+
+- (NSString *)title
+{
+ return NSLocalizedString(@"Stop", @"Queue -> Stop action");
+}
+
+- (BOOL)hasFileRepresentation
+{
+ return NO;
+}
+
+- (NSAttributedString *)attributedDescription
+{
+ return [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Stop action.", @"Queue -> Stop action")
+ attributes:@{NSFontAttributeName: [NSFont systemFontOfSize:NSFont.smallSystemFontSize]}];
+}
+
+- (NSImage *)image
+{
+ return [NSImage imageNamed:@"EncodeCanceled"];
+}
+
++ (BOOL)supportsSecureCoding
+{
+ return YES;
+}
+
+static NSString *versionKey = @"HBQueueActionItemVersion";
+
+- (void)encodeWithCoder:(nonnull NSCoder *)coder {
+ [coder encodeInt:1 forKey:versionKey];
+ encodeInteger(_state);
+}
+
+- (nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder {
+ int version = [decoder decodeIntForKey:versionKey];
+
+ if (version == 1 && (self = [super init]))
+ {
+ decodeInteger(_state); if (_state < HBQueueItemStateReady || _state > HBQueueItemStateRescanning) { goto fail; }
+ return self;
+ }
+fail:
+ return nil;
+}
+
+@end