mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-05-08 17:59:50 +00:00
[#12] Added the Custom Command preference on the Qt side.
This commit is contained in:
parent
5c80ac1c74
commit
7346b422d5
10
core/app.py
10
core/app.py
@ -12,6 +12,7 @@ import os
|
|||||||
import os.path as op
|
import os.path as op
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
from send2trash import send2trash
|
from send2trash import send2trash
|
||||||
from hsutil import io, files
|
from hsutil import io, files
|
||||||
@ -233,6 +234,15 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
|||||||
ref = group.ref
|
ref = group.ref
|
||||||
cmd = cmd.replace('%d', unicode(dupe.path))
|
cmd = cmd.replace('%d', unicode(dupe.path))
|
||||||
cmd = cmd.replace('%r', unicode(ref.path))
|
cmd = cmd.replace('%r', unicode(ref.path))
|
||||||
|
match = re.match(r'"([^"]+)"(.*)', cmd)
|
||||||
|
if match is not None:
|
||||||
|
# This code here is because subprocess. Popen doesn't seem to accept, under Windows,
|
||||||
|
# executable paths with spaces in it, *even* when they're enclosed in "". So this is
|
||||||
|
# a workaround to make the damn thing work.
|
||||||
|
exepath, args = match.groups()
|
||||||
|
path, exename = op.split(exepath)
|
||||||
|
subprocess.Popen(exename + args, shell=True, cwd=path)
|
||||||
|
else:
|
||||||
subprocess.Popen(cmd, shell=True)
|
subprocess.Popen(cmd, shell=True)
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
|
@ -171,6 +171,14 @@ class DupeGuru(DupeGuruBase, QObject):
|
|||||||
def askForRegCode(self):
|
def askForRegCode(self):
|
||||||
self.reg.ask_for_code()
|
self.reg.ask_for_code()
|
||||||
|
|
||||||
|
def invokeCustomCommand(self):
|
||||||
|
cmd = self.prefs.custom_command
|
||||||
|
if cmd:
|
||||||
|
self.invoke_command(cmd)
|
||||||
|
else:
|
||||||
|
msg = "You have no custom command set up. Please, set it up in your preferences."
|
||||||
|
QMessageBox.warning(self.main_window, 'Custom Command', msg)
|
||||||
|
|
||||||
def openDebugLog(self):
|
def openDebugLog(self):
|
||||||
debugLogPath = op.join(self.appdata, 'debug.log')
|
debugLogPath = op.join(self.appdata, 'debug.log')
|
||||||
self._open_path(debugLogPath)
|
self._open_path(debugLogPath)
|
||||||
|
@ -37,6 +37,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.connect(QCoreApplication.instance(), SIGNAL('aboutToQuit()'), self.application_will_terminate)
|
self.connect(QCoreApplication.instance(), SIGNAL('aboutToQuit()'), self.application_will_terminate)
|
||||||
self.connect(self.resultsView, SIGNAL('doubleClicked()'), self.resultsDoubleClicked)
|
self.connect(self.resultsView, SIGNAL('doubleClicked()'), self.resultsDoubleClicked)
|
||||||
self.connect(self.resultsView, SIGNAL('spacePressed()'), self.resultsSpacePressed)
|
self.connect(self.resultsView, SIGNAL('spacePressed()'), self.resultsSpacePressed)
|
||||||
|
self.actionInvokeCustomCommand.triggered.connect(self.app.invokeCustomCommand)
|
||||||
|
|
||||||
def _setupUi(self):
|
def _setupUi(self):
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
@ -76,6 +77,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
actionMenu.addSeparator()
|
actionMenu.addSeparator()
|
||||||
actionMenu.addAction(self.actionOpenSelected)
|
actionMenu.addAction(self.actionOpenSelected)
|
||||||
actionMenu.addAction(self.actionRevealSelected)
|
actionMenu.addAction(self.actionRevealSelected)
|
||||||
|
actionMenu.addAction(self.actionInvokeCustomCommand)
|
||||||
actionMenu.addAction(self.actionRenameSelected)
|
actionMenu.addAction(self.actionRenameSelected)
|
||||||
self.actionActions.setMenu(actionMenu)
|
self.actionActions.setMenu(actionMenu)
|
||||||
button = QToolButton(self.toolBar)
|
button = QToolButton(self.toolBar)
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
<attribute name="headerStretchLastSection">
|
<attribute name="headerStretchLastSection">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -54,7 +57,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>630</width>
|
<width>630</width>
|
||||||
<height>22</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuColumns">
|
<widget class="QMenu" name="menuColumns">
|
||||||
@ -77,6 +80,7 @@
|
|||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionOpenSelected"/>
|
<addaction name="actionOpenSelected"/>
|
||||||
<addaction name="actionRevealSelected"/>
|
<addaction name="actionRevealSelected"/>
|
||||||
|
<addaction name="actionInvokeCustomCommand"/>
|
||||||
<addaction name="actionRenameSelected"/>
|
<addaction name="actionRenameSelected"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionApplyFilter"/>
|
<addaction name="actionApplyFilter"/>
|
||||||
@ -428,6 +432,14 @@
|
|||||||
<string>Open Debug Log</string>
|
<string>Open Debug Log</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionInvokeCustomCommand">
|
||||||
|
<property name="text">
|
||||||
|
<string>Invoke Custom Command</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+I</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
@ -26,6 +26,7 @@ class Preferences(PreferencesBase):
|
|||||||
self.use_regexp = get('UseRegexp', self.use_regexp)
|
self.use_regexp = get('UseRegexp', self.use_regexp)
|
||||||
self.remove_empty_folders = get('RemoveEmptyFolders', self.remove_empty_folders)
|
self.remove_empty_folders = get('RemoveEmptyFolders', self.remove_empty_folders)
|
||||||
self.destination_type = get('DestinationType', self.destination_type)
|
self.destination_type = get('DestinationType', self.destination_type)
|
||||||
|
self.custom_command = get('CustomCommand', self.custom_command)
|
||||||
widths = get('ColumnsWidth', self.columns_width)
|
widths = get('ColumnsWidth', self.columns_width)
|
||||||
# only set nonzero values
|
# only set nonzero values
|
||||||
for index, width in enumerate(widths[:len(self.columns_width)]):
|
for index, width in enumerate(widths[:len(self.columns_width)]):
|
||||||
@ -46,6 +47,7 @@ class Preferences(PreferencesBase):
|
|||||||
self.use_regexp = False
|
self.use_regexp = False
|
||||||
self.remove_empty_folders = False
|
self.remove_empty_folders = False
|
||||||
self.destination_type = 1
|
self.destination_type = 1
|
||||||
|
self.custom_command = ''
|
||||||
self.registration_code = ''
|
self.registration_code = ''
|
||||||
self.registration_email = ''
|
self.registration_email = ''
|
||||||
self._reset_specific()
|
self._reset_specific()
|
||||||
@ -64,6 +66,7 @@ class Preferences(PreferencesBase):
|
|||||||
set_('UseRegexp', self.use_regexp)
|
set_('UseRegexp', self.use_regexp)
|
||||||
set_('RemoveEmptyFolders', self.remove_empty_folders)
|
set_('RemoveEmptyFolders', self.remove_empty_folders)
|
||||||
set_('DestinationType', self.destination_type)
|
set_('DestinationType', self.destination_type)
|
||||||
|
set_('CustomCommand', self.custom_command)
|
||||||
set_('ColumnsWidth', self.columns_width)
|
set_('ColumnsWidth', self.columns_width)
|
||||||
set_('ColumnsVisible', self.columns_visible)
|
set_('ColumnsVisible', self.columns_visible)
|
||||||
set_('RegistrationCode', self.registration_code)
|
set_('RegistrationCode', self.registration_code)
|
||||||
|
@ -50,6 +50,7 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog):
|
|||||||
setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files)
|
setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files)
|
||||||
self.sizeThresholdEdit.setText(unicode(prefs.small_file_threshold))
|
self.sizeThresholdEdit.setText(unicode(prefs.small_file_threshold))
|
||||||
self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type)
|
self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type)
|
||||||
|
self.customCommandEdit.setText(prefs.custom_command)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
prefs = self.app.prefs
|
prefs = self.app.prefs
|
||||||
@ -64,6 +65,7 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog):
|
|||||||
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
|
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
|
||||||
prefs.small_file_threshold = tryint(self.sizeThresholdEdit.text())
|
prefs.small_file_threshold = tryint(self.sizeThresholdEdit.text())
|
||||||
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
||||||
|
prefs.custom_command = unicode(self.customCommandEdit.text())
|
||||||
|
|
||||||
def resetToDefaults(self):
|
def resetToDefaults(self):
|
||||||
self.load(preferences.Preferences())
|
self.load(preferences.Preferences())
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>449</width>
|
<width>308</width>
|
||||||
<height>312</height>
|
<height>361</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -19,9 +19,9 @@
|
|||||||
<property name="modal">
|
<property name="modal">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0,1">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
@ -174,15 +174,6 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="wordWeightingBox">
|
<widget class="QCheckBox" name="wordWeightingBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -220,9 +211,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="ignoreSmallFilesBox">
|
<widget class="QCheckBox" name="ignoreSmallFilesBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -319,6 +307,16 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Custom Command (arguments: %d for dupe, %r for ref):</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="customCommandEdit"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user