mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 22:51:39 +00:00
Pushed some action confirmation logic down from GUI layers to the core.
This commit is contained in:
@@ -237,4 +237,21 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
{
|
||||
[HSFairwareReminder showDemoNagWithApp:[self model] prompt:prompt];
|
||||
}
|
||||
|
||||
- (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) {
|
||||
return [[op filenames] objectAtIndex:0];
|
||||
}
|
||||
else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -75,17 +75,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
- (void)sendMarkedToTrash:(BOOL)hardlinkDeleted
|
||||
{
|
||||
NSInteger mark_count = [model getMarkCount];
|
||||
if (!mark_count) {
|
||||
return;
|
||||
}
|
||||
NSString *msg = TR(@"You are about to send %d files to Trash. Continue?");
|
||||
if (hardlinkDeleted) {
|
||||
msg = TR(@"You are about to send %d files to Trash (and hardlink them afterwards). Continue?");
|
||||
}
|
||||
if ([Dialogs askYesNo:[NSString stringWithFormat:msg,mark_count]] == NSAlertSecondButtonReturn) { // NO
|
||||
return;
|
||||
}
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
[model setRemoveEmptyFolders:n2b([ud objectForKey:@"removeEmptyFolders"])];
|
||||
if (hardlinkDeleted) {
|
||||
@@ -130,20 +119,10 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
- (IBAction)copyMarked:(id)sender
|
||||
{
|
||||
NSInteger mark_count = [model getMarkCount];
|
||||
if (!mark_count)
|
||||
return;
|
||||
NSOpenPanel *op = [NSOpenPanel openPanel];
|
||||
[op setCanChooseFiles:NO];
|
||||
[op setCanChooseDirectories:YES];
|
||||
[op setCanCreateDirectories:YES];
|
||||
[op setAllowsMultipleSelection:NO];
|
||||
[op setTitle:TR(@"Select a directory to copy marked files to")];
|
||||
if ([op runModal] == NSOKButton) {
|
||||
NSString *directory = [[op filenames] objectAtIndex:0];
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
[model copyOrMove:YES markedTo:directory recreatePath:n2b([ud objectForKey:@"recreatePathType"])];
|
||||
}
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
[model setRemoveEmptyFolders:n2b([ud objectForKey:@"removeEmptyFolders"])];
|
||||
[model setCopyMoveDestType:n2i([ud objectForKey:@"recreatePathType"])];
|
||||
[model copyMarked];
|
||||
}
|
||||
|
||||
- (IBAction)deleteMarked:(id)sender
|
||||
@@ -201,21 +180,10 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
- (IBAction)moveMarked:(id)sender
|
||||
{
|
||||
NSInteger mark_count = [model getMarkCount];
|
||||
if (!mark_count)
|
||||
return;
|
||||
NSOpenPanel *op = [NSOpenPanel openPanel];
|
||||
[op setCanChooseFiles:NO];
|
||||
[op setCanChooseDirectories:YES];
|
||||
[op setCanCreateDirectories:YES];
|
||||
[op setAllowsMultipleSelection:NO];
|
||||
[op setTitle:TR(@"Select a directory to move marked files to")];
|
||||
if ([op runModal] == NSOKButton) {
|
||||
NSString *directory = [[op filenames] objectAtIndex:0];
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
[model setRemoveEmptyFolders:n2b([ud objectForKey:@"removeEmptyFolders"])];
|
||||
[model copyOrMove:NO markedTo:directory recreatePath:n2b([ud objectForKey:@"recreatePathType"])];
|
||||
}
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
[model setRemoveEmptyFolders:n2b([ud objectForKey:@"removeEmptyFolders"])];
|
||||
[model setCopyMoveDestType:n2i([ud objectForKey:@"recreatePathType"])];
|
||||
[model moveMarked];
|
||||
}
|
||||
|
||||
- (IBAction)openClicked:(id)sender
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
|
||||
"Select a results file to load" = "Select a results file to load";
|
||||
"You have unsaved results, do you really want to quit?" = "You have unsaved results, do you really want to quit?";
|
||||
"Select a directory to copy marked files to" = "Select a directory to copy marked files to";
|
||||
"Select a directory to move marked files to" = "Select a directory to move marked files to";
|
||||
"Select a file to save your results to" = "Select a file to save your results to";
|
||||
"Select a folder to add to the scanning list" = "Select a folder to add to the scanning list";
|
||||
"You have unsaved results, do you really want to continue?" = "You have unsaved results, do you really want to continue?";
|
||||
"'%@' already is in the list." = "'%@' already is in the list.";
|
||||
"'%@' does not exist." = "'%@' does not exist.";
|
||||
"The name '%@' already exists." = "The name '%@' already exists.";
|
||||
"You are about to send %d files to Trash. Continue?" = "You are about to send %d files to Trash. Continue?";
|
||||
"You are about to send %d files to Trash (and hardlink them afterwards). Continue?" = "You are about to send %d files to Trash (and hardlink them afterwards). Continue?";
|
||||
"A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again." = "A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again.";
|
||||
"Your iTunes Library contains %d dead tracks ready to be removed. Continue?" = "Your iTunes Library contains %d dead tracks ready to be removed. Continue?";
|
||||
"You have no dead tracks in your iTunes Library" = "You have no dead tracks in your iTunes Library";
|
||||
|
||||
@@ -22,6 +22,7 @@ JOBID2TITLE = {
|
||||
class DupeGuruView(FairwareView):
|
||||
def askYesNoWithPrompt_(self, prompt: str) -> bool: pass
|
||||
def showProblemDialog(self): pass
|
||||
def selectDestFolderWithPrompt_(self, prompt: str) -> str: pass
|
||||
|
||||
class PyDupeGuruBase(PyFairware):
|
||||
FOLLOW_PROTOCOLS = ['Worker']
|
||||
@@ -107,8 +108,11 @@ class PyDupeGuruBase(PyFairware):
|
||||
def makeSelectedReference(self):
|
||||
self.model.make_selected_reference()
|
||||
|
||||
def copyOrMove_markedTo_recreatePath_(self, copy: bool, destination: str, recreate_path: bool):
|
||||
self.model.copy_or_move_marked(copy, destination, recreate_path)
|
||||
def copyMarked(self):
|
||||
self.model.copy_or_move_marked(copy=True)
|
||||
|
||||
def moveMarked(self):
|
||||
self.model.copy_or_move_marked(copy=False)
|
||||
|
||||
def openSelected(self):
|
||||
self.model.open_selected()
|
||||
@@ -126,9 +130,6 @@ class PyDupeGuruBase(PyFairware):
|
||||
self.model.invoke_custom_command()
|
||||
|
||||
#---Information
|
||||
def getMarkCount(self) -> int:
|
||||
return self.model.results.mark_count
|
||||
|
||||
def resultsAreModified(self) -> bool:
|
||||
return self.model.results.is_modified
|
||||
|
||||
@@ -145,6 +146,9 @@ class PyDupeGuruBase(PyFairware):
|
||||
def setIgnoreHardlinkMatches_(self, ignore_hardlink_matches: bool):
|
||||
self.model.options['ignore_hardlink_matches'] = ignore_hardlink_matches
|
||||
|
||||
def setCopyMoveDestType_(self, copymove_dest_type: int):
|
||||
self.model.options['copymove_dest_type'] = copymove_dest_type
|
||||
|
||||
#---Worker
|
||||
def getJobProgress(self) -> object: # NSNumber
|
||||
try:
|
||||
@@ -206,3 +210,7 @@ class PyDupeGuruBase(PyFairware):
|
||||
def show_problem_dialog(self):
|
||||
self.callback.showProblemDialog()
|
||||
|
||||
@dontwrap
|
||||
def select_dest_folder(self, prompt):
|
||||
return self.callback.selectDestFolderWithPrompt_(prompt)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user