2009-08-05 08:59:46 +00:00
|
|
|
/*
|
2015-01-03 21:30:57 +00:00
|
|
|
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
2009-08-05 08:59:46 +00:00
|
|
|
|
2015-01-03 21:33:16 +00:00
|
|
|
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2009-08-05 08:59:46 +00:00
|
|
|
which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
http://www.gnu.org/licenses/gpl-3.0.html
|
2009-08-05 08:59:46 +00:00
|
|
|
*/
|
|
|
|
|
2016-06-06 01:18:48 +00:00
|
|
|
#import "AppDelegate.h"
|
2009-06-01 09:55:11 +00:00
|
|
|
#import "ProgressController.h"
|
2012-05-28 18:45:13 +00:00
|
|
|
#import "HSPyUtil.h"
|
2009-06-01 09:55:11 +00:00
|
|
|
#import "Consts.h"
|
2011-01-13 15:20:03 +00:00
|
|
|
#import "Dialogs.h"
|
2012-07-31 14:27:36 +00:00
|
|
|
#import "Utils.h"
|
2011-09-23 13:14:16 +00:00
|
|
|
#import "ValueTransformers.h"
|
2016-06-06 01:18:48 +00:00
|
|
|
#import "DetailsPanelPicture.h"
|
|
|
|
#import "PreferencesPanelStandard_UI.h"
|
|
|
|
#import "PreferencesPanelMusic_UI.h"
|
|
|
|
#import "PreferencesPanelPicture_UI.h"
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2016-06-06 01:18:48 +00:00
|
|
|
@implementation AppDelegate
|
2012-07-27 22:30:34 +00:00
|
|
|
|
|
|
|
@synthesize recentResultsMenu;
|
|
|
|
@synthesize columnsMenu;
|
|
|
|
@synthesize updater;
|
|
|
|
|
2012-07-31 14:27:36 +00:00
|
|
|
+ (NSDictionary *)defaultPreferences
|
|
|
|
{
|
|
|
|
NSMutableDictionary *d = [NSMutableDictionary dictionary];
|
2016-06-06 01:18:48 +00:00
|
|
|
[d setObject:i2n(1) forKey:@"scanTypeStandard"];
|
|
|
|
[d setObject:i2n(3) forKey:@"scanTypeMusic"];
|
|
|
|
[d setObject:i2n(0) forKey:@"scanTypePicture"];
|
|
|
|
[d setObject:i2n(95) forKey:@"minMatchPercentage"];
|
|
|
|
[d setObject:i2n(30) forKey:@"smallFileThreshold"];
|
|
|
|
[d setObject:b2n(YES) forKey:@"wordWeighting"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"matchSimilarWords"];
|
|
|
|
[d setObject:b2n(YES) forKey:@"ignoreSmallFiles"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"scanTagTrack"];
|
|
|
|
[d setObject:b2n(YES) forKey:@"scanTagArtist"];
|
|
|
|
[d setObject:b2n(YES) forKey:@"scanTagAlbum"];
|
|
|
|
[d setObject:b2n(YES) forKey:@"scanTagTitle"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"scanTagGenre"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"scanTagYear"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"matchScaled"];
|
2012-07-31 14:27:36 +00:00
|
|
|
[d setObject:i2n(1) forKey:@"recreatePathType"];
|
|
|
|
[d setObject:i2n(11) forKey:TableFontSize];
|
|
|
|
[d setObject:b2n(YES) forKey:@"mixFileKind"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"useRegexpFilter"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"ignoreHardlinkMatches"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"removeEmptyFolders"];
|
|
|
|
[d setObject:b2n(NO) forKey:@"DebugMode"];
|
|
|
|
[d setObject:@"" forKey:@"CustomCommand"];
|
|
|
|
[d setObject:[NSArray array] forKey:@"recentDirectories"];
|
|
|
|
[d setObject:[NSArray array] forKey:@"columnsOrder"];
|
|
|
|
[d setObject:[NSDictionary dictionary] forKey:@"columnsWidth"];
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2011-09-23 13:14:16 +00:00
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
HSVTAdd *vt = [[[HSVTAdd alloc] initWithValue:4] autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:vt forName:@"vtRowHeightOffset"];
|
2012-07-31 14:27:36 +00:00
|
|
|
NSDictionary *d = [self defaultPreferences];
|
|
|
|
[[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:d];
|
|
|
|
[[NSUserDefaults standardUserDefaults] registerDefaults:d];
|
2011-09-23 13:14:16 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (id)init
|
2011-01-13 15:20:03 +00:00
|
|
|
{
|
2012-07-27 22:30:34 +00:00
|
|
|
self = [super init];
|
2012-01-13 19:43:43 +00:00
|
|
|
model = [[PyDupeGuru alloc] init];
|
2012-01-13 22:02:41 +00:00
|
|
|
[model bindCallback:createCallback(@"DupeGuruView", self)];
|
2012-07-27 22:30:34 +00:00
|
|
|
[self setUpdater:[SUUpdater sharedUpdater]];
|
2016-06-06 01:18:48 +00:00
|
|
|
NSMutableIndexSet *contentsIndexes = [NSMutableIndexSet indexSet];
|
|
|
|
[contentsIndexes addIndex:1];
|
|
|
|
[contentsIndexes addIndex:2];
|
|
|
|
VTIsIntIn *vt = [[[VTIsIntIn alloc] initWithValues:contentsIndexes reverse:YES] autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:vt forName:@"vtScanTypeIsNotContent"];
|
|
|
|
NSMutableIndexSet *i = [NSMutableIndexSet indexSetWithIndex:0];
|
|
|
|
VTIsIntIn *vtScanTypeIsFuzzy = [[[VTIsIntIn alloc] initWithValues:i reverse:NO] autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:vtScanTypeIsFuzzy forName:@"vtScanTypeIsFuzzy"];
|
|
|
|
i = [NSMutableIndexSet indexSetWithIndex:4];
|
|
|
|
VTIsIntIn *vtScanTypeIsNotContent = [[[VTIsIntIn alloc] initWithValues:i reverse:YES] autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:vtScanTypeIsNotContent forName:@"vtScanTypeMusicIsNotContent"];
|
|
|
|
VTIsIntIn *vtScanTypeIsTag = [[[VTIsIntIn alloc] initWithValues:[NSIndexSet indexSetWithIndex:3] reverse:NO] autorelease];
|
|
|
|
[NSValueTransformer setValueTransformer:vtScanTypeIsTag forName:@"vtScanTypeIsTag"];
|
2012-07-27 22:30:34 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)finalizeInit
|
|
|
|
{
|
|
|
|
// We can only finalize initialization once the main menu has been created, which cannot happen
|
|
|
|
// before AppDelegate is created.
|
2011-01-23 11:47:21 +00:00
|
|
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
|
|
|
/* Because the pref pane is lazily loaded, we have to manually do the update check if the
|
|
|
|
preference is set.
|
|
|
|
*/
|
|
|
|
if ([ud boolForKey:@"SUEnableAutomaticChecks"]) {
|
|
|
|
[[SUUpdater sharedUpdater] checkForUpdatesInBackground];
|
|
|
|
}
|
2011-01-13 15:20:03 +00:00
|
|
|
_recentResults = [[HSRecentFiles alloc] initWithName:@"recentResults" menu:recentResultsMenu];
|
|
|
|
[_recentResults setDelegate:self];
|
2016-06-05 01:18:14 +00:00
|
|
|
_directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self];
|
2012-03-14 16:47:21 +00:00
|
|
|
_ignoreListDialog = [[IgnoreListDialog alloc] initWithPyRef:[model ignoreListDialog]];
|
2016-06-06 01:18:48 +00:00
|
|
|
_problemDialog = [[ProblemDialog alloc] initWithPyRef:[model problemDialog]];
|
|
|
|
_deletionOptions = [[DeletionOptions alloc] initWithPyRef:[model deletionOptions]];
|
2013-08-03 20:27:36 +00:00
|
|
|
_progressWindow = [[HSProgressWindow alloc] initWithPyRef:[[self model] progressWindow] view:nil];
|
2016-06-05 01:18:14 +00:00
|
|
|
[_progressWindow setParentWindow:[_directoryPanel window]];
|
2016-06-06 01:18:48 +00:00
|
|
|
// Lazily loaded
|
|
|
|
_aboutBox = nil;
|
|
|
|
_preferencesPanel = nil;
|
|
|
|
_resultWindow = nil;
|
|
|
|
_detailsPanel = nil;
|
2011-01-14 13:41:43 +00:00
|
|
|
[[[self directoryPanel] window] makeKeyAndOrderFront:self];
|
2011-01-13 15:20:03 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 12:56:50 +00:00
|
|
|
/* Virtual */
|
|
|
|
|
2012-01-13 19:43:43 +00:00
|
|
|
- (PyDupeGuru *)model
|
|
|
|
{
|
|
|
|
return model;
|
|
|
|
}
|
2011-01-14 12:56:50 +00:00
|
|
|
|
2016-06-05 01:18:14 +00:00
|
|
|
- (DetailsPanel *)createDetailsPanel
|
2011-01-14 12:56:50 +00:00
|
|
|
{
|
2016-06-06 01:18:48 +00:00
|
|
|
NSInteger appMode = [self getAppMode];
|
|
|
|
if (appMode == AppModePicture) {
|
2016-06-06 15:03:09 +00:00
|
|
|
return [[DetailsPanelPicture alloc] initWithApp:model];
|
2016-06-06 01:18:48 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return [[DetailsPanel alloc] initWithPyRef:[model detailsPanel]];
|
|
|
|
}
|
2011-01-14 12:56:50 +00:00
|
|
|
}
|
|
|
|
|
2016-06-05 01:18:14 +00:00
|
|
|
- (void)setScanOptions
|
2011-01-14 12:56:50 +00:00
|
|
|
{
|
2016-06-06 01:18:48 +00:00
|
|
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSString *scanTypeOptionName;
|
|
|
|
NSInteger appMode = [self getAppMode];
|
|
|
|
if (appMode == AppModePicture) {
|
|
|
|
scanTypeOptionName = @"scanTypePicture";
|
|
|
|
}
|
|
|
|
else if (appMode == AppModeMusic) {
|
|
|
|
scanTypeOptionName = @"scanTypeMusic";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
scanTypeOptionName = @"scanTypeStandard";
|
|
|
|
}
|
|
|
|
[model setScanType:n2i([ud objectForKey:scanTypeOptionName])];
|
|
|
|
[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];
|
|
|
|
[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 setMatchScaled:n2b([ud objectForKey:@"matchScaled"])];
|
2011-01-14 12:56:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Public */
|
2016-06-05 01:18:14 +00:00
|
|
|
- (ResultWindow *)resultWindow
|
2011-01-14 12:56:50 +00:00
|
|
|
{
|
|
|
|
return _resultWindow;
|
|
|
|
}
|
|
|
|
|
2010-02-05 16:05:00 +00:00
|
|
|
- (DirectoryPanel *)directoryPanel
|
|
|
|
{
|
|
|
|
return _directoryPanel;
|
|
|
|
}
|
|
|
|
|
2010-02-05 16:15:45 +00:00
|
|
|
- (DetailsPanel *)detailsPanel
|
|
|
|
{
|
|
|
|
return _detailsPanel;
|
|
|
|
}
|
2009-10-30 14:40:17 +00:00
|
|
|
|
2011-01-13 15:20:03 +00:00
|
|
|
- (HSRecentFiles *)recentResults
|
2010-02-05 15:51:00 +00:00
|
|
|
{
|
2011-01-13 15:20:03 +00:00
|
|
|
return _recentResults;
|
|
|
|
}
|
|
|
|
|
2016-06-06 01:18:48 +00:00
|
|
|
- (NSInteger)getAppMode
|
|
|
|
{
|
|
|
|
return [model getAppMode];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAppMode:(NSInteger)appMode
|
|
|
|
{
|
|
|
|
[model setAppMode:appMode];
|
|
|
|
if (_preferencesPanel != nil) {
|
|
|
|
[_preferencesPanel release];
|
|
|
|
_preferencesPanel = nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 12:56:50 +00:00
|
|
|
/* Actions */
|
2016-06-06 01:18:48 +00:00
|
|
|
- (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];
|
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)loadResults
|
2010-12-30 12:00:44 +00:00
|
|
|
{
|
2011-01-14 14:34:10 +00:00
|
|
|
NSOpenPanel *op = [NSOpenPanel openPanel];
|
|
|
|
[op setCanChooseFiles:YES];
|
|
|
|
[op setCanChooseDirectories:NO];
|
|
|
|
[op setCanCreateDirectories:NO];
|
|
|
|
[op setAllowsMultipleSelection:NO];
|
|
|
|
[op setAllowedFileTypes:[NSArray arrayWithObject:@"dupeguru"]];
|
2012-08-01 20:34:12 +00:00
|
|
|
[op setTitle:NSLocalizedString(@"Select a results file to load", @"")];
|
2011-01-14 14:34:10 +00:00
|
|
|
if ([op runModal] == NSOKButton) {
|
2013-11-10 17:41:10 +00:00
|
|
|
NSString *filename = [[[op URLs] objectAtIndex:0] path];
|
2012-01-13 19:43:43 +00:00
|
|
|
[model loadResultsFrom:filename];
|
2011-01-14 14:34:10 +00:00
|
|
|
[[self recentResults] addFile:filename];
|
2010-12-30 12:00:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)openWebsite
|
2011-01-12 16:30:57 +00:00
|
|
|
{
|
2016-06-06 01:18:48 +00:00
|
|
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.hardcoded.net/dupeguru/"]];
|
2011-01-12 16:30:57 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)openHelp
|
2011-01-12 16:30:57 +00:00
|
|
|
{
|
|
|
|
NSBundle *b = [NSBundle mainBundle];
|
|
|
|
NSString *p = [b pathForResource:@"index" ofType:@"html" inDirectory:@"help"];
|
|
|
|
NSURL *u = [NSURL fileURLWithPath:p];
|
|
|
|
[[NSWorkspace sharedWorkspace] openURL:u];
|
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)showAboutBox
|
2011-01-14 14:34:10 +00:00
|
|
|
{
|
|
|
|
if (_aboutBox == nil) {
|
2013-11-30 22:54:40 +00:00
|
|
|
_aboutBox = [[HSAboutBox alloc] initWithApp:model];
|
2011-01-14 14:34:10 +00:00
|
|
|
}
|
2012-07-27 22:30:34 +00:00
|
|
|
[[_aboutBox window] makeKeyAndOrderFront:nil];
|
2011-01-14 14:34:10 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)showDirectoryWindow
|
2011-01-14 14:34:10 +00:00
|
|
|
{
|
|
|
|
[[[self directoryPanel] window] makeKeyAndOrderFront:nil];
|
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)showPreferencesPanel
|
2011-01-14 13:06:54 +00:00
|
|
|
{
|
|
|
|
if (_preferencesPanel == nil) {
|
2016-06-06 01:18:48 +00:00
|
|
|
NSWindow *window;
|
|
|
|
NSInteger appMode = [model getAppMode];
|
|
|
|
if (appMode == AppModePicture) {
|
|
|
|
window = createPreferencesPanelPicture_UI(nil);
|
|
|
|
}
|
|
|
|
else if (appMode == AppModeMusic) {
|
|
|
|
window = createPreferencesPanelMusic_UI(nil);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window = createPreferencesPanelStandard_UI(nil);
|
|
|
|
}
|
|
|
|
_preferencesPanel = [[NSWindowController alloc] initWithWindow:window];
|
2011-01-14 13:06:54 +00:00
|
|
|
}
|
2012-07-27 22:30:34 +00:00
|
|
|
[_preferencesPanel showWindow:nil];
|
2011-01-14 13:06:54 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)showResultWindow
|
2011-01-14 13:41:43 +00:00
|
|
|
{
|
2011-01-14 14:34:10 +00:00
|
|
|
[[[self resultWindow] window] makeKeyAndOrderFront:nil];
|
2011-01-14 13:41:43 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)showIgnoreList
|
2012-03-14 16:47:21 +00:00
|
|
|
{
|
|
|
|
[model showIgnoreList];
|
|
|
|
}
|
|
|
|
|
2012-07-27 22:30:34 +00:00
|
|
|
- (void)startScanning
|
2011-01-13 15:20:03 +00:00
|
|
|
{
|
2016-06-05 01:18:14 +00:00
|
|
|
[[self directoryPanel] startDuplicateScan];
|
2011-01-13 15:20:03 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:34:10 +00:00
|
|
|
|
2009-10-30 14:40:17 +00:00
|
|
|
/* Delegate */
|
|
|
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
|
|
|
{
|
2012-01-13 19:43:43 +00:00
|
|
|
[model loadSession];
|
2009-10-30 14:40:17 +00:00
|
|
|
}
|
2010-02-05 15:31:09 +00:00
|
|
|
|
|
|
|
- (void)applicationWillBecomeActive:(NSNotification *)aNotification
|
|
|
|
{
|
2011-01-14 13:41:43 +00:00
|
|
|
if (![[[self directoryPanel] window] isVisible]) {
|
|
|
|
[[self directoryPanel] showWindow:NSApp];
|
|
|
|
}
|
2010-02-05 15:31:09 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 15:20:03 +00:00
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
|
|
|
{
|
2012-01-13 19:43:43 +00:00
|
|
|
if ([model resultsAreModified]) {
|
2012-08-01 20:34:12 +00:00
|
|
|
NSString *msg = NSLocalizedString(@"You have unsaved results, do you really want to quit?", @"");
|
2011-01-13 15:20:03 +00:00
|
|
|
if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) { // NO
|
|
|
|
return NSTerminateCancel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NSTerminateNow;
|
|
|
|
}
|
|
|
|
|
2010-02-05 15:31:09 +00:00
|
|
|
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSInteger sc = [ud integerForKey:@"sessionCountSinceLastIgnorePurge"];
|
2011-01-13 15:20:03 +00:00
|
|
|
if (sc >= 10) {
|
2010-02-05 15:31:09 +00:00
|
|
|
sc = -1;
|
2012-01-13 19:43:43 +00:00
|
|
|
[model purgeIgnoreList];
|
2010-02-05 15:31:09 +00:00
|
|
|
}
|
|
|
|
sc++;
|
2012-01-13 19:43:43 +00:00
|
|
|
[model saveSession];
|
2010-02-05 15:31:09 +00:00
|
|
|
[ud setInteger:sc forKey:@"sessionCountSinceLastIgnorePurge"];
|
|
|
|
// NSApplication does not release nib instances objects, we must do it manually
|
|
|
|
// Well, it isn't needed because the memory is freed anyway (we are quitting the application
|
2011-01-13 15:20:03 +00:00
|
|
|
// But I need to release HSRecentFiles so it saves the user defaults
|
|
|
|
[_directoryPanel release];
|
|
|
|
[_recentResults release];
|
2010-02-05 15:31:09 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 15:20:03 +00:00
|
|
|
- (void)recentFileClicked:(NSString *)path
|
2010-02-05 15:51:00 +00:00
|
|
|
{
|
2012-01-13 19:43:43 +00:00
|
|
|
[model loadResultsFrom:path];
|
2010-02-05 15:51:00 +00:00
|
|
|
}
|
2011-03-05 12:03:23 +00:00
|
|
|
|
2011-09-21 19:24:26 +00:00
|
|
|
|
|
|
|
/* model --> view */
|
2011-09-22 14:35:17 +00:00
|
|
|
- (void)showMessage:(NSString *)msg
|
|
|
|
{
|
|
|
|
[Dialogs showMessage:msg];
|
|
|
|
}
|
2011-09-24 20:21:20 +00:00
|
|
|
|
2012-03-09 16:34:08 +00:00
|
|
|
- (BOOL)askYesNoWithPrompt:(NSString *)prompt
|
|
|
|
{
|
|
|
|
return [Dialogs askYesNo:prompt] == NSAlertFirstButtonReturn;
|
|
|
|
}
|
|
|
|
|
2016-06-06 01:18:48 +00:00
|
|
|
- (void)createResultsWindow
|
|
|
|
{
|
|
|
|
if (_resultWindow != nil) {
|
|
|
|
[_resultWindow release];
|
|
|
|
}
|
|
|
|
if (_detailsPanel != nil) {
|
|
|
|
[_detailsPanel release];
|
|
|
|
}
|
|
|
|
_resultWindow = [[ResultWindow alloc] initWithParentApp:self];
|
|
|
|
_detailsPanel = [self createDetailsPanel];
|
|
|
|
}
|
2016-06-05 01:18:14 +00:00
|
|
|
- (void)showResultsWindow
|
|
|
|
{
|
|
|
|
[[[self resultWindow] window] makeKeyAndOrderFront:nil];
|
|
|
|
}
|
|
|
|
|
2012-03-09 18:47:28 +00:00
|
|
|
- (void)showProblemDialog
|
|
|
|
{
|
2016-06-06 01:18:48 +00:00
|
|
|
[_problemDialog showWindow:self];
|
2012-03-09 18:47:28 +00:00
|
|
|
}
|
|
|
|
|
2012-03-10 19:32:56 +00:00
|
|
|
- (NSString *)selectDestFolderWithPrompt:(NSString *)prompt
|
|
|
|
{
|
|
|
|
NSOpenPanel *op = [NSOpenPanel openPanel];
|
|
|
|
[op setCanChooseFiles:NO];
|
|
|
|
[op setCanChooseDirectories:YES];
|
|
|
|
[op setCanCreateDirectories:YES];
|
|
|
|
[op setAllowsMultipleSelection:NO];
|
|
|
|
[op setTitle:prompt];
|
|
|
|
if ([op runModal] == NSOKButton) {
|
2013-11-10 17:41:10 +00:00
|
|
|
return [[[op URLs] objectAtIndex:0] path];
|
2012-03-10 19:32:56 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-31 20:46:51 +00:00
|
|
|
- (NSString *)selectDestFileWithPrompt:(NSString *)prompt extension:(NSString *)extension
|
|
|
|
{
|
|
|
|
NSSavePanel *sp = [NSSavePanel savePanel];
|
|
|
|
[sp setCanCreateDirectories:YES];
|
|
|
|
[sp setAllowedFileTypes:[NSArray arrayWithObject:extension]];
|
|
|
|
[sp setTitle:prompt];
|
|
|
|
if ([sp runModal] == NSOKButton) {
|
2013-11-10 17:41:10 +00:00
|
|
|
return [[sp URL] path];
|
2012-07-31 20:46:51 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
@end
|