diff --git a/cocoa/base/AppDelegateBase.h b/cocoa/base/AppDelegateBase.h index 3c3fcb96..038123f9 100644 --- a/cocoa/base/AppDelegateBase.h +++ b/cocoa/base/AppDelegateBase.h @@ -10,6 +10,7 @@ http://www.gnu.org/licenses/gpl-3.0.html #import #import "PyDupeGuru.h" #import "ResultWindow.h" +#import "ResultTable.h" #import "DetailsPanel.h" #import "DirectoryPanel.h" #import "IgnoreListDialog.h" @@ -24,7 +25,7 @@ http://www.gnu.org/licenses/gpl-3.0.html SUUpdater *updater; PyDupeGuru *model; - ResultWindowBase *_resultWindow; + ResultWindow *_resultWindow; DirectoryPanel *_directoryPanel; DetailsPanel *_detailsPanel; IgnoreListDialog *_ignoreListDialog; @@ -41,14 +42,14 @@ http://www.gnu.org/licenses/gpl-3.0.html /* Virtual */ + (NSDictionary *)defaultPreferences; - (PyDupeGuru *)model; -- (ResultWindowBase *)createResultWindow; -- (DirectoryPanel *)createDirectoryPanel; - (DetailsPanel *)createDetailsPanel; - (NSString *)homepageURL; +- (void)setScanOptions; +- (void)initResultColumns:(ResultTable *)aTable; /* Public */ - (void)finalizeInit; -- (ResultWindowBase *)resultWindow; +- (ResultWindow *)resultWindow; - (DirectoryPanel *)directoryPanel; - (DetailsPanel *)detailsPanel; - (HSRecentFiles *)recentResults; diff --git a/cocoa/base/AppDelegateBase.m b/cocoa/base/AppDelegateBase.m index bcd0df8b..46e7b04b 100644 --- a/cocoa/base/AppDelegateBase.m +++ b/cocoa/base/AppDelegateBase.m @@ -69,12 +69,12 @@ http://www.gnu.org/licenses/gpl-3.0.html } _recentResults = [[HSRecentFiles alloc] initWithName:@"recentResults" menu:recentResultsMenu]; [_recentResults setDelegate:self]; - _resultWindow = [self createResultWindow]; - _directoryPanel = [self createDirectoryPanel]; + _resultWindow = [[ResultWindow alloc] initWithParentApp:self]; + _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; _detailsPanel = [self createDetailsPanel]; _ignoreListDialog = [[IgnoreListDialog alloc] initWithPyRef:[model ignoreListDialog]]; _progressWindow = [[HSProgressWindow alloc] initWithPyRef:[[self model] progressWindow] view:nil]; - [_progressWindow setParentWindow:[_resultWindow window]]; + [_progressWindow setParentWindow:[_directoryPanel window]]; _aboutBox = nil; // Lazily loaded _preferencesPanel = nil; // Lazily loaded [[[self directoryPanel] window] makeKeyAndOrderFront:self]; @@ -87,16 +87,6 @@ http://www.gnu.org/licenses/gpl-3.0.html return model; } -- (ResultWindowBase *)createResultWindow -{ - return nil; // must be overriden by all editions -} - -- (DirectoryPanel *)createDirectoryPanel -{ - return [[DirectoryPanel alloc] initWithParentApp:self]; -} - - (DetailsPanel *)createDetailsPanel { return [[DetailsPanel alloc] initWithPyRef:[model detailsPanel]]; @@ -107,8 +97,16 @@ http://www.gnu.org/licenses/gpl-3.0.html return @""; // must be overriden by all editions } +- (void)setScanOptions +{ +} + +- (void)initResultColumns:(ResultTable *)aTable +{ +} + /* Public */ -- (ResultWindowBase *)resultWindow +- (ResultWindow *)resultWindow { return _resultWindow; } @@ -191,7 +189,7 @@ http://www.gnu.org/licenses/gpl-3.0.html - (void)startScanning { - [[self resultWindow] startDuplicateScan]; + [[self directoryPanel] startDuplicateScan]; } @@ -254,6 +252,11 @@ http://www.gnu.org/licenses/gpl-3.0.html return [Dialogs askYesNo:prompt] == NSAlertFirstButtonReturn; } +- (void)showResultsWindow +{ + [[[self resultWindow] window] makeKeyAndOrderFront:nil]; +} + - (void)showProblemDialog { [[self resultWindow] showProblemDialog]; diff --git a/cocoa/base/DirectoryPanel.h b/cocoa/base/DirectoryPanel.h index 03f738c0..19318e42 100644 --- a/cocoa/base/DirectoryPanel.h +++ b/cocoa/base/DirectoryPanel.h @@ -45,6 +45,7 @@ http://www.gnu.org/licenses/gpl-3.0.html - (void)popupAddDirectoryMenu:(id)sender; - (void)popupLoadRecentMenu:(id)sender; - (void)removeSelectedDirectory; +- (void)startDuplicateScan; - (void)addDirectory:(NSString *)directory; - (void)refreshRemoveButtonText; diff --git a/cocoa/base/DirectoryPanel.m b/cocoa/base/DirectoryPanel.m index 322328f7..e3b10daa 100644 --- a/cocoa/base/DirectoryPanel.m +++ b/cocoa/base/DirectoryPanel.m @@ -137,6 +137,16 @@ http://www.gnu.org/licenses/gpl-3.0.html [self refreshRemoveButtonText]; } +- (void)startDuplicateScan +{ + if ([model resultsAreModified]) { + if ([Dialogs askYesNo:NSLocalizedString(@"You have unsaved results, do you really want to continue?", @"")] == NSAlertSecondButtonReturn) // NO + return; + } + [_app setScanOptions]; + [model doScan]; +} + /* Public */ - (void)addDirectory:(NSString *)directory { diff --git a/cocoa/base/ResultWindowBase.h b/cocoa/base/ResultWindow.h similarity index 93% rename from cocoa/base/ResultWindowBase.h rename to cocoa/base/ResultWindow.h index 09c38c9b..d61ab430 100644 --- a/cocoa/base/ResultWindowBase.h +++ b/cocoa/base/ResultWindow.h @@ -17,7 +17,7 @@ http://www.gnu.org/licenses/gpl-3.0.html @class AppDelegateBase; -@interface ResultWindowBase : NSWindowController +@interface ResultWindow : NSWindowController { @protected NSSegmentedControl *optionsSwitch; @@ -43,10 +43,6 @@ http://www.gnu.org/licenses/gpl-3.0.html - (id)initWithParentApp:(AppDelegateBase *)app; -/* Virtual */ -- (void)initResultColumns; -- (void)setScanOptions; - /* Helpers */ - (void)fillColumnsMenu; - (void)updateOptionSegments; @@ -75,7 +71,6 @@ http://www.gnu.org/licenses/gpl-3.0.html - (void)resetColumnsToDefault; - (void)revealSelected; - (void)saveResults; -- (void)startDuplicateScan; - (void)switchSelected; - (void)toggleColumn:(id)sender; - (void)toggleDelta; diff --git a/cocoa/base/ResultWindowBase.m b/cocoa/base/ResultWindow.m similarity index 94% rename from cocoa/base/ResultWindowBase.m rename to cocoa/base/ResultWindow.m index 83218b18..9afc6723 100644 --- a/cocoa/base/ResultWindowBase.m +++ b/cocoa/base/ResultWindow.m @@ -6,7 +6,7 @@ which should be included with this package. The terms are also available at http://www.gnu.org/licenses/gpl-3.0.html */ -#import "ResultWindowBase.h" +#import "ResultWindow.h" #import "ResultWindow_UI.h" #import "Dialogs.h" #import "ProgressController.h" @@ -15,7 +15,7 @@ http://www.gnu.org/licenses/gpl-3.0.html #import "Consts.h" #import "PrioritizeDialog.h" -@implementation ResultWindowBase +@implementation ResultWindow @synthesize optionsSwitch; @synthesize optionsToolbarItem; @@ -36,7 +36,7 @@ http://www.gnu.org/licenses/gpl-3.0.html statsLabel = [[StatsLabel alloc] initWithPyRef:[model statsLabel] view:stats]; problemDialog = [[ProblemDialog alloc] initWithPyRef:[model problemDialog]]; deletionOptions = [[DeletionOptions alloc] initWithPyRef:[model deletionOptions]]; - [self initResultColumns]; + [aApp initResultColumns:table]; [[table columns] setColumnsAsReadOnly]; [self fillColumnsMenu]; [matches setTarget:self]; @@ -53,15 +53,6 @@ http://www.gnu.org/licenses/gpl-3.0.html [super dealloc]; } -/* Virtual */ -- (void)initResultColumns -{ -} - -- (void)setScanOptions -{ -} - /* Helpers */ - (void)fillColumnsMenu { @@ -263,16 +254,6 @@ http://www.gnu.org/licenses/gpl-3.0.html } } -- (void)startDuplicateScan -{ - if ([model resultsAreModified]) { - if ([Dialogs askYesNo:NSLocalizedString(@"You have unsaved results, do you really want to continue?", @"")] == NSAlertSecondButtonReturn) // NO - return; - } - [self setScanOptions]; - [model doScan]; -} - - (void)switchSelected { [model makeSelectedReference]; diff --git a/cocoa/base/ui/result_window.py b/cocoa/base/ui/result_window.py index b4fa769b..ad3b075a 100644 --- a/cocoa/base/ui/result_window.py +++ b/cocoa/base/ui/result_window.py @@ -1,5 +1,5 @@ -ownerclass = 'ResultWindowBase' -ownerimport = 'ResultWindowBase.h' +ownerclass = 'ResultWindow' +ownerimport = 'ResultWindow.h' result = Window(557, 400, "dupeGuru Results") toolbar = result.createToolbar('ResultsToolbar') diff --git a/cocoa/inter/app.py b/cocoa/inter/app.py index f15e5a24..91da591a 100644 --- a/cocoa/inter/app.py +++ b/cocoa/inter/app.py @@ -6,6 +6,7 @@ from cocoa.inter import PyBaseApp, BaseAppView class DupeGuruView(BaseAppView): def askYesNoWithPrompt_(self, prompt: str) -> bool: pass + def showResultsWindow(self): pass def showProblemDialog(self): pass def selectDestFolderWithPrompt_(self, prompt: str) -> str: pass def selectDestFileWithPrompt_extension_(self, prompt: str, extension: str) -> str: pass @@ -152,10 +153,7 @@ class PyDupeGuruBase(PyBaseApp): @dontwrap def show_results_window(self): - # Not needed yet because our progress dialog is shown as a sheet of the results window, - # which causes it to be already visible when the scan/load ends. - # XXX Make progress sheet be a child of the folder selection window. - pass + self.callback.showResultsWindow() @dontwrap def show_problem_dialog(self): diff --git a/cocoa/me/AppDelegate.m b/cocoa/me/AppDelegate.m index a9cf2482..95f274da 100644 --- a/cocoa/me/AppDelegate.m +++ b/cocoa/me/AppDelegate.m @@ -50,8 +50,57 @@ http://www.gnu.org/licenses/gpl-3.0.html return @"https://www.hardcoded.net/dupeguru_me/"; } -- (ResultWindowBase *)createResultWindow +- (void)setScanOptions { - return [[ResultWindow alloc] initWithParentApp:self]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [model setScanType:n2i([ud objectForKey:@"scanType"])]; + [model enable:n2b([ud objectForKey:@"scanTagTrack"]) scanForTag:@"track"]; + [model enable:n2b([ud objectForKey:@"scanTagArtist"]) scanForTag:@"artist"]; + [model enable:n2b([ud objectForKey:@"scanTagAlbum"]) scanForTag:@"album"]; + [model enable:n2b([ud objectForKey:@"scanTagTitle"]) scanForTag:@"title"]; + [model enable:n2b([ud objectForKey:@"scanTagGenre"]) scanForTag:@"genre"]; + [model enable:n2b([ud objectForKey:@"scanTagYear"]) scanForTag:@"year"]; + [model setMinMatchPercentage:n2i([ud objectForKey:@"minMatchPercentage"])]; + [model setWordWeighting:n2b([ud objectForKey:@"wordWeighting"])]; + [model setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])]; + [model setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])]; + [model setMatchSimilarWords:n2b([ud objectForKey:@"matchSimilarWords"])]; +} + +- (void)initResultColumns:(ResultTable *)aTable +{ + HSColumnDef defs[] = { + {@"marked", 26, 26, 26, YES, [NSButtonCell class]}, + {@"name", 235, 16, 0, YES, nil}, + {@"folder_path", 120, 16, 0, YES, nil}, + {@"size", 63, 16, 0, YES, nil}, + {@"duration", 50, 16, 0, YES, nil}, + {@"bitrate", 50, 16, 0, YES, nil}, + {@"samplerate", 60, 16, 0, YES, nil}, + {@"extension", 40, 16, 0, YES, nil}, + {@"mtime", 120, 16, 0, YES, nil}, + {@"title", 120, 16, 0, YES, nil}, + {@"artist", 120, 16, 0, YES, nil}, + {@"album", 120, 16, 0, YES, nil}, + {@"genre", 80, 16, 0, YES, nil}, + {@"year", 40, 16, 0, YES, nil}, + {@"track", 40, 16, 0, YES, nil}, + {@"comment", 120, 16, 0, YES, nil}, + {@"percentage", 57, 16, 0, YES, nil}, + {@"words", 120, 16, 0, YES, nil}, + {@"dupe_count", 80, 16, 0, YES, nil}, + nil + }; + [[aTable columns] initializeColumns:defs]; + NSTableColumn *c = [[aTable view] tableColumnWithIdentifier:@"marked"]; + [[c dataCell] setButtonType:NSSwitchButton]; + [[c dataCell] setControlSize:NSSmallControlSize]; + c = [[aTable view] tableColumnWithIdentifier:@"size"]; + [[c dataCell] setAlignment:NSRightTextAlignment]; + c = [[aTable view] tableColumnWithIdentifier:@"duration"]; + [[c dataCell] setAlignment:NSRightTextAlignment]; + c = [[aTable view] tableColumnWithIdentifier:@"bitrate"]; + [[c dataCell] setAlignment:NSRightTextAlignment]; + [[aTable columns] restoreColumns]; } @end diff --git a/cocoa/me/ResultWindow.h b/cocoa/me/ResultWindow.h deleted file mode 100644 index 707edb5b..00000000 --- a/cocoa/me/ResultWindow.h +++ /dev/null @@ -1,13 +0,0 @@ -/* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) - -This software is licensed under the "GPLv3" License as described in the "LICENSE" file, -which should be included with this package. The terms are also available at -http://www.gnu.org/licenses/gpl-3.0.html -*/ - -#import -#import "ResultWindowBase.h" - -@interface ResultWindow : ResultWindowBase {} -@end diff --git a/cocoa/me/ResultWindow.m b/cocoa/me/ResultWindow.m deleted file mode 100644 index 27a0f449..00000000 --- a/cocoa/me/ResultWindow.m +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) - -This software is licensed under the "GPLv3" License as described in the "LICENSE" file, -which should be included with this package. The terms are also available at -http://www.gnu.org/licenses/gpl-3.0.html -*/ - -#import "ResultWindow.h" -#import "Dialogs.h" -#import "Utils.h" -#import "PyDupeGuru.h" -#import "Consts.h" -#import "ProgressController.h" - -@implementation ResultWindow -/* Override */ -- (void)setScanOptions -{ - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - [model setScanType:n2i([ud objectForKey:@"scanType"])]; - [model enable:n2b([ud objectForKey:@"scanTagTrack"]) scanForTag:@"track"]; - [model enable:n2b([ud objectForKey:@"scanTagArtist"]) scanForTag:@"artist"]; - [model enable:n2b([ud objectForKey:@"scanTagAlbum"]) scanForTag:@"album"]; - [model enable:n2b([ud objectForKey:@"scanTagTitle"]) scanForTag:@"title"]; - [model enable:n2b([ud objectForKey:@"scanTagGenre"]) scanForTag:@"genre"]; - [model enable:n2b([ud objectForKey:@"scanTagYear"]) scanForTag:@"year"]; - [model setMinMatchPercentage:n2i([ud objectForKey:@"minMatchPercentage"])]; - [model setWordWeighting:n2b([ud objectForKey:@"wordWeighting"])]; - [model setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])]; - [model setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])]; - [model setMatchSimilarWords:n2b([ud objectForKey:@"matchSimilarWords"])]; -} - -- (void)initResultColumns -{ - HSColumnDef defs[] = { - {@"marked", 26, 26, 26, YES, [NSButtonCell class]}, - {@"name", 235, 16, 0, YES, nil}, - {@"folder_path", 120, 16, 0, YES, nil}, - {@"size", 63, 16, 0, YES, nil}, - {@"duration", 50, 16, 0, YES, nil}, - {@"bitrate", 50, 16, 0, YES, nil}, - {@"samplerate", 60, 16, 0, YES, nil}, - {@"extension", 40, 16, 0, YES, nil}, - {@"mtime", 120, 16, 0, YES, nil}, - {@"title", 120, 16, 0, YES, nil}, - {@"artist", 120, 16, 0, YES, nil}, - {@"album", 120, 16, 0, YES, nil}, - {@"genre", 80, 16, 0, YES, nil}, - {@"year", 40, 16, 0, YES, nil}, - {@"track", 40, 16, 0, YES, nil}, - {@"comment", 120, 16, 0, YES, nil}, - {@"percentage", 57, 16, 0, YES, nil}, - {@"words", 120, 16, 0, YES, nil}, - {@"dupe_count", 80, 16, 0, YES, nil}, - nil - }; - [[table columns] initializeColumns:defs]; - NSTableColumn *c = [matches tableColumnWithIdentifier:@"marked"]; - [[c dataCell] setButtonType:NSSwitchButton]; - [[c dataCell] setControlSize:NSSmallControlSize]; - c = [matches tableColumnWithIdentifier:@"size"]; - [[c dataCell] setAlignment:NSRightTextAlignment]; - c = [matches tableColumnWithIdentifier:@"duration"]; - [[c dataCell] setAlignment:NSRightTextAlignment]; - c = [matches tableColumnWithIdentifier:@"bitrate"]; - [[c dataCell] setAlignment:NSRightTextAlignment]; - [[table columns] restoreColumns]; -} -@end diff --git a/cocoa/pe/AppDelegate.m b/cocoa/pe/AppDelegate.m index d8a1ad50..8c20946d 100644 --- a/cocoa/pe/AppDelegate.m +++ b/cocoa/pe/AppDelegate.m @@ -9,6 +9,7 @@ http://www.gnu.org/licenses/gpl-3.0.html #import "AppDelegate.h" #import "ProgressController.h" #import "Utils.h" +#import "Dialogs.h" #import "ValueTransformers.h" #import "Consts.h" #import "DetailsPanel.h" @@ -38,18 +39,50 @@ http://www.gnu.org/licenses/gpl-3.0.html return @"https://www.hardcoded.net/dupeguru_pe/"; } -- (ResultWindowBase *)createResultWindow -{ - return [[ResultWindow alloc] initWithParentApp:self]; -} - - (DetailsPanel *)createDetailsPanel { return [[DetailsPanel alloc] initWithApp:model]; } +- (void)setScanOptions +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [model setScanType:n2i([ud objectForKey:@"scanType"])]; + [model setMinMatchPercentage:n2i([ud objectForKey:@"minMatchPercentage"])]; + [model setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])]; + [model setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])]; + [model setMatchScaled:n2b([ud objectForKey:@"matchScaled"])]; +} + +- (void)initResultColumns:(ResultTable *)aTable +{ + HSColumnDef defs[] = { + {@"marked", 26, 26, 26, YES, [NSButtonCell class]}, + {@"name", 162, 16, 0, YES, nil}, + {@"folder_path", 142, 16, 0, YES, nil}, + {@"size", 63, 16, 0, YES, nil}, + {@"extension", 40, 16, 0, YES, nil}, + {@"dimensions", 73, 16, 0, YES, nil}, + {@"exif_timestamp", 120, 16, 0, YES, nil}, + {@"mtime", 120, 16, 0, YES, nil}, + {@"percentage", 58, 16, 0, YES, nil}, + {@"dupe_count", 80, 16, 0, YES, nil}, + nil + }; + [[aTable columns] initializeColumns:defs]; + NSTableColumn *c = [[aTable view] tableColumnWithIdentifier:@"marked"]; + [[c dataCell] setButtonType:NSSwitchButton]; + [[c dataCell] setControlSize:NSSmallControlSize]; + c = [[aTable view] tableColumnWithIdentifier:@"size"]; + [[c dataCell] setAlignment:NSRightTextAlignment]; + [[aTable columns] restoreColumns]; +} + - (void)clearPictureCache { - [(ResultWindow *)[self resultWindow] clearPictureCache]; + NSString *msg = NSLocalizedString(@"Do you really want to remove all your cached picture analysis?", @""); + if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) // NO + return; + [model clearPictureCache]; } @end diff --git a/cocoa/pe/ResultWindow.h b/cocoa/pe/ResultWindow.h deleted file mode 100644 index baf18a9b..00000000 --- a/cocoa/pe/ResultWindow.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) - -This software is licensed under the "GPLv3" License as described in the "LICENSE" file, -which should be included with this package. The terms are also available at -http://www.gnu.org/licenses/gpl-3.0.html -*/ - -#import -#import "ResultWindowBase.h" - -@interface ResultWindow : ResultWindowBase {} -- (void)clearPictureCache; -@end diff --git a/cocoa/pe/ResultWindow.m b/cocoa/pe/ResultWindow.m deleted file mode 100644 index 0dec7ab8..00000000 --- a/cocoa/pe/ResultWindow.m +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) - -This software is licensed under the "GPLv3" License as described in the "LICENSE" file, -which should be included with this package. The terms are also available at -http://www.gnu.org/licenses/gpl-3.0.html -*/ - -#import "ResultWindow.h" -#import "Dialogs.h" -#import "Utils.h" -#import "PyDupeGuru.h" - -@implementation ResultWindow -/* Override */ -- (void)initResultColumns -{ - HSColumnDef defs[] = { - {@"marked", 26, 26, 26, YES, [NSButtonCell class]}, - {@"name", 162, 16, 0, YES, nil}, - {@"folder_path", 142, 16, 0, YES, nil}, - {@"size", 63, 16, 0, YES, nil}, - {@"extension", 40, 16, 0, YES, nil}, - {@"dimensions", 73, 16, 0, YES, nil}, - {@"exif_timestamp", 120, 16, 0, YES, nil}, - {@"mtime", 120, 16, 0, YES, nil}, - {@"percentage", 58, 16, 0, YES, nil}, - {@"dupe_count", 80, 16, 0, YES, nil}, - nil - }; - [[table columns] initializeColumns:defs]; - NSTableColumn *c = [matches tableColumnWithIdentifier:@"marked"]; - [[c dataCell] setButtonType:NSSwitchButton]; - [[c dataCell] setControlSize:NSSmallControlSize]; - c = [matches tableColumnWithIdentifier:@"size"]; - [[c dataCell] setAlignment:NSRightTextAlignment]; - [[table columns] restoreColumns]; -} - -- (void)setScanOptions -{ - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - [model setScanType:n2i([ud objectForKey:@"scanType"])]; - [model setMinMatchPercentage:n2i([ud objectForKey:@"minMatchPercentage"])]; - [model setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])]; - [model setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])]; - [model setMatchScaled:n2b([ud objectForKey:@"matchScaled"])]; -} - -/* Actions */ -- (void)clearPictureCache -{ - NSString *msg = NSLocalizedString(@"Do you really want to remove all your cached picture analysis?", @""); - if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) // NO - return; - [model clearPictureCache]; -} -@end \ No newline at end of file diff --git a/cocoa/se/AppDelegate.m b/cocoa/se/AppDelegate.m index 91e2a001..7f666fe0 100644 --- a/cocoa/se/AppDelegate.m +++ b/cocoa/se/AppDelegate.m @@ -45,8 +45,41 @@ http://www.gnu.org/licenses/gpl-3.0.html return @"http://www.hardcoded.net/dupeguru/"; } -- (ResultWindowBase *)createResultWindow +- (void)setScanOptions { - return [[ResultWindow alloc] initWithParentApp:self]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [model setScanType:n2i([ud objectForKey:@"scanType"])]; + [model setMinMatchPercentage:n2i([ud objectForKey:@"minMatchPercentage"])]; + [model setWordWeighting:n2b([ud objectForKey:@"wordWeighting"])]; + [model setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])]; + [model setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])]; + [model setMatchSimilarWords:n2b([ud objectForKey:@"matchSimilarWords"])]; + int smallFileThreshold = [ud integerForKey:@"smallFileThreshold"]; // In KB + int sizeThreshold = [ud boolForKey:@"ignoreSmallFiles"] ? smallFileThreshold * 1024 : 0; // The py side wants bytes + [model setSizeThreshold:sizeThreshold]; } + +- (void)initResultColumns:(ResultTable *)aTable +{ + HSColumnDef defs[] = { + {@"marked", 26, 26, 26, YES, [NSButtonCell class]}, + {@"name", 195, 16, 0, YES, nil}, + {@"folder_path", 183, 16, 0, YES, nil}, + {@"size", 63, 16, 0, YES, nil}, + {@"extension", 40, 16, 0, YES, nil}, + {@"mtime", 120, 16, 0, YES, nil}, + {@"percentage", 60, 16, 0, YES, nil}, + {@"words", 120, 16, 0, YES, nil}, + {@"dupe_count", 80, 16, 0, YES, nil}, + nil + }; + [[aTable columns] initializeColumns:defs]; + NSTableColumn *c = [[aTable view] tableColumnWithIdentifier:@"marked"]; + [[c dataCell] setButtonType:NSSwitchButton]; + [[c dataCell] setControlSize:NSSmallControlSize]; + c = [[aTable view] tableColumnWithIdentifier:@"size"]; + [[c dataCell] setAlignment:NSRightTextAlignment]; + [[aTable columns] restoreColumns]; +} + @end diff --git a/cocoa/se/ResultWindow.h b/cocoa/se/ResultWindow.h deleted file mode 100644 index 707edb5b..00000000 --- a/cocoa/se/ResultWindow.h +++ /dev/null @@ -1,13 +0,0 @@ -/* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) - -This software is licensed under the "GPLv3" License as described in the "LICENSE" file, -which should be included with this package. The terms are also available at -http://www.gnu.org/licenses/gpl-3.0.html -*/ - -#import -#import "ResultWindowBase.h" - -@interface ResultWindow : ResultWindowBase {} -@end diff --git a/cocoa/se/ResultWindow.m b/cocoa/se/ResultWindow.m deleted file mode 100644 index 39da66d7..00000000 --- a/cocoa/se/ResultWindow.m +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) - -This software is licensed under the "GPLv3" License as described in the "LICENSE" file, -which should be included with this package. The terms are also available at -http://www.gnu.org/licenses/gpl-3.0.html -*/ - -#import "ResultWindow.h" -#import "Utils.h" -#import "Consts.h" -#import "PyDupeGuru.h" - -@implementation ResultWindow -/* Override */ -- (void)initResultColumns -{ - HSColumnDef defs[] = { - {@"marked", 26, 26, 26, YES, [NSButtonCell class]}, - {@"name", 195, 16, 0, YES, nil}, - {@"folder_path", 183, 16, 0, YES, nil}, - {@"size", 63, 16, 0, YES, nil}, - {@"extension", 40, 16, 0, YES, nil}, - {@"mtime", 120, 16, 0, YES, nil}, - {@"percentage", 60, 16, 0, YES, nil}, - {@"words", 120, 16, 0, YES, nil}, - {@"dupe_count", 80, 16, 0, YES, nil}, - nil - }; - [[table columns] initializeColumns:defs]; - NSTableColumn *c = [matches tableColumnWithIdentifier:@"marked"]; - [[c dataCell] setButtonType:NSSwitchButton]; - [[c dataCell] setControlSize:NSSmallControlSize]; - c = [matches tableColumnWithIdentifier:@"size"]; - [[c dataCell] setAlignment:NSRightTextAlignment]; - [[table columns] restoreColumns]; -} - -- (void)setScanOptions -{ - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - [model setScanType:n2i([ud objectForKey:@"scanType"])]; - [model setMinMatchPercentage:n2i([ud objectForKey:@"minMatchPercentage"])]; - [model setWordWeighting:n2b([ud objectForKey:@"wordWeighting"])]; - [model setMixFileKind:n2b([ud objectForKey:@"mixFileKind"])]; - [model setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])]; - [model setMatchSimilarWords:n2b([ud objectForKey:@"matchSimilarWords"])]; - int smallFileThreshold = [ud integerForKey:@"smallFileThreshold"]; // In KB - int sizeThreshold = [ud boolForKey:@"ignoreSmallFiles"] ? smallFileThreshold * 1024 : 0; // The py side wants bytes - [model setSizeThreshold:sizeThreshold]; -} -@end