diff --git a/core/app.py b/core/app.py index 8b294773..6aafaf3c 100644 --- a/core/app.py +++ b/core/app.py @@ -103,6 +103,10 @@ class DupeGuru(RegistrableApplication, Broadcaster): path = Path(str_path) return fs.get_file(path, self.directories.fileclasses) + @staticmethod + def _open_path(path): + raise NotImplementedError() + @staticmethod def _recycle_dupe(dupe): raise NotImplementedError() @@ -224,6 +228,10 @@ class DupeGuru(RegistrableApplication, Broadcaster): self.results.make_ref(dupe) changed_groups.add(g) + def open_selected(self): + if self.selected_dupes: + self._open_path(self.selected_dupes[0].path) + def remove_duplicates(self, duplicates): self.results.remove_duplicates(duplicates) diff --git a/core/app_cocoa.py b/core/app_cocoa.py index cc56d56e..50dc20c2 100644 --- a/core/app_cocoa.py +++ b/core/app_cocoa.py @@ -49,6 +49,10 @@ class DupeGuru(app.DupeGuru): self.display_delta_values = False #--- Override + @staticmethod + def _open_path(path): + NSWorkspace.sharedWorkspace().openFile_(unicode(path)) + @staticmethod def _recycle_dupe(dupe): # local import because first appkit import takes a lot of memory. we want to avoid it. @@ -93,12 +97,6 @@ class DupeGuru(app.DupeGuru): copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked) delete_marked = demo_method(app.DupeGuru.delete_marked) - def OpenSelected(self): - # local import because first appkit import takes a lot of memory. we want to avoid it. - if self.selected_dupes: - path = unicode(self.selected_dupes[0].path) - NSWorkspace.sharedWorkspace().openFile_(path) - def PurgeIgnoreList(self): self.scanner.ignore_list.Filter(lambda f,s:op.exists(f) and op.exists(s)) diff --git a/core/app_cocoa_inter.py b/core/app_cocoa_inter.py index 985b1883..5ebeaee2 100644 --- a/core/app_cocoa_inter.py +++ b/core/app_cocoa_inter.py @@ -100,7 +100,7 @@ class PyDupeGuruBase(PyApp): self.app.copy_or_move_marked(copy, destination, recreate_path) def openSelected(self): - self.app.OpenSelected() + self.app.open_selected() def removeMarked(self): self.app.results.perform_on_marked(lambda x:True, True) diff --git a/qt/base/app.py b/qt/base/app.py index 46068da9..6925d5b5 100644 --- a/qt/base/app.py +++ b/qt/base/app.py @@ -117,6 +117,11 @@ class DupeGuru(DupeGuruBase, QObject): raise NotImplementedError() #--- Override + @staticmethod + def _open_path(path): + url = QUrl.fromLocalFile(unicode(path)) + QDesktopServices.openUrl(url) + @staticmethod def _recycle_dupe(dupe): platform.recycle_file(dupe.path) @@ -182,14 +187,7 @@ class DupeGuru(DupeGuruBase, QObject): def openDebugLog(self): debugLogPath = op.join(self.appdata, 'debug.log') - url = QUrl.fromLocalFile(debugLogPath) - QDesktopServices.openUrl(url) - - def open_selected(self): - if not self.selected_dupes: - return - url = QUrl.fromLocalFile(unicode(self.selected_dupes[0].path)) - QDesktopServices.openUrl(url) + self._open_path(debugLogPath) def remove_marked_duplicates(self): marked = [d for d in self.results.dupes if self.results.is_marked(d)]