mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
Added a Deletion Options dialog that pops up when Send to Trash is triggered.
It offers hardlink and direct deletion options. This new feature supersedes the old "Send to Trash and Hardlink" menu item, which was removed.
This commit is contained in:
@@ -32,6 +32,7 @@ from .result_window import ResultWindow
|
||||
from .directories_dialog import DirectoriesDialog
|
||||
from .problem_dialog import ProblemDialog
|
||||
from .ignore_list_dialog import IgnoreListDialog
|
||||
from .deletion_options import DeletionOptions
|
||||
|
||||
tr = trget('ui')
|
||||
|
||||
@@ -89,6 +90,7 @@ class DupeGuru(QObject):
|
||||
self.details_dialog = self.DETAILS_DIALOG_CLASS(self.resultWindow, self)
|
||||
self.problemDialog = ProblemDialog(parent=self.resultWindow, model=self.model.problem_dialog)
|
||||
self.ignoreListDialog = IgnoreListDialog(parent=self.resultWindow, model=self.model.ignore_list_dialog)
|
||||
self.deletionOptions = DeletionOptions(parent=self.resultWindow, model=self.model.deletion_options)
|
||||
self.preferences_dialog = self.PREFERENCES_DIALOG_CLASS(self.resultWindow, self)
|
||||
self.about_box = AboutBox(self.resultWindow, self)
|
||||
|
||||
|
||||
64
qt/base/deletion_options.py
Normal file
64
qt/base/deletion_options.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2012-05-30
|
||||
# Copyright 2012 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
from PyQt4.QtCore import Qt
|
||||
from PyQt4.QtGui import QDialog, QVBoxLayout, QLabel, QCheckBox, QDialogButtonBox
|
||||
|
||||
from hscommon.trans import trget
|
||||
from qtlib.util import horizontalWrap
|
||||
|
||||
tr = trget('ui')
|
||||
|
||||
class DeletionOptions(QDialog):
|
||||
def __init__(self, parent, model):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
QDialog.__init__(self, parent, flags)
|
||||
self._setupUi()
|
||||
self.model = model
|
||||
self.model.view = self
|
||||
|
||||
self.buttonBox.accepted.connect(self.accept)
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
def _setupUi(self):
|
||||
self.setWindowTitle(tr("Deletion Options"))
|
||||
self.resize(400, 250)
|
||||
self.verticalLayout = QVBoxLayout(self)
|
||||
self.msgLabel = QLabel()
|
||||
self.verticalLayout.addWidget(self.msgLabel)
|
||||
self.hardlinkCheckbox = QCheckBox(tr("Hardlink deleted files"))
|
||||
self.verticalLayout.addWidget(self.hardlinkCheckbox)
|
||||
text = tr("After having deleted a duplicate, place a hardlink targeting the reference file "
|
||||
"to replace the deleted file.")
|
||||
self.hardlinkMessageLabel = QLabel(text)
|
||||
self.hardlinkMessageLabel.setWordWrap(True)
|
||||
self.verticalLayout.addWidget(self.hardlinkMessageLabel)
|
||||
self.directCheckbox = QCheckBox(tr("Directly delete files"))
|
||||
self.verticalLayout.addWidget(self.directCheckbox)
|
||||
text = tr("Instead of sending files to trash, delete them directly. This option is usually "
|
||||
"used as a workaround when the normal deletion method doesn't work.")
|
||||
self.directMessageLabel = QLabel(text)
|
||||
self.directMessageLabel.setWordWrap(True)
|
||||
self.verticalLayout.addWidget(self.directMessageLabel)
|
||||
self.buttonBox = QDialogButtonBox()
|
||||
self.buttonBox.addButton(tr("Proceed"), QDialogButtonBox.AcceptRole)
|
||||
self.buttonBox.addButton(tr("Cancel"), QDialogButtonBox.RejectRole)
|
||||
self.verticalLayout.addWidget(self.buttonBox)
|
||||
|
||||
#--- model --> view
|
||||
def update_msg(self, msg):
|
||||
self.msgLabel.setText(msg)
|
||||
|
||||
def show(self):
|
||||
self.hardlinkCheckbox.setChecked(self.model.hardlink)
|
||||
self.directCheckbox.setChecked(self.model.direct)
|
||||
result = self.exec()
|
||||
self.model.hardlink = self.hardlinkCheckbox.isChecked()
|
||||
self.model.direct = self.directCheckbox.isChecked()
|
||||
return result == QDialog.Accepted
|
||||
|
||||
@@ -49,7 +49,6 @@ class ResultWindow(QMainWindow):
|
||||
('actionPowerMarker', 'Ctrl+1', '', tr("Show Dupes Only"), self.powerMarkerTriggered),
|
||||
('actionDelta', 'Ctrl+2', '', tr("Show Delta Values"), self.deltaTriggered),
|
||||
('actionDeleteMarked', 'Ctrl+D', '', tr("Send Marked to Recycle Bin"), self.deleteTriggered),
|
||||
('actionHardlinkMarked', 'Ctrl+Shift+D', '', tr("Delete Marked and Replace with Hardlinks"), self.hardlinkTriggered),
|
||||
('actionMoveMarked', 'Ctrl+M', '', tr("Move Marked to..."), self.moveTriggered),
|
||||
('actionCopyMarked', 'Ctrl+Shift+M', '', tr("Copy Marked to..."), self.copyTriggered),
|
||||
('actionRemoveMarked', 'Ctrl+R', '', tr("Remove Marked from Results"), self.removeMarkedTriggered),
|
||||
@@ -72,9 +71,6 @@ class ResultWindow(QMainWindow):
|
||||
self.actionDelta.setCheckable(True)
|
||||
self.actionPowerMarker.setCheckable(True)
|
||||
|
||||
if (not ISOSX) and (not ISLINUX):
|
||||
self.actionHardlinkMarked.setVisible(False)
|
||||
|
||||
def _setupMenu(self):
|
||||
self.menubar = QMenuBar(self)
|
||||
self.menubar.setGeometry(QRect(0, 0, 630, 22))
|
||||
@@ -93,7 +89,6 @@ class ResultWindow(QMainWindow):
|
||||
self.setMenuBar(self.menubar)
|
||||
|
||||
self.menuActions.addAction(self.actionDeleteMarked)
|
||||
self.menuActions.addAction(self.actionHardlinkMarked)
|
||||
self.menuActions.addAction(self.actionMoveMarked)
|
||||
self.menuActions.addAction(self.actionCopyMarked)
|
||||
self.menuActions.addAction(self.actionRemoveMarked)
|
||||
@@ -150,7 +145,6 @@ class ResultWindow(QMainWindow):
|
||||
# Action menu
|
||||
actionMenu = QMenu(tr("Actions"), self.menubar)
|
||||
actionMenu.addAction(self.actionDeleteMarked)
|
||||
actionMenu.addAction(self.actionHardlinkMarked)
|
||||
actionMenu.addAction(self.actionMoveMarked)
|
||||
actionMenu.addAction(self.actionCopyMarked)
|
||||
actionMenu.addAction(self.actionRemoveMarked)
|
||||
@@ -245,9 +239,6 @@ class ResultWindow(QMainWindow):
|
||||
url = QUrl.fromLocalFile(exported_path)
|
||||
QDesktopServices.openUrl(url)
|
||||
|
||||
def hardlinkTriggered(self):
|
||||
self.app.model.delete_marked(replace_with_hardlinks=True)
|
||||
|
||||
def makeReferenceTriggered(self):
|
||||
self.app.model.make_selected_reference()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user