mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
Pushed job_finished logic down from GUI layers to the core.
This commit is contained in:
parent
5fb7742cf4
commit
ef0a66f794
@ -218,6 +218,11 @@ http://www.hardcoded.net/licenses/bsd_license
|
|||||||
return [Dialogs askYesNo:prompt] == NSAlertFirstButtonReturn;
|
return [Dialogs askYesNo:prompt] == NSAlertFirstButtonReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)showProblemDialog
|
||||||
|
{
|
||||||
|
[[self resultWindow] showProblemDialog];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setupAsRegistered
|
- (void)setupAsRegistered
|
||||||
{
|
{
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
|
@ -42,6 +42,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
|||||||
- (void)fillColumnsMenu;
|
- (void)fillColumnsMenu;
|
||||||
- (void)sendMarkedToTrash:(BOOL)hardlinkDeleted;
|
- (void)sendMarkedToTrash:(BOOL)hardlinkDeleted;
|
||||||
- (void)updateOptionSegments;
|
- (void)updateOptionSegments;
|
||||||
|
- (void)showProblemDialog;
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
- (IBAction)clearIgnoreList:(id)sender;
|
- (IBAction)clearIgnoreList:(id)sender;
|
||||||
@ -74,7 +75,4 @@ http://www.hardcoded.net/licenses/bsd_license
|
|||||||
- (IBAction)toggleDetailsPanel:(id)sender;
|
- (IBAction)toggleDetailsPanel:(id)sender;
|
||||||
- (IBAction)togglePowerMarker:(id)sender;
|
- (IBAction)togglePowerMarker:(id)sender;
|
||||||
- (IBAction)toggleQuicklookPanel:(id)sender;
|
- (IBAction)toggleQuicklookPanel:(id)sender;
|
||||||
|
|
||||||
/* Notifications */
|
|
||||||
- (void)jobCompleted:(NSNotification *)aNotification;
|
|
||||||
@end
|
@end
|
||||||
|
@ -32,7 +32,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
|||||||
[matches setTarget:self];
|
[matches setTarget:self];
|
||||||
[matches setDoubleAction:@selector(openClicked:)];
|
[matches setDoubleAction:@selector(openClicked:)];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobCompleted:) name:JobCompletedNotification object:nil];
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobStarted:) name:JobStarted object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobStarted:) name:JobStarted object:nil];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobInProgress:) name:JobInProgress object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobInProgress:) name:JobInProgress object:nil];
|
||||||
return self;
|
return self;
|
||||||
@ -104,6 +103,11 @@ http://www.hardcoded.net/licenses/bsd_license
|
|||||||
[optionsSwitch setSelected:[table deltaValuesMode] forSegment:2];
|
[optionsSwitch setSelected:[table deltaValuesMode] forSegment:2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)showProblemDialog
|
||||||
|
{
|
||||||
|
[problemDialog showWindow:self];
|
||||||
|
}
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
- (IBAction)clearIgnoreList:(id)sender
|
- (IBAction)clearIgnoreList:(id)sender
|
||||||
{
|
{
|
||||||
@ -377,42 +381,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
|||||||
previewPanel = nil;
|
previewPanel = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notifications */
|
|
||||||
- (void)jobCompleted:(NSNotification *)aNotification
|
|
||||||
{
|
|
||||||
id lastAction = [[ProgressController mainProgressController] jobId];
|
|
||||||
if ([lastAction isEqualTo:jobCopy]) {
|
|
||||||
if ([model scanWasProblematic]) {
|
|
||||||
[problemDialog showWindow:self];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[Dialogs showMessage:TR(@"All marked files were copied sucessfully.")];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ([lastAction isEqualTo:jobMove]) {
|
|
||||||
if ([model scanWasProblematic]) {
|
|
||||||
[problemDialog showWindow:self];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[Dialogs showMessage:TR(@"All marked files were moved sucessfully.")];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ([lastAction isEqualTo:jobDelete]) {
|
|
||||||
if ([model scanWasProblematic]) {
|
|
||||||
[problemDialog showWindow:self];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[Dialogs showMessage:TR(@"All marked files were sucessfully sent to Trash.")];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ([lastAction isEqualTo:jobScan]) {
|
|
||||||
NSInteger rowCount = [[table model] numberOfRows];
|
|
||||||
if (rowCount == 0) {
|
|
||||||
[Dialogs showMessage:TR(@"No duplicates found.")];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)jobInProgress:(NSNotification *)aNotification
|
- (void)jobInProgress:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
[Dialogs showMessage:TR(@"A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again.")];
|
[Dialogs showMessage:TR(@"A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again.")];
|
||||||
|
@ -21,6 +21,7 @@ JOBID2TITLE = {
|
|||||||
|
|
||||||
class DupeGuruView(FairwareView):
|
class DupeGuruView(FairwareView):
|
||||||
def askYesNoWithPrompt_(self, prompt: str) -> bool: pass
|
def askYesNoWithPrompt_(self, prompt: str) -> bool: pass
|
||||||
|
def showProblemDialog(self): pass
|
||||||
|
|
||||||
class PyDupeGuruBase(PyFairware):
|
class PyDupeGuruBase(PyFairware):
|
||||||
FOLLOW_PROTOCOLS = ['Worker']
|
FOLLOW_PROTOCOLS = ['Worker']
|
||||||
@ -128,9 +129,6 @@ class PyDupeGuruBase(PyFairware):
|
|||||||
def getMarkCount(self) -> int:
|
def getMarkCount(self) -> int:
|
||||||
return self.model.results.mark_count
|
return self.model.results.mark_count
|
||||||
|
|
||||||
def scanWasProblematic(self) -> bool:
|
|
||||||
return bool(self.model.results.problems)
|
|
||||||
|
|
||||||
def resultsAreModified(self) -> bool:
|
def resultsAreModified(self) -> bool:
|
||||||
return self.model.results.is_modified
|
return self.model.results.is_modified
|
||||||
|
|
||||||
@ -197,3 +195,14 @@ class PyDupeGuruBase(PyFairware):
|
|||||||
def ask_yes_no(self, prompt):
|
def ask_yes_no(self, prompt):
|
||||||
return self.callback.askYesNoWithPrompt_(prompt)
|
return self.callback.askYesNoWithPrompt_(prompt)
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@dontwrap
|
||||||
|
def show_problem_dialog(self):
|
||||||
|
self.callback.showProblemDialog()
|
||||||
|
|
||||||
|
21
core/app.py
21
core/app.py
@ -81,6 +81,8 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
|||||||
# reveal_path(path)
|
# reveal_path(path)
|
||||||
# start_job(jobid, func, args=()) ( func(j, *args) )
|
# start_job(jobid, func, args=()) ( func(j, *args) )
|
||||||
# ask_yes_no(prompt) --> bool
|
# ask_yes_no(prompt) --> bool
|
||||||
|
# show_results_window()
|
||||||
|
# show_problem_dialog()
|
||||||
|
|
||||||
# in fairware prompts, we don't mention the edition, it's too long.
|
# in fairware prompts, we don't mention the edition, it's too long.
|
||||||
PROMPT_NAME = "dupeGuru"
|
PROMPT_NAME = "dupeGuru"
|
||||||
@ -174,12 +176,29 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
|||||||
# Must be called by subclasses when they detect that an async job is completed. If an
|
# Must be called by subclasses when they detect that an async job is completed. If an
|
||||||
# exception was raised during the job, `exc` will be set. Return True when the error was
|
# exception was raised during the job, `exc` will be set. Return True when the error was
|
||||||
# handled. If we return False when exc is set, a the exception will be re-raised.
|
# handled. If we return False when exc is set, a the exception will be re-raised.
|
||||||
|
if exc is not None:
|
||||||
|
return False # We don't handle any exception in here
|
||||||
if jobid == JobType.Scan:
|
if jobid == JobType.Scan:
|
||||||
self._results_changed()
|
self._results_changed()
|
||||||
elif jobid in {JobType.Load, JobType.Move, JobType.Delete}:
|
if not self.results.groups:
|
||||||
|
self.view.show_message(tr("No duplicates found."))
|
||||||
|
else:
|
||||||
|
self.view.show_results_window()
|
||||||
|
if jobid in {JobType.Load, JobType.Move, JobType.Delete}:
|
||||||
self._results_changed()
|
self._results_changed()
|
||||||
|
if jobid == JobType.Load:
|
||||||
|
self.view.show_results_window()
|
||||||
if jobid in {JobType.Copy, JobType.Move, JobType.Delete}:
|
if jobid in {JobType.Copy, JobType.Move, JobType.Delete}:
|
||||||
|
if self.results.problems:
|
||||||
self.notify('problems_changed')
|
self.notify('problems_changed')
|
||||||
|
self.view.show_problem_dialog()
|
||||||
|
else:
|
||||||
|
msg = {
|
||||||
|
JobType.Copy: tr("All marked files were copied sucessfully."),
|
||||||
|
JobType.Move: tr("All marked files were moved sucessfully."),
|
||||||
|
JobType.Delete: tr("All marked files were sucessfully sent to Trash."),
|
||||||
|
}[jobid]
|
||||||
|
self.view.show_message(msg)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _remove_hardlink_dupes(files):
|
def _remove_hardlink_dupes(files):
|
||||||
|
@ -203,21 +203,6 @@ class DupeGuru(QObject):
|
|||||||
result = self.model._job_completed(jobid, self._progress.last_error)
|
result = self.model._job_completed(jobid, self._progress.last_error)
|
||||||
if not result:
|
if not result:
|
||||||
self._progress.reraise_if_error()
|
self._progress.reraise_if_error()
|
||||||
if jobid in {JobType.Move, JobType.Copy, JobType.Delete}:
|
|
||||||
if self.model.results.problems:
|
|
||||||
self.problemDialog.show()
|
|
||||||
else:
|
|
||||||
msg = tr("All files were processed successfully.")
|
|
||||||
QMessageBox.information(self.resultWindow, tr("Operation Complete"), msg)
|
|
||||||
elif jobid == JobType.Scan:
|
|
||||||
if not self.model.results.groups:
|
|
||||||
title = tr("Scan complete")
|
|
||||||
msg = tr("No duplicates found.")
|
|
||||||
QMessageBox.information(self.resultWindow, title, msg)
|
|
||||||
else:
|
|
||||||
self.showResultsWindow()
|
|
||||||
elif jobid == JobType.Load:
|
|
||||||
self.showResultsWindow()
|
|
||||||
|
|
||||||
def openDebugLogTriggered(self):
|
def openDebugLogTriggered(self):
|
||||||
debugLogPath = op.join(self.model.appdata, 'debug.log')
|
debugLogPath = op.join(self.model.appdata, 'debug.log')
|
||||||
@ -294,3 +279,9 @@ class DupeGuru(QObject):
|
|||||||
url = QUrl(url)
|
url = QUrl(url)
|
||||||
QDesktopServices.openUrl(url)
|
QDesktopServices.openUrl(url)
|
||||||
|
|
||||||
|
def show_results_window(self):
|
||||||
|
self.showResultsWindow()
|
||||||
|
|
||||||
|
def show_problem_dialog(self):
|
||||||
|
self.problemDialog.show()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user