mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-05 16:13:59 +00:00
Messing with settings:
Revert `options_renaming` UI files back to upstream/master (gets rid of `move_files_ancestor`). Stick to `windows_compatibility` setting name, and handle upgrade. Rename `move_files_ancestor` setting to `windows_compatibility_drive_root`.
This commit is contained in:
@@ -283,7 +283,7 @@ class File(QtCore.QObject, Item):
|
||||
if not settings['move_files']:
|
||||
new_filename = os.path.basename(new_filename)
|
||||
new_filename = make_short_filename(new_dirname, new_filename,
|
||||
config.setting['windows_compatibility'], config.setting['move_files_ancestor'])
|
||||
config.setting['windows_compatibility'], config.setting['windows_compatibility_drive_root'])
|
||||
# win32 compatibility fixes
|
||||
if settings['windows_compatibility'] or sys.platform == 'win32':
|
||||
new_filename = new_filename.replace('./', '_/').replace('.\\', '_\\')
|
||||
|
||||
@@ -207,7 +207,18 @@ class Tagger(QtGui.QApplication):
|
||||
# default format, disabled
|
||||
remove_va_file_naming_format(merge=False)
|
||||
|
||||
def upgrade_windows_compatibility_setting():
|
||||
# the setting `windows_compatible_filenames` has been renamed
|
||||
# to `windows_compatibility`
|
||||
_s = config.setting
|
||||
if "windows_compatible_filenames" in _s:
|
||||
_s["windows_compatibility"] = _s["windows_compatible_filenames"]
|
||||
_s.remove("windows_compatible_filenames")
|
||||
|
||||
|
||||
cfg.register_upgrade_hook("1.0.0final0", upgrade_to_v1_0)
|
||||
# TODO: uncomment this and replace with proper version before release
|
||||
#cfg.register_upgrade_hook("1.3.0dev1", upgrade_windows_compatibility_setting)
|
||||
|
||||
cfg.run_upgrade_hooks()
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ class RenamingOptionsPage(OptionsPage):
|
||||
config.TextOption("setting", "file_naming_format", "$if2(%albumartist%,%artist%)/%album%/$if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2)$if(%compilation%, %artist% -,) %title%"),
|
||||
config.BoolOption("setting", "move_files", False),
|
||||
config.TextOption("setting", "move_files_to", ""),
|
||||
config.TextOption("setting", "move_files_ancestor", ""),
|
||||
config.BoolOption("setting", "move_additional_files", False),
|
||||
config.TextOption("setting", "move_additional_files_pattern", "*.jpg *.png"),
|
||||
config.BoolOption("setting", "delete_empty_dirs", True),
|
||||
@@ -61,7 +60,6 @@ class RenamingOptionsPage(OptionsPage):
|
||||
self.ui.rename_files.clicked.connect(self.update_examples)
|
||||
self.ui.move_files.clicked.connect(self.update_examples)
|
||||
self.ui.move_files_to.editingFinished.connect(self.update_examples)
|
||||
self.ui.move_files_ancestor.editingFinished.connect(self.update_examples)
|
||||
|
||||
# The following code is there to fix
|
||||
# http://tickets.musicbrainz.org/browse/PICARD-417
|
||||
@@ -78,18 +76,6 @@ class RenamingOptionsPage(OptionsPage):
|
||||
enabledSlot,
|
||||
self.ui.windows_compatibility.setEnabled)
|
||||
)
|
||||
self.ui.rename_files.stateChanged.connect(partial(
|
||||
enabledSlot,
|
||||
self.toggle_move_files_ancestor_enabled)
|
||||
)
|
||||
self.ui.windows_compatibility.stateChanged.connect(partial(
|
||||
enabledSlot,
|
||||
self.toggle_move_files_ancestor_enabled)
|
||||
)
|
||||
self.ui.move_files.stateChanged.connect(partial(
|
||||
enabledSlot,
|
||||
self.toggle_move_files_ancestor_enabled)
|
||||
)
|
||||
|
||||
self.ui.move_files.stateChanged.connect(partial(
|
||||
enabledSlot,
|
||||
@@ -127,17 +113,6 @@ class RenamingOptionsPage(OptionsPage):
|
||||
self.ui.file_naming_format_default.clicked.connect(self.set_file_naming_format_default)
|
||||
self.highlighter = TaggerScriptSyntaxHighlighter(self.ui.file_naming_format.document())
|
||||
self.ui.move_files_to_browse.clicked.connect(self.move_files_to_browse)
|
||||
self.ui.move_files_ancestor_browse.clicked.connect(self.move_files_ancestor_browse)
|
||||
|
||||
def toggle_move_files_ancestor_enabled(self, enable):
|
||||
enabled = enable and \
|
||||
self.ui.rename_files.isChecked() and \
|
||||
self.ui.windows_compatibility.isChecked() and \
|
||||
self.ui.windows_compatibility.isEnabled() and \
|
||||
self.ui.move_files.isChecked()
|
||||
parentLayout = self.ui.move_files_ancestorLayout
|
||||
for i in range(parentLayout.count()):
|
||||
parentLayout.itemAt(i).widget().setEnabled(enabled)
|
||||
|
||||
def check_formats(self):
|
||||
self.test()
|
||||
@@ -151,8 +126,7 @@ class RenamingOptionsPage(OptionsPage):
|
||||
'move_files': self.ui.move_files.isChecked(),
|
||||
'use_va_format': False, # TODO remove
|
||||
'file_naming_format': unicode(self.ui.file_naming_format.toPlainText()),
|
||||
'move_files_to': os.path.normpath(unicode(self.ui.move_files_to.text())),
|
||||
'move_files_ancestor': unicode(self.ui.move_files_ancestor.text())
|
||||
'move_files_to': os.path.normpath(unicode(self.ui.move_files_to.text()))
|
||||
}
|
||||
try:
|
||||
if config.setting["enable_tagger_script"]:
|
||||
@@ -190,8 +164,6 @@ class RenamingOptionsPage(OptionsPage):
|
||||
self.ui.file_naming_format.setPlainText(config.setting["file_naming_format"])
|
||||
self.ui.move_files_to.setText(config.setting["move_files_to"])
|
||||
self.ui.move_files_to.setCursorPosition(0)
|
||||
self.ui.move_files_ancestor.setText(config.setting["move_files_ancestor"])
|
||||
self.ui.move_files_ancestor.setCursorPosition(0)
|
||||
self.ui.move_additional_files.setChecked(config.setting["move_additional_files"])
|
||||
self.ui.move_additional_files_pattern.setText(config.setting["move_additional_files_pattern"])
|
||||
self.ui.delete_empty_dirs.setChecked(config.setting["delete_empty_dirs"])
|
||||
@@ -199,21 +171,8 @@ class RenamingOptionsPage(OptionsPage):
|
||||
|
||||
def check(self):
|
||||
self.check_format()
|
||||
if self.ui.move_files.isChecked():
|
||||
move_files_to = unicode(self.ui.move_files_to.text()).strip()
|
||||
if not move_files_to:
|
||||
raise OptionsCheckError(_("Error"), _("The location to move files to must not be empty."))
|
||||
if self.ui.windows_compatibility.isChecked() and self.ui.windows_compatibility.isEnabled():
|
||||
move_files_ancestor = unicode(self.ui.move_files_ancestor.text()).strip()
|
||||
if move_files_ancestor:
|
||||
move_files_to = os.path.abspath(move_files_to)
|
||||
move_files_ancestor = os.path.abspath(move_files_ancestor)
|
||||
if not move_files_to.startswith(move_files_ancestor) or \
|
||||
move_files_to.split(move_files_ancestor)[1][:1] not in (os.path.sep, ""):
|
||||
raise OptionsCheckError(
|
||||
_("Error"),
|
||||
_("Compatibility must be applied against an ancestor of where files are moved to.")
|
||||
)
|
||||
if self.ui.move_files.isChecked() and not unicode(self.ui.move_files_to.text()).strip():
|
||||
raise OptionsCheckError(_("Error"), _("The location to move files to must not be empty."))
|
||||
|
||||
def check_format(self):
|
||||
parser = ScriptParser()
|
||||
@@ -233,7 +192,6 @@ class RenamingOptionsPage(OptionsPage):
|
||||
self.tagger.window.enable_renaming_action.setChecked(config.setting["rename_files"])
|
||||
config.setting["move_files"] = self.ui.move_files.isChecked()
|
||||
config.setting["move_files_to"] = os.path.normpath(unicode(self.ui.move_files_to.text()))
|
||||
config.setting["move_files_ancestor"] = unicode(self.ui.move_files_ancestor.text())
|
||||
config.setting["move_additional_files"] = self.ui.move_additional_files.isChecked()
|
||||
config.setting["move_additional_files_pattern"] = unicode(self.ui.move_additional_files_pattern.text())
|
||||
config.setting["delete_empty_dirs"] = self.ui.delete_empty_dirs.isChecked()
|
||||
@@ -303,12 +261,6 @@ class RenamingOptionsPage(OptionsPage):
|
||||
path = os.path.normpath(unicode(path))
|
||||
self.ui.move_files_to.setText(path)
|
||||
|
||||
def move_files_ancestor_browse(self):
|
||||
path = QtGui.QFileDialog.getExistingDirectory(self, "", self.ui.move_files_ancestor.text())
|
||||
if path:
|
||||
path = os.path.normpath(unicode(path))
|
||||
self.ui.move_files_ancestor.setText(path)
|
||||
|
||||
def test(self):
|
||||
self.ui.renaming_error.setStyleSheet("")
|
||||
self.ui.renaming_error.setText("")
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'ui/options_renaming.ui'
|
||||
#
|
||||
# Created: Thu Jun 6 20:19:42 2013
|
||||
# by: PyQt4 UI code generator 4.10.1
|
||||
# Created: Fri Jul 13 15:18:48 2012
|
||||
# by: PyQt4 UI code generator 4.8.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
@@ -12,16 +12,7 @@ from PyQt4 import QtCore, QtGui
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
def _fromUtf8(s):
|
||||
return s
|
||||
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
_fromUtf8 = lambda s: s
|
||||
|
||||
class Ui_RenamingOptionsPage(object):
|
||||
def setupUi(self, RenamingOptionsPage):
|
||||
@@ -59,23 +50,6 @@ class Ui_RenamingOptionsPage(object):
|
||||
self.move_files_to_browse.setObjectName(_fromUtf8("move_files_to_browse"))
|
||||
self.horizontalLayout_4.addWidget(self.move_files_to_browse)
|
||||
self.verticalLayout_5.addLayout(self.horizontalLayout_4)
|
||||
self.move_files_ancestorLayout = QtGui.QHBoxLayout()
|
||||
self.move_files_ancestorLayout.setSpacing(2)
|
||||
self.move_files_ancestorLayout.setObjectName(_fromUtf8("move_files_ancestorLayout"))
|
||||
self.move_files_ancestor_label = QtGui.QLabel(RenamingOptionsPage)
|
||||
self.move_files_ancestor_label.setEnabled(False)
|
||||
self.move_files_ancestor_label.setObjectName(_fromUtf8("move_files_ancestor_label"))
|
||||
self.move_files_ancestorLayout.addWidget(self.move_files_ancestor_label)
|
||||
self.move_files_ancestor = QtGui.QLineEdit(RenamingOptionsPage)
|
||||
self.move_files_ancestor.setEnabled(False)
|
||||
self.move_files_ancestor.setText(_fromUtf8(""))
|
||||
self.move_files_ancestor.setObjectName(_fromUtf8("move_files_ancestor"))
|
||||
self.move_files_ancestorLayout.addWidget(self.move_files_ancestor)
|
||||
self.move_files_ancestor_browse = QtGui.QPushButton(RenamingOptionsPage)
|
||||
self.move_files_ancestor_browse.setEnabled(False)
|
||||
self.move_files_ancestor_browse.setObjectName(_fromUtf8("move_files_ancestor_browse"))
|
||||
self.move_files_ancestorLayout.addWidget(self.move_files_ancestor_browse)
|
||||
self.verticalLayout_5.addLayout(self.move_files_ancestorLayout)
|
||||
self.delete_empty_dirs = QtGui.QCheckBox(RenamingOptionsPage)
|
||||
self.delete_empty_dirs.setEnabled(False)
|
||||
self.delete_empty_dirs.setObjectName(_fromUtf8("delete_empty_dirs"))
|
||||
@@ -103,7 +77,7 @@ class Ui_RenamingOptionsPage(object):
|
||||
font = QtGui.QFont()
|
||||
font.setFamily(_fromUtf8("Monospace"))
|
||||
self.file_naming_format.setFont(font)
|
||||
self.file_naming_format.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.IBeamCursor))
|
||||
self.file_naming_format.setProperty(_fromUtf8("cursor"), QtCore.Qt.IBeamCursor)
|
||||
self.file_naming_format.setTabChangesFocus(False)
|
||||
self.file_naming_format.setLineWrapMode(QtGui.QTextEdit.NoWrap)
|
||||
self.file_naming_format.setTabStopWidth(20)
|
||||
@@ -162,16 +136,14 @@ class Ui_RenamingOptionsPage(object):
|
||||
self.windows_compatibility.setText(_("Windows compatibility"))
|
||||
self.move_files.setText(_("Move files to this directory when saving:"))
|
||||
self.move_files_to_browse.setText(_("Browse..."))
|
||||
self.move_files_ancestor_label.setText(_("Apply compatibility against:"))
|
||||
self.move_files_ancestor_browse.setText(_("Browse..."))
|
||||
self.delete_empty_dirs.setText(_("Delete empty directories"))
|
||||
self.move_additional_files.setText(_("Move additional files:"))
|
||||
self.groupBox_2.setTitle(_("Name files like this"))
|
||||
self.file_naming_format.setHtml(_translate("RenamingOptionsPage", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
self.file_naming_format.setHtml(QtGui.QApplication.translate("RenamingOptionsPage", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head><body style=\" font-family:\'Monospace\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
|
||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;\"><br /></p></body></html>", None))
|
||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;\"><br /></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.file_naming_format_default.setText(_("Default"))
|
||||
self.groupBox.setTitle(_("Examples"))
|
||||
|
||||
|
||||
@@ -72,43 +72,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="move_files_ancestorLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="move_files_ancestor_label">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply compatibility against:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="move_files_ancestor">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="move_files_ancestor_browse">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="delete_empty_dirs">
|
||||
<property name="enabled">
|
||||
|
||||
Reference in New Issue
Block a user