Skip to content

Commit

Permalink
Redesign File Naming options page
Browse files Browse the repository at this point in the history
- regroup Move-related options in their own checkable group
- regroup Rename-related options in their own checkable group
- improve the visual feedback when File Renaming is disabled (text edit area background)
  • Loading branch information
zas committed Jun 29, 2015
1 parent c6b45ba commit da04e8b
Show file tree
Hide file tree
Showing 3 changed files with 276 additions and 232 deletions.
81 changes: 33 additions & 48 deletions picard/ui/options/renaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import sys
from functools import partial
from PyQt4 import QtGui
from PyQt4.QtGui import QPalette, QColor
from picard import config
from picard.file import File
from picard.script import ScriptParser, SyntaxError, ScriptError, UnknownFunction
Expand Down Expand Up @@ -73,67 +74,51 @@ def __init__(self, parent=None):
self.ui.move_files.clicked.connect(self.update_examples)
self.ui.move_files_to.editingFinished.connect(self.update_examples)

if not sys.platform == "win32":
self.ui.rename_files.stateChanged.connect(
partial(
enabledSlot,
self.ui.windows_compatibility.setEnabled
)
)

self.ui.move_files.stateChanged.connect(
partial(
enabledSlot,
self.ui.delete_empty_dirs.setEnabled
)
)
self.ui.move_files.stateChanged.connect(
partial(
enabledSlot,
self.ui.move_files_to.setEnabled
)
)
self.ui.move_files.stateChanged.connect(
self.ui.move_files.toggled.connect(
partial(
enabledSlot,
self.ui.move_files_to_browse.setEnabled
self.toggle_file_moving
)
)
self.ui.move_files.stateChanged.connect(
self.ui.rename_files.toggled.connect(
partial(
enabledSlot,
self.ui.move_additional_files.setEnabled
)
)
self.ui.move_files.stateChanged.connect(
partial(
enabledSlot,
self.ui.move_additional_files_pattern.setEnabled
)
)
self.ui.rename_files.stateChanged.connect(
partial(
enabledSlot,
self.ui.ascii_filenames.setEnabled
)
)
self.ui.rename_files.stateChanged.connect(
partial(
enabledSlot,
self.ui.file_naming_format.setEnabled
)
)
self.ui.rename_files.stateChanged.connect(
partial(
enabledSlot,
self.ui.file_naming_format_default.setEnabled
self.toggle_file_renaming
)
)
self.ui.file_naming_format.textChanged.connect(self.check_formats)
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)

textEdit = self.ui.file_naming_format
self.textEditPaletteNormal = textEdit.palette()
self.textEditPaletteReadOnly = QPalette(self.textEditPaletteNormal)
disabled_color = self.textEditPaletteNormal.color(QPalette.Inactive, QPalette.Window)
self.textEditPaletteReadOnly.setColor(QPalette.Disabled, QPalette.Base, disabled_color)

def toggle_file_moving(self, state):
self.ui.delete_empty_dirs.setEnabled(state)
self.ui.move_files_to.setEnabled(state)
self.ui.move_files_to_browse.setEnabled(state)
self.ui.move_additional_files.setEnabled(state)
self.ui.move_additional_files_pattern.setEnabled(state)

def toggle_file_renaming(self, state):

self.ui.file_naming_format.setEnabled(state)
self.ui.file_naming_format_default.setEnabled(state)
self.ui.ascii_filenames.setEnabled(state)
self.ui.file_naming_format_group.setEnabled(state)
if not sys.platform == "win32":
self.ui.windows_compatibility.setEnabled(state)

if self.ui.file_naming_format.isEnabled():
self.ui.file_naming_format.setPalette(self.textEditPaletteNormal)
else:
self.ui.file_naming_format.setPalette(self.textEditPaletteReadOnly)


def check_formats(self):
self.test()
self.update_examples()
Expand Down
105 changes: 66 additions & 39 deletions picard/ui/ui_options_renaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,86 @@
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
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)

class Ui_RenamingOptionsPage(object):
def setupUi(self, RenamingOptionsPage):
RenamingOptionsPage.setObjectName(_fromUtf8("RenamingOptionsPage"))
RenamingOptionsPage.setEnabled(True)
RenamingOptionsPage.resize(453, 421)
RenamingOptionsPage.resize(453, 465)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(RenamingOptionsPage.sizePolicy().hasHeightForWidth())
RenamingOptionsPage.setSizePolicy(sizePolicy)
self.verticalLayout_5 = QtGui.QVBoxLayout(RenamingOptionsPage)
self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5"))
self.rename_files = QtGui.QCheckBox(RenamingOptionsPage)
self.rename_files.setObjectName(_fromUtf8("rename_files"))
self.verticalLayout_5.addWidget(self.rename_files)
self.ascii_filenames = QtGui.QCheckBox(RenamingOptionsPage)
self.ascii_filenames.setObjectName(_fromUtf8("ascii_filenames"))
self.verticalLayout_5.addWidget(self.ascii_filenames)
self.windows_compatibility = QtGui.QCheckBox(RenamingOptionsPage)
self.windows_compatibility.setObjectName(_fromUtf8("windows_compatibility"))
self.verticalLayout_5.addWidget(self.windows_compatibility)
self.move_files = QtGui.QCheckBox(RenamingOptionsPage)
self.move_files = QtGui.QGroupBox(RenamingOptionsPage)
self.move_files.setFlat(False)
self.move_files.setCheckable(True)
self.move_files.setChecked(False)
self.move_files.setObjectName(_fromUtf8("move_files"))
self.verticalLayout_5.addWidget(self.move_files)
self.verticalLayout_4 = QtGui.QVBoxLayout(self.move_files)
self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
self.label = QtGui.QLabel(self.move_files)
self.label.setObjectName(_fromUtf8("label"))
self.verticalLayout_4.addWidget(self.label)
self.horizontalLayout_4 = QtGui.QHBoxLayout()
self.horizontalLayout_4.setSpacing(2)
self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
self.move_files_to = QtGui.QLineEdit(RenamingOptionsPage)
self.move_files_to = QtGui.QLineEdit(self.move_files)
self.move_files_to.setEnabled(False)
self.move_files_to.setObjectName(_fromUtf8("move_files_to"))
self.horizontalLayout_4.addWidget(self.move_files_to)
self.move_files_to_browse = QtGui.QPushButton(RenamingOptionsPage)
self.move_files_to_browse = QtGui.QPushButton(self.move_files)
self.move_files_to_browse.setEnabled(False)
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.delete_empty_dirs = QtGui.QCheckBox(RenamingOptionsPage)
self.delete_empty_dirs.setEnabled(False)
self.delete_empty_dirs.setObjectName(_fromUtf8("delete_empty_dirs"))
self.verticalLayout_5.addWidget(self.delete_empty_dirs)
self.move_additional_files = QtGui.QCheckBox(RenamingOptionsPage)
self.verticalLayout_4.addLayout(self.horizontalLayout_4)
self.move_additional_files = QtGui.QCheckBox(self.move_files)
self.move_additional_files.setEnabled(False)
self.move_additional_files.setObjectName(_fromUtf8("move_additional_files"))
self.verticalLayout_5.addWidget(self.move_additional_files)
self.move_additional_files_pattern = QtGui.QLineEdit(RenamingOptionsPage)
self.verticalLayout_4.addWidget(self.move_additional_files)
self.move_additional_files_pattern = QtGui.QLineEdit(self.move_files)
self.move_additional_files_pattern.setEnabled(False)
self.move_additional_files_pattern.setObjectName(_fromUtf8("move_additional_files_pattern"))
self.verticalLayout_5.addWidget(self.move_additional_files_pattern)
self.groupBox_2 = QtGui.QGroupBox(RenamingOptionsPage)
self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox_2)
self.verticalLayout_4.addWidget(self.move_additional_files_pattern)
self.delete_empty_dirs = QtGui.QCheckBox(self.move_files)
self.delete_empty_dirs.setEnabled(False)
self.delete_empty_dirs.setObjectName(_fromUtf8("delete_empty_dirs"))
self.verticalLayout_4.addWidget(self.delete_empty_dirs)
self.verticalLayout_5.addWidget(self.move_files)
self.rename_files = QtGui.QGroupBox(RenamingOptionsPage)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.rename_files.sizePolicy().hasHeightForWidth())
self.rename_files.setSizePolicy(sizePolicy)
self.rename_files.setCheckable(True)
self.rename_files.setChecked(False)
self.rename_files.setObjectName(_fromUtf8("rename_files"))
self.verticalLayout_3 = QtGui.QVBoxLayout(self.rename_files)
self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
self.ascii_filenames = QtGui.QCheckBox(self.rename_files)
self.ascii_filenames.setObjectName(_fromUtf8("ascii_filenames"))
self.verticalLayout_3.addWidget(self.ascii_filenames)
self.windows_compatibility = QtGui.QCheckBox(self.rename_files)
self.windows_compatibility.setObjectName(_fromUtf8("windows_compatibility"))
self.verticalLayout_3.addWidget(self.windows_compatibility)
self.file_naming_format_group = QtGui.QGroupBox(self.rename_files)
self.file_naming_format_group.setObjectName(_fromUtf8("file_naming_format_group"))
self.verticalLayout_2 = QtGui.QVBoxLayout(self.file_naming_format_group)
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
self.file_naming_format = QtGui.QTextEdit(self.groupBox_2)
self.file_naming_format = QtGui.QTextEdit(self.file_naming_format_group)
self.file_naming_format.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
Expand All @@ -84,12 +109,12 @@ def setupUi(self, RenamingOptionsPage):
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.renaming_error = QtGui.QLabel(self.groupBox_2)
self.renaming_error = QtGui.QLabel(self.file_naming_format_group)
self.renaming_error.setText(_fromUtf8(""))
self.renaming_error.setAlignment(QtCore.Qt.AlignCenter)
self.renaming_error.setObjectName(_fromUtf8("renaming_error"))
self.horizontalLayout.addWidget(self.renaming_error)
self.file_naming_format_default = QtGui.QPushButton(self.groupBox_2)
self.file_naming_format_default = QtGui.QPushButton(self.file_naming_format_group)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -99,7 +124,8 @@ def setupUi(self, RenamingOptionsPage):
self.file_naming_format_default.setObjectName(_fromUtf8("file_naming_format_default"))
self.horizontalLayout.addWidget(self.file_naming_format_default)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.verticalLayout_5.addWidget(self.groupBox_2)
self.verticalLayout_3.addWidget(self.file_naming_format_group)
self.verticalLayout_5.addWidget(self.rename_files)
self.groupBox = QtGui.QGroupBox(RenamingOptionsPage)
self.groupBox.setObjectName(_fromUtf8("groupBox"))
self.verticalLayout = QtGui.QVBoxLayout(self.groupBox)
Expand Down Expand Up @@ -127,19 +153,20 @@ def setupUi(self, RenamingOptionsPage):
QtCore.QMetaObject.connectSlotsByName(RenamingOptionsPage)

def retranslateUi(self, RenamingOptionsPage):
self.rename_files.setText(_("Rename files when saving"))
self.ascii_filenames.setText(_("Replace non-ASCII characters"))
self.windows_compatibility.setText(_("Windows compatibility"))
self.move_files.setText(_("Move files to this directory when saving:"))
self.move_files.setTitle(_("Move files when saving"))
self.label.setText(_("Destination directory:"))
self.move_files_to_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(QtGui.QApplication.translate("RenamingOptionsPage", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
self.delete_empty_dirs.setText(_("Delete empty directories"))
self.rename_files.setTitle(_("Rename files when saving"))
self.ascii_filenames.setText(_("Replace non-ASCII characters"))
self.windows_compatibility.setText(_("Windows compatibility"))
self.file_naming_format_group.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"
"<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, QtGui.QApplication.UnicodeUTF8))
"<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))
self.file_naming_format_default.setText(_("Default"))
self.groupBox.setTitle(_("Examples"))

Loading

0 comments on commit da04e8b

Please sign in to comment.