1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

[#92 state:fixed] Added an action to delete duplicates and then create hardlinks to group ref.

This commit is contained in:
Virgil Dupras
2010-09-25 15:37:18 +02:00
parent 01db7c4948
commit 359f9c0680
12 changed files with 150 additions and 38 deletions

View File

@@ -131,11 +131,12 @@ class DupeGuru(DupeGuruBase, QObject):
def _reveal_path(path):
DupeGuru._open_path(path[:-1])
def _start_job(self, jobid, func):
def _start_job(self, jobid, func, *args):
title = JOBID2TITLE[jobid]
try:
j = self._progress.create_job()
self._progress.run(jobid, title, func, args=(j, ))
args = tuple([j] + list(args))
self._progress.run(jobid, title, func, args=args)
except job.JobInProgressError:
msg = "A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again."
QMessageBox.information(self.main_window, 'Action in progress', msg)

View File

@@ -44,6 +44,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.actionInvokeCustomCommand.triggered.connect(self.app.invokeCustomCommand)
self.actionLoadResults.triggered.connect(self.loadResultsTriggered)
self.actionSaveResults.triggered.connect(self.saveResultsTriggered)
self.actionHardlinkMarked.triggered.connect(self.hardlinkTriggered)
def _setupUi(self):
self.setupUi(self)
@@ -73,6 +74,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
actionMenu = QMenu('Actions', self.toolBar)
actionMenu.setIcon(QIcon(QPixmap(":/actions")))
actionMenu.addAction(self.actionDeleteMarked)
actionMenu.addAction(self.actionHardlinkMarked)
actionMenu.addAction(self.actionMoveMarked)
actionMenu.addAction(self.actionCopyMarked)
actionMenu.addAction(self.actionRemoveMarked)
@@ -99,9 +101,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if self.app.prefs.mainWindowRect is not None and not self.app.prefs.mainWindowIsMaximized:
self.setGeometry(self.app.prefs.mainWindowRect)
# Linux setup
# Platform-specific setup
if sys.platform == 'linux2':
self.actionCheckForUpdate.setVisible(False) # This only works on Windows
if sys.platform not in {'darwin', 'linux2'}:
self.actionHardlinkMarked.setVisible(False)
#--- Private
def _confirm(self, title, msg, default_button=QMessageBox.Yes):
@@ -194,6 +198,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
url = QUrl.fromLocalFile(exported_path)
QDesktopServices.openUrl(url)
def hardlinkTriggered(self):
count = self.app.results.mark_count
if not count:
return
title = "Delete and hardlink duplicates"
msg = "You are about to send {0} files to the trash and hardlink them afterwards. Continue?".format(count)
if self._confirm(title, msg):
self.app.delete_marked(replace_with_hardlinks=True)
def loadResultsTriggered(self):
title = "Select a results file to load"
files = "dupeGuru Results (*.dupeguru)"

View File

@@ -64,6 +64,7 @@
<string>Actions</string>
</property>
<addaction name="actionDeleteMarked"/>
<addaction name="actionHardlinkMarked"/>
<addaction name="actionMoveMarked"/>
<addaction name="actionCopyMarked"/>
<addaction name="actionRemoveMarked"/>
@@ -265,6 +266,14 @@
<string>Ctrl+D</string>
</property>
</action>
<action name="actionHardlinkMarked">
<property name="text">
<string>Delete Marked and Replace with Hardlinks</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+D</string>
</property>
</action>
<action name="actionMoveMarked">
<property name="text">
<string>Move Marked to...</string>