This commit is contained in:
galad87 committed 2015-08-29 13:12:26 +02:00
1 parent bb241f46b1
commit ee94900e33
10 files changed
+56 -67

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSArray+Subscripting.h
// Subler
//
+2 -5
View File
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSArray+Subscripting.m
// Subler
//
@@ -11,9 +11,7 @@
+ (void)load
{
Class class = [self class];
SEL swizzledSelector = @selector(dg_objectAtIndexedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
class_addMethod([NSArray class],
@@ -23,8 +21,7 @@
);
}
- (id)dg_objectAtIndexedSubscript:(NSInteger)index
{
- (id)dg_objectAtIndexedSubscript:(NSInteger)index {
return [self objectAtIndex:index];
}
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSDictionary+Subscript.h
// Subler
//
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSDictionary+Subscript.m
// Subler
//
@@ -8,10 +8,8 @@
@implementation NSDictionary (Subscript)
+ (void)load
{
+ (void)load {
Class class = [self class];
SEL swizzledSelector = @selector(dg_objectForKeyedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
@@ -22,8 +20,7 @@
);
}
-(id)dg_objectForKeyedSubscript:(id)key
{
-(id)dg_objectForKeyedSubscript:(id)key {
return [self objectForKey:key];
}
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSMutableArray+Subscript.h
// Subler
//
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSMutableArray+Subscript.m
// Subler
//
@@ -11,7 +11,6 @@
+ (void)load
{
Class class = [self class];
SEL swizzledSelector = @selector(dg_setObject:atIndexedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
@@ -22,22 +21,17 @@
);
}
- (void)dg_setObject:(id)anObject atIndexedSubscript:(NSUInteger)index
{
if(anObject == nil)
{
- (void)dg_setObject:(id)anObject atIndexedSubscript:(NSUInteger)index {
if (anObject == nil) {
[NSException raise:NSInvalidArgumentException format:@"setObject:atIndexedSubscript does not allow objects to be nil"];
}
if(index > self.count)
{
if (index > self.count) {
[NSException raise:NSRangeException format:@"setObject:atIndexedSubscript does not allow the index to be out of array bounds"];
}
if(index == self.count)
{
if (index == self.count) {
[self addObject:anObject];
}
else
{
else {
[self replaceObjectAtIndex:index withObject:anObject];
}
}
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSMutableDictionary+Subscript.h
// Subler
//
@@ -1,5 +1,5 @@
//
// SBLogger.m
// NSMutableDictionary+Subscript.m
// Subler
//
@@ -8,10 +8,8 @@
@implementation NSMutableDictionary (Subscript)
+ (void)load
{
+ (void)load {
Class class = [self class];
SEL swizzledSelector = @selector(dg_setObject:forKeyedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
@@ -22,8 +20,7 @@
);
}
- (void)dg_setObject:(id)object forKeyedSubscript:(id < NSCopying >)aKey
{
- (void)dg_setObject:(id)object forKeyedSubscript:(id < NSCopying >)aKey {
[self setObject:object forKey:aKey];
}
+14 -14
View File
@@ -88,20 +88,21 @@
#ifdef DONATION
BOOL firstLaunch = YES;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"])
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]) {
firstLaunch = NO;
}
if (![[NSUserDefaults standardUserDefaults] valueForKey:@"WarningDonate"]) {
NSDate * lastDonateDate = [[NSUserDefaults standardUserDefaults] valueForKey:@"DonateAskDate"];
if (![[NSUserDefaults standardUserDefaults] valueForKey:@"WarningDonate"]) {
NSDate *lastDonateDate = [[NSUserDefaults standardUserDefaults] valueForKey:@"DonateAskDate"];
const BOOL timePassed = !lastDonateDate || (-1 * [lastDonateDate timeIntervalSinceNow]) >= DONATE_NAG_TIME;
if (!firstLaunch && timePassed) {
[[NSUserDefaults standardUserDefaults] setValue:[NSDate date] forKey:@"DonateAskDate"];
NSAlert * alert = [[NSAlert alloc] init];
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText: NSLocalizedString(@"Support Subler", "Donation -> title")];
NSString * donateMessage = [NSString stringWithFormat: @"%@",
NSString *donateMessage = [NSString stringWithFormat: @"%@",
NSLocalizedString(@" A lot of time and effort have gone into development, coding, and refinement."
" If you enjoy using it, please consider showing your appreciation with a donation.", "Donation -> message")];
@@ -114,22 +115,26 @@
const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them time to try the app
[alert setShowsSuppressionButton:allowNeverAgain];
if (allowNeverAgain)
if (allowNeverAgain) {
[[alert suppressionButton] setTitle:NSLocalizedString(@"Don't ask me about this ever again.", "Donation -> button")];
}
const NSInteger donateResult = [alert runModal];
if (donateResult == NSAlertFirstButtonReturn)
if (donateResult == NSAlertFirstButtonReturn) {
[self linkDonate:self];
}
if (allowNeverAgain)
if (allowNeverAgain) {
[[NSUserDefaults standardUserDefaults] setBool:([[alert suppressionButton] state] != NSOnState) forKey:@"WarningDonate"];
}
[alert release];
}
}
if (firstLaunch)
if (firstLaunch) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstLaunch"];
}
#endif
[SBQueueController sharedManager];
@@ -184,11 +189,6 @@
@implementation SBDocumentController
- (instancetype)init
{
return [super init];
}
- (void)openDocumentWithContentsOfURL:(NSURL * _Nonnull)url
display:(BOOL)displayDocument
completionHandler:(void (^ _Nonnull)(NSDocument * _Nullable document,
+24 -20
View File
@@ -167,8 +167,8 @@
case NSSaveAsOperation:
// movie does not exist, create a new one from scratch.
if ([_64bit_data state]) { attributes[MP4264BitData] = @YES; }
if ([_64bit_time state]) { attributes[MP4264BitTime] = @YES; }
if (_64bit_data.state) { attributes[MP4264BitData] = @YES; }
if (_64bit_time.state) { attributes[MP4264BitTime] = @YES; }
result = [self.mp4 writeToUrl:url withAttributes:attributes error:outError];
break;
@@ -597,18 +597,18 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
[self close];
} else {
NSSavePanel *panel = [NSSavePanel savePanel];
[self prepareSavePanel:panel];
panel.prompt = NSLocalizedString(@"Send To Queue", nil);
[panel setPrompt:@"Send To Queue"];
[self prepareSavePanel:panel];
[panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
if ([_64bit_data state]) [attributes setObject:@YES forKey:MP4264BitData];
if ([_64bit_time state]) [attributes setObject:@YES forKey:MP4264BitTime];
if (_64bit_data.state) { attributes[MP4264BitData] = @YES; }
if (_64bit_time.state) { attributes[MP4264BitTime] = @YES; }
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"chaptersPreviewTrack"] boolValue]) {
[attributes setObject:@YES forKey:MP42GenerateChaptersPreviewTrack];
attributes[MP42GenerateChaptersPreviewTrack] = @YES;
}
SBQueueItem *item = [SBQueueItem itemWithMP4:self.mp4 destinationURL:panel.URL attributes:attributes];
@@ -626,7 +626,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
NSString *filename = nil;
for (MP42Track *track in self.mp4.tracks) {
if (track.sourceURL) {
filename = [track.sourceURL lastPathComponent];
filename = track.sourceURL.lastPathComponent;
break;
}
}
@@ -801,7 +801,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
- (void)addMetadata:(NSURL *)URL
{
if ([[URL pathExtension] isEqualToString:@"xml"] || [[URL pathExtension] isEqualToString:@"nfo"]) {
if ([URL.pathExtension isEqualToString:@"xml"] || [URL.pathExtension isEqualToString:@"nfo"]) {
MP42Metadata *xmlMetadata = [[MP42Metadata alloc] initWithFileURL:URL];
[self.mp4.metadata mergeMetadata:xmlMetadata];
[xmlMetadata release];
@@ -835,9 +835,13 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
- (IBAction)export:(id)sender
{
NSInteger row = [fileTracksTable selectedRow];
NSSavePanel * panel = [NSSavePanel savePanel];
NSString *filename = [[[[self fileURL] path] stringByDeletingPathExtension] lastPathComponent];
NSString *filename = self.fileURL.URLByDeletingPathExtension.lastPathComponent;
NSSavePanel *panel = [NSSavePanel savePanel];
panel.canSelectHiddenExtension = YES;
panel.nameFieldStringValue = filename;
NSInteger row = fileTracksTable.selectedRow;
if (row != -1 && [[self.mp4 trackAtIndex:row] isKindOfClass:[MP42SubtitleTrack class]]) {
panel.allowedFileTypes = @[@"srt"];
@@ -848,20 +852,20 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
panel.allowedFileTypes = @[@"txt"];
}
[panel setCanSelectHiddenExtension: YES];
[panel setNameFieldStringValue:filename];
[panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
id track = [self.mp4 trackAtIndex:[fileTracksTable selectedRow]];
if (![track exportToURL: [panel URL] error: nil]) {
NSAlert * alert = [[NSAlert alloc] init];
NSError *error;
id track = [self.mp4 trackAtIndex:row];
if (![track exportToURL:panel.URL error:&error]) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Export alert panel -> button")];
[alert setMessageText: NSLocalizedString(@"File Could Not Be Saved", "Export alert panel -> title")];
[alert setInformativeText: [NSString stringWithFormat:
NSLocalizedString(@"There was a problem creating the file \"%@\".",
"Export alert panel -> message"), [[[panel URL] path] lastPathComponent]]];
"Export alert panel -> message"), panel.URL.lastPathComponent]];
[alert setAlertStyle: NSWarningAlertStyle];
[alert runModal];