mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-05-08 09:49:51 +00:00
Removed logic duplication across toolkit code in "Open Selected" action.
This commit is contained in:
parent
9edee82fa1
commit
37238c7f57
@ -103,6 +103,10 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
|||||||
path = Path(str_path)
|
path = Path(str_path)
|
||||||
return fs.get_file(path, self.directories.fileclasses)
|
return fs.get_file(path, self.directories.fileclasses)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _open_path(path):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _recycle_dupe(dupe):
|
def _recycle_dupe(dupe):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
@ -224,6 +228,10 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
|||||||
self.results.make_ref(dupe)
|
self.results.make_ref(dupe)
|
||||||
changed_groups.add(g)
|
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):
|
def remove_duplicates(self, duplicates):
|
||||||
self.results.remove_duplicates(duplicates)
|
self.results.remove_duplicates(duplicates)
|
||||||
|
|
||||||
|
@ -49,6 +49,10 @@ class DupeGuru(app.DupeGuru):
|
|||||||
self.display_delta_values = False
|
self.display_delta_values = False
|
||||||
|
|
||||||
#--- Override
|
#--- Override
|
||||||
|
@staticmethod
|
||||||
|
def _open_path(path):
|
||||||
|
NSWorkspace.sharedWorkspace().openFile_(unicode(path))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _recycle_dupe(dupe):
|
def _recycle_dupe(dupe):
|
||||||
# local import because first appkit import takes a lot of memory. we want to avoid it.
|
# 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)
|
copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked)
|
||||||
delete_marked = demo_method(app.DupeGuru.delete_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):
|
def PurgeIgnoreList(self):
|
||||||
self.scanner.ignore_list.Filter(lambda f,s:op.exists(f) and op.exists(s))
|
self.scanner.ignore_list.Filter(lambda f,s:op.exists(f) and op.exists(s))
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class PyDupeGuruBase(PyApp):
|
|||||||
self.app.copy_or_move_marked(copy, destination, recreate_path)
|
self.app.copy_or_move_marked(copy, destination, recreate_path)
|
||||||
|
|
||||||
def openSelected(self):
|
def openSelected(self):
|
||||||
self.app.OpenSelected()
|
self.app.open_selected()
|
||||||
|
|
||||||
def removeMarked(self):
|
def removeMarked(self):
|
||||||
self.app.results.perform_on_marked(lambda x:True, True)
|
self.app.results.perform_on_marked(lambda x:True, True)
|
||||||
|
@ -117,6 +117,11 @@ class DupeGuru(DupeGuruBase, QObject):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
#--- Override
|
#--- Override
|
||||||
|
@staticmethod
|
||||||
|
def _open_path(path):
|
||||||
|
url = QUrl.fromLocalFile(unicode(path))
|
||||||
|
QDesktopServices.openUrl(url)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _recycle_dupe(dupe):
|
def _recycle_dupe(dupe):
|
||||||
platform.recycle_file(dupe.path)
|
platform.recycle_file(dupe.path)
|
||||||
@ -182,14 +187,7 @@ class DupeGuru(DupeGuruBase, QObject):
|
|||||||
|
|
||||||
def openDebugLog(self):
|
def openDebugLog(self):
|
||||||
debugLogPath = op.join(self.appdata, 'debug.log')
|
debugLogPath = op.join(self.appdata, 'debug.log')
|
||||||
url = QUrl.fromLocalFile(debugLogPath)
|
self._open_path(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)
|
|
||||||
|
|
||||||
def remove_marked_duplicates(self):
|
def remove_marked_duplicates(self):
|
||||||
marked = [d for d in self.results.dupes if self.results.is_marked(d)]
|
marked = [d for d in self.results.dupes if self.results.is_marked(d)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user