diff options
author | Damiano Galassi <[email protected]> | 2020-01-13 17:19:43 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2020-01-13 17:19:43 +0100 |
commit | 80127fdb821c1e795b486d957e36bdab3f5de1f6 (patch) | |
tree | cab65feadbe05d7d89abf7869245e4a9186d03a9 /macosx/HBPreset.m | |
parent | fce3bbbf92011ee2eb9a3805f6b426ff1ffb6eba (diff) |
MacGui: improve presets view to allow multiple selection, drag & drop from and to Finder.
Diffstat (limited to 'macosx/HBPreset.m')
-rw-r--r-- | macosx/HBPreset.m | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/macosx/HBPreset.m b/macosx/HBPreset.m index 013e11b9c..f0fec1310 100644 --- a/macosx/HBPreset.m +++ b/macosx/HBPreset.m @@ -186,6 +186,7 @@ [self.children addObject:preset]; } } + [self resetBuiltInAndDefaultState]; return self; } else if (outError) @@ -246,7 +247,7 @@ return output; } -- (BOOL)writeToURL:(NSURL *)url atomically:(BOOL)atomically format:(HBPresetFormat)format removeRoot:(BOOL)removeRoot +- (BOOL)writeToURL:(NSURL *)url atomically:(BOOL)atomically removeRoot:(BOOL)removeRoot error:(NSError * __autoreleasing *)outError { BOOL success = NO; NSArray *presetList; @@ -268,16 +269,10 @@ @"VersionMinor": @(minor), @"VersionMicro": @(micro) }; - if (format == HBPresetFormatPlist) - { - success = [dict writeToURL:url atomically:atomically]; - } - else - { - NSUInteger sortKeys = (1UL << 1); // NSJSONWritingSortedKeys in 10.13 sdk; - NSData *jsonPreset = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted | sortKeys error:NULL]; - success = [jsonPreset writeToURL:url atomically:atomically]; - } + + NSUInteger sortKeys = (1UL << 1); // NSJSONWritingSortedKeys in 10.13 sdk; + NSData *jsonPreset = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted | sortKeys error:NULL]; + success = [jsonPreset writeToURL:url options:NSDataWritingAtomic error:outError]; return success; } @@ -300,6 +295,17 @@ } } +- (void)resetBuiltInAndDefaultState +{ + _isBuiltIn = NO; + _isDefault = NO; + + for (HBPreset *child in self.children) + { + [child resetBuiltInAndDefaultState]; + } +} + #pragma mark - NSCopying - (id)copyWithZone:(NSZone *)zone |