diff --git a/picard/ui/options/dialog.py b/picard/ui/options/dialog.py index fb576e4c7..c406c8174 100644 --- a/picard/ui/options/dialog.py +++ b/picard/ui/options/dialog.py @@ -75,6 +75,7 @@ from picard.ui.options import ( # noqa: F401 # pylint: disable=unused-import ratings, releases, renaming, + renaming_compat, scripting, tags, tags_compatibility_aac, diff --git a/picard/ui/options/renaming.py b/picard/ui/options/renaming.py index cf39d7eb3..0ab2cc9f9 100644 --- a/picard/ui/options/renaming.py +++ b/picard/ui/options/renaming.py @@ -44,9 +44,7 @@ from picard.config import ( TextOption, get_config, ) -from picard.const.sys import IS_WIN from picard.script import ScriptParser -from picard.util import system_supports_long_paths from picard.ui.options import ( OptionsCheckError, @@ -79,9 +77,6 @@ class RenamingOptionsPage(OptionsPage): HELP_URL = '/config/options_filerenaming.html' options = [ - BoolOption("setting", "windows_compatibility", True), - BoolOption("setting", "windows_long_paths", system_supports_long_paths() if IS_WIN else False), - BoolOption("setting", "ascii_filenames", False), BoolOption("setting", "rename_files", False), BoolOption("setting", "move_files", False), TextOption("setting", "move_files_to", _default_music_dir), @@ -96,9 +91,6 @@ class RenamingOptionsPage(OptionsPage): self.ui = Ui_RenamingOptionsPage() self.ui.setupUi(self) - self.ui.ascii_filenames.clicked.connect(self.update_examples_from_local) - self.ui.windows_compatibility.clicked.connect(self.update_examples_from_local) - self.ui.windows_long_paths.clicked.connect(self.update_examples_from_local) self.ui.rename_files.clicked.connect(self.update_examples_from_local) self.ui.move_files.clicked.connect(self.update_examples_from_local) self.ui.move_files_to.editingFinished.connect(self.update_examples_from_local) @@ -200,20 +192,6 @@ class RenamingOptionsPage(OptionsPage): active = self.ui.move_files.isChecked() or self.ui.rename_files.isChecked() self.ui.open_script_editor.setEnabled(active) - def toggle_windows_long_paths(self, state): - if state and not system_supports_long_paths(): - dialog = QtWidgets.QMessageBox( - QtWidgets.QMessageBox.Icon.Information, - _('Windows long path support'), - _( - 'Enabling long paths on Windows might cause files being saved with path names ' - 'exceeding the 259 character limit traditionally imposed by the Windows API. ' - 'Some software might not be able to properly access those files.' - ), - QtWidgets.QMessageBox.StandardButton.Ok, - self) - dialog.exec_() - def save_from_editor(self): self.script_text = self.script_editor_dialog.get_script() self.update_selector_from_editor() @@ -228,11 +206,12 @@ class RenamingOptionsPage(OptionsPage): def update_examples_from_local(self): override = { - 'ascii_filenames': self.ui.ascii_filenames.isChecked(), 'move_files': self.ui.move_files.isChecked(), 'move_files_to': os.path.normpath(self.ui.move_files_to.text()), 'rename_files': self.ui.rename_files.isChecked(), - 'windows_compatibility': self.ui.windows_compatibility.isChecked(), + # 'ascii_filenames': self.ui.ascii_filenames.isChecked(), + # 'windows_compatibility': self.ui.windows_compatibility.isChecked(), + # 'windows_long_paths': self.ui.windows_long_paths.isChecked(), } self.examples.update_examples(override=override) self.update_displayed_examples() @@ -250,19 +229,8 @@ class RenamingOptionsPage(OptionsPage): def load(self): config = get_config() - try: - self.ui.windows_long_paths.toggled.disconnect(self.toggle_windows_long_paths) - except TypeError: - pass - if IS_WIN: - self.ui.windows_compatibility.setChecked(True) - self.ui.windows_compatibility.setEnabled(False) - else: - self.ui.windows_compatibility.setChecked(config.setting["windows_compatibility"]) - self.ui.windows_long_paths.setChecked(config.setting["windows_long_paths"]) self.ui.rename_files.setChecked(config.setting["rename_files"]) self.ui.move_files.setChecked(config.setting["move_files"]) - self.ui.ascii_filenames.setChecked(config.setting["ascii_filenames"]) self.ui.move_files_to.setText(config.setting["move_files_to"]) self.ui.move_files_to.setCursorPosition(0) self.ui.move_additional_files.setChecked(config.setting["move_additional_files"]) @@ -275,7 +243,6 @@ class RenamingOptionsPage(OptionsPage): else: self.update_selector_from_settings() self.update_examples_from_local() - self.ui.windows_long_paths.toggled.connect(self.toggle_windows_long_paths) def check(self): self.check_format() @@ -294,9 +261,6 @@ class RenamingOptionsPage(OptionsPage): def save(self): config = get_config() - config.setting["windows_compatibility"] = self.ui.windows_compatibility.isChecked() - config.setting["windows_long_paths"] = self.ui.windows_long_paths.isChecked() - config.setting["ascii_filenames"] = self.ui.ascii_filenames.isChecked() config.setting["rename_files"] = self.ui.rename_files.isChecked() config.setting["move_files"] = self.ui.move_files.isChecked() config.setting["move_files_to"] = os.path.normpath(self.ui.move_files_to.text()) diff --git a/picard/ui/options/renaming_compat.py b/picard/ui/options/renaming_compat.py new file mode 100644 index 000000000..66831ee69 --- /dev/null +++ b/picard/ui/options/renaming_compat.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +# +# Picard, the next-generation MusicBrainz tagger +# +# Copyright (C) 2006-2008, 2011 Lukáš Lalinský +# Copyright (C) 2008-2009 Nikolai Prokoschenko +# Copyright (C) 2009-2010, 2014-2015, 2018-2022 Philipp Wolfer +# Copyright (C) 2011-2013 Michael Wiencek +# Copyright (C) 2011-2013 Wieland Hoffmann +# Copyright (C) 2013 Calvin Walton +# Copyright (C) 2013 Ionuț Ciocîrlan +# Copyright (C) 2013-2014 Sophist-UK +# Copyright (C) 2013-2015, 2018-2021 Laurent Monin +# Copyright (C) 2015 Alex Berman +# Copyright (C) 2015 Ohm Patel +# Copyright (C) 2016 Suhas +# Copyright (C) 2016-2017 Sambhav Kothari +# Copyright (C) 2021 Bob Swift +# Copyright (C) 2021 Gabriel Ferreira +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +from PyQt5 import QtWidgets + +from picard.config import ( + BoolOption, + get_config, +) +from picard.const.sys import IS_WIN +from picard.util import system_supports_long_paths + +from picard.ui.options import ( + OptionsPage, + register_options_page, +) +from picard.ui.ui_options_renaming_compat import Ui_RenamingCompatOptionsPage + + +class RenamingCompatOptionsPage(OptionsPage): + + NAME = "filerenaming_compat" + TITLE = N_("Compatibility") + PARENT = "filerenaming" + ACTIVE = True + HELP_URL = '/config/options_filerenaming_compat.html' + + options = [ + BoolOption("setting", "windows_compatibility", True), + BoolOption("setting", "windows_long_paths", system_supports_long_paths() if IS_WIN else False), + BoolOption("setting", "ascii_filenames", False), + ] + + def __init__(self, parent=None): + super().__init__(parent) + self.ui = Ui_RenamingCompatOptionsPage() + self.ui.setupUi(self) + + def load(self): + config = get_config() + try: + self.ui.windows_long_paths.toggled.disconnect(self.toggle_windows_long_paths) + except TypeError: + pass + if IS_WIN: + self.ui.windows_compatibility.setChecked(True) + self.ui.windows_compatibility.setEnabled(False) + else: + self.ui.windows_compatibility.setChecked(config.setting["windows_compatibility"]) + self.ui.windows_long_paths.setChecked(config.setting["windows_long_paths"]) + self.ui.ascii_filenames.setChecked(config.setting["ascii_filenames"]) + self.ui.windows_long_paths.toggled.connect(self.toggle_windows_long_paths) + + def save(self): + config = get_config() + config.setting["windows_compatibility"] = self.ui.windows_compatibility.isChecked() + config.setting["windows_long_paths"] = self.ui.windows_long_paths.isChecked() + config.setting["ascii_filenames"] = self.ui.ascii_filenames.isChecked() + + def toggle_windows_long_paths(self, state): + if state and not system_supports_long_paths(): + dialog = QtWidgets.QMessageBox( + QtWidgets.QMessageBox.Icon.Information, + _('Windows long path support'), + _( + 'Enabling long paths on Windows might cause files being saved with path names ' + 'exceeding the 259 character limit traditionally imposed by the Windows API. ' + 'Some software might not be able to properly access those files.' + ), + QtWidgets.QMessageBox.StandardButton.Ok, + self) + dialog.exec_() + + +register_options_page(RenamingCompatOptionsPage) diff --git a/picard/ui/ui_options_renaming.py b/picard/ui/ui_options_renaming.py index 756f2a936..75ddc0260 100644 --- a/picard/ui/ui_options_renaming.py +++ b/picard/ui/ui_options_renaming.py @@ -11,7 +11,7 @@ class Ui_RenamingOptionsPage(object): def setupUi(self, RenamingOptionsPage): RenamingOptionsPage.setObjectName("RenamingOptionsPage") RenamingOptionsPage.setEnabled(True) - RenamingOptionsPage.resize(453, 679) + RenamingOptionsPage.resize(453, 468) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -52,16 +52,6 @@ class Ui_RenamingOptionsPage(object): self.rename_files = QtWidgets.QCheckBox(RenamingOptionsPage) self.rename_files.setObjectName("rename_files") self.verticalLayout_5.addWidget(self.rename_files) - self.ascii_filenames = QtWidgets.QCheckBox(RenamingOptionsPage) - self.ascii_filenames.setObjectName("ascii_filenames") - self.verticalLayout_5.addWidget(self.ascii_filenames) - self.windows_compatibility = QtWidgets.QCheckBox(RenamingOptionsPage) - self.windows_compatibility.setObjectName("windows_compatibility") - self.verticalLayout_5.addWidget(self.windows_compatibility) - self.windows_long_paths = QtWidgets.QCheckBox(RenamingOptionsPage) - self.windows_long_paths.setEnabled(False) - self.windows_long_paths.setObjectName("windows_long_paths") - self.verticalLayout_5.addWidget(self.windows_long_paths) self.label_2 = QtWidgets.QLabel(RenamingOptionsPage) self.label_2.setObjectName("label_2") self.verticalLayout_5.addWidget(self.label_2) @@ -86,6 +76,7 @@ class Ui_RenamingOptionsPage(object): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) self.groupBox.setSizePolicy(sizePolicy) + self.groupBox.setMinimumSize(QtCore.QSize(0, 120)) self.groupBox.setObjectName("groupBox") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.groupBox) self.verticalLayout_6.setContentsMargins(3, 3, 3, 3) @@ -141,7 +132,6 @@ class Ui_RenamingOptionsPage(object): self.verticalLayout_5.addLayout(self.horizontalLayout) self.retranslateUi(RenamingOptionsPage) - self.windows_compatibility.toggled['bool'].connect(self.windows_long_paths.setEnabled) # type: ignore QtCore.QMetaObject.connectSlotsByName(RenamingOptionsPage) RenamingOptionsPage.setTabOrder(self.move_files, self.move_files_to) RenamingOptionsPage.setTabOrder(self.move_files_to, self.move_files_to_browse) @@ -149,10 +139,7 @@ class Ui_RenamingOptionsPage(object): RenamingOptionsPage.setTabOrder(self.move_additional_files, self.move_additional_files_pattern) RenamingOptionsPage.setTabOrder(self.move_additional_files_pattern, self.delete_empty_dirs) RenamingOptionsPage.setTabOrder(self.delete_empty_dirs, self.rename_files) - RenamingOptionsPage.setTabOrder(self.rename_files, self.ascii_filenames) - RenamingOptionsPage.setTabOrder(self.ascii_filenames, self.windows_compatibility) - RenamingOptionsPage.setTabOrder(self.windows_compatibility, self.windows_long_paths) - RenamingOptionsPage.setTabOrder(self.windows_long_paths, self.naming_script_selector) + RenamingOptionsPage.setTabOrder(self.rename_files, self.naming_script_selector) RenamingOptionsPage.setTabOrder(self.naming_script_selector, self.open_script_editor) RenamingOptionsPage.setTabOrder(self.open_script_editor, self.example_filename_before) RenamingOptionsPage.setTabOrder(self.example_filename_before, self.example_filename_sample_files_button) @@ -166,9 +153,6 @@ class Ui_RenamingOptionsPage(object): self.move_additional_files.setText(_("Move additional files (case insensitive):")) self.delete_empty_dirs.setText(_("Delete empty directories")) self.rename_files.setText(_("Rename files when saving")) - self.ascii_filenames.setText(_("Replace non-ASCII characters")) - self.windows_compatibility.setText(_("Windows compatibility")) - self.windows_long_paths.setText(_("Allow paths longer than 259 characters")) self.label_2.setText(_("Selected file naming script:")) self.open_script_editor.setText(_("Edit file naming script...")) self.groupBox.setTitle(_("Files will be named like this:")) diff --git a/picard/ui/ui_options_renaming_compat.py b/picard/ui/ui_options_renaming_compat.py new file mode 100644 index 000000000..2eca52035 --- /dev/null +++ b/picard/ui/ui_options_renaming_compat.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +# Automatically generated - don't edit. +# Use `python setup.py build_ui` to update it. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_RenamingCompatOptionsPage(object): + def setupUi(self, RenamingCompatOptionsPage): + RenamingCompatOptionsPage.setObjectName("RenamingCompatOptionsPage") + RenamingCompatOptionsPage.setEnabled(True) + RenamingCompatOptionsPage.resize(453, 374) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(RenamingCompatOptionsPage.sizePolicy().hasHeightForWidth()) + RenamingCompatOptionsPage.setSizePolicy(sizePolicy) + self.verticalLayout_5 = QtWidgets.QVBoxLayout(RenamingCompatOptionsPage) + self.verticalLayout_5.setObjectName("verticalLayout_5") + self.ascii_filenames = QtWidgets.QCheckBox(RenamingCompatOptionsPage) + self.ascii_filenames.setObjectName("ascii_filenames") + self.verticalLayout_5.addWidget(self.ascii_filenames) + self.windows_compatibility = QtWidgets.QCheckBox(RenamingCompatOptionsPage) + self.windows_compatibility.setObjectName("windows_compatibility") + self.verticalLayout_5.addWidget(self.windows_compatibility) + self.windows_long_paths = QtWidgets.QCheckBox(RenamingCompatOptionsPage) + self.windows_long_paths.setEnabled(False) + self.windows_long_paths.setObjectName("windows_long_paths") + self.verticalLayout_5.addWidget(self.windows_long_paths) + self.example_selection_note = QtWidgets.QLabel(RenamingCompatOptionsPage) + self.example_selection_note.setText("") + self.example_selection_note.setWordWrap(True) + self.example_selection_note.setObjectName("example_selection_note") + self.verticalLayout_5.addWidget(self.example_selection_note) + + self.retranslateUi(RenamingCompatOptionsPage) + self.windows_compatibility.toggled['bool'].connect(self.windows_long_paths.setEnabled) # type: ignore + QtCore.QMetaObject.connectSlotsByName(RenamingCompatOptionsPage) + RenamingCompatOptionsPage.setTabOrder(self.ascii_filenames, self.windows_compatibility) + RenamingCompatOptionsPage.setTabOrder(self.windows_compatibility, self.windows_long_paths) + + def retranslateUi(self, RenamingCompatOptionsPage): + _translate = QtCore.QCoreApplication.translate + self.ascii_filenames.setText(_("Replace non-ASCII characters")) + self.windows_compatibility.setText(_("Windows compatibility")) + self.windows_long_paths.setText(_("Allow paths longer than 259 characters")) diff --git a/ui/options_renaming.ui b/ui/options_renaming.ui index 57ae43a6b..2166a59fc 100644 --- a/ui/options_renaming.ui +++ b/ui/options_renaming.ui @@ -10,7 +10,7 @@ 0 0 453 - 679 + 468 @@ -19,7 +19,7 @@ 0 - + @@ -86,30 +86,6 @@ - - - - Replace non-ASCII characters - - - - - - - Windows compatibility - - - - - - - false - - - Allow paths longer than 259 characters - - - @@ -149,6 +125,12 @@ 0 + + + 0 + 120 + + Files will be named like this: @@ -304,9 +286,6 @@ move_additional_files_pattern delete_empty_dirs rename_files - ascii_filenames - windows_compatibility - windows_long_paths naming_script_selector open_script_editor example_filename_before @@ -314,22 +293,5 @@ example_filename_after - - - windows_compatibility - toggled(bool) - windows_long_paths - setEnabled(bool) - - - 226 - 267 - - - 226 - 296 - - - - + diff --git a/ui/options_renaming_compat.ui b/ui/options_renaming_compat.ui new file mode 100644 index 000000000..c6c89f3c6 --- /dev/null +++ b/ui/options_renaming_compat.ui @@ -0,0 +1,83 @@ + + + RenamingCompatOptionsPage + + + true + + + + 0 + 0 + 453 + 374 + + + + + 0 + 0 + + + + + + + Replace non-ASCII characters + + + + + + + Windows compatibility + + + + + + + false + + + Allow paths longer than 259 characters + + + + + + + + + + true + + + + + + + ascii_filenames + windows_compatibility + windows_long_paths + + + + + windows_compatibility + toggled(bool) + windows_long_paths + setEnabled(bool) + + + 226 + 267 + + + 226 + 296 + + + + +