From ba65c3f24582461b4fe85288111175f248ba5977 Mon Sep 17 00:00:00 2001 From: Bob Swift Date: Thu, 25 Apr 2024 09:47:33 -0600 Subject: [PATCH] Update the Options > Advanced > Maintenance page: - update the enabling logic for the unused setting item selections and "Remove selected options" checkbox to allow scrolling the unused settings list without having to enable the "Remove selected options" checkbox - relocate the "Remove selected options" checkbox to save space - update the wording of the instructions to clarify and save space - update the tab order --- picard/ui/options/maintenance.py | 27 +++++++-------- picard/ui/ui_options_maintenance.py | 24 ++++++++++--- ui/options_maintenance.ui | 53 +++++++++++++++++++++++------ 3 files changed, 73 insertions(+), 31 deletions(-) diff --git a/picard/ui/options/maintenance.py b/picard/ui/options/maintenance.py index 1ecdf91709..b4716db509 100644 --- a/picard/ui/options/maintenance.py +++ b/picard/ui/options/maintenance.py @@ -2,7 +2,7 @@ # # Picard, the next-generation MusicBrainz tagger # -# Copyright (C) 2021-2022 Bob Swift +# Copyright (C) 2021-2022, 2024 Bob Swift # Copyright (C) 2021-2023 Philipp Wolfer # Copyright (C) 2021-2024 Laurent Monin # @@ -91,23 +91,21 @@ def __init__(self, parent=None): self.ui = Ui_MaintenanceOptionsPage() self.ui.setupUi(self) self.ui.description.setText(_( - "This allows you to remove unused option settings from the configuration INI file.\n\n" "Settings that are found in the configuration file that do not appear on any option " - "settings page will be listed below. If your configuration file does not contain any " + "settings page are listed below. If your configuration file does not contain any " "unused option settings, then the list will be empty and the removal checkbox will be " "disabled.\n\n" "Note that unused option settings could come from plugins that have been uninstalled, " "so please be careful to not remove settings that you may want to use later when " "the plugin is reinstalled. Options belonging to plugins that are installed but " - "currently disabled will not be listed for possible removal.\n\n" - "To remove one or more settings, first enable the removal by checking the \"Remove " - "selected options\" box. You can then select the settings to remove by checking the " - "box next to the setting. When you choose \"Make It So!\" to save your option " + "currently disabled are not listed for possible removal.\n\n" + "To remove one or more settings, select the settings that you want to remove by " + "checking the box next to the setting, and enable the removal by checking the \"Remove " + "selected options\" box. When you choose \"Make It So!\" to save your option " "settings, the selected items will be removed." )) self.ui.tableWidget.setHorizontalHeaderLabels([_("Option"), _("Value")]) self.ui.select_all.stateChanged.connect(self.select_all_changed) - self.ui.enable_cleanup.stateChanged.connect(self.enable_cleanup_changed) self.ui.open_folder_button.clicked.connect(self.open_config_dir) self.ui.save_backup_button.clicked.connect(self.save_backup) self.ui.load_backup_button.clicked.connect(self.load_backup) @@ -176,7 +174,7 @@ def load(self): self.ui.option_counts.setText( _("The configuration file currently contains %(totalcount)d option " - "settings, %(unusedcount)d which are unused.") % { + "settings (%(unusedcount)d unused).") % { 'totalcount': len(file_options), 'unusedcount': len(orphan_options), }) @@ -204,9 +202,7 @@ def load(self): self.ui.tableWidget.setCellWidget(row, 1, tableitem) self.ui.tableWidget.resizeColumnsToContents() self.ui.select_all.setCheckState(QtCore.Qt.CheckState.Unchecked) - if not len(orphan_options): - self.ui.select_all.setEnabled(False) - self.enable_cleanup_changed() + self._set_cleanup_state() def open_config_dir(self): config = get_config() @@ -397,10 +393,11 @@ def make_setting_value_text(self, key): value = config.setting.raw_value(key) return repr(value) - def enable_cleanup_changed(self): - state = self.ui.enable_cleanup.checkState() == QtCore.Qt.CheckState.Checked + def _set_cleanup_state(self): + state = self.ui.tableWidget.rowCount() > 0 self.ui.select_all.setEnabled(state) - self.ui.tableWidget.setEnabled(state) + self.ui.enable_cleanup.setChecked(False) + self.ui.enable_cleanup.setEnabled(state) register_options_page(MaintenanceOptionsPage) diff --git a/picard/ui/ui_options_maintenance.py b/picard/ui/ui_options_maintenance.py index d8b5956ed6..e139d299d6 100644 --- a/picard/ui/ui_options_maintenance.py +++ b/picard/ui/ui_options_maintenance.py @@ -92,9 +92,6 @@ def setupUi(self, MaintenanceOptionsPage): self.option_counts.setText("") self.option_counts.setObjectName("option_counts") self.vboxlayout.addWidget(self.option_counts) - self.enable_cleanup = QtWidgets.QCheckBox(parent=MaintenanceOptionsPage) - self.enable_cleanup.setObjectName("enable_cleanup") - self.vboxlayout.addWidget(self.enable_cleanup) self.description = QtWidgets.QLabel(parent=MaintenanceOptionsPage) self.description.setText("") self.description.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) @@ -109,9 +106,18 @@ def setupUi(self, MaintenanceOptionsPage): self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) self.line.setObjectName("line") self.vboxlayout.addWidget(self.line) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setContentsMargins(-1, 0, -1, -1) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.select_all = QtWidgets.QCheckBox(parent=MaintenanceOptionsPage) self.select_all.setObjectName("select_all") - self.vboxlayout.addWidget(self.select_all) + self.horizontalLayout_2.addWidget(self.select_all) + spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) + self.horizontalLayout_2.addItem(spacerItem2) + self.enable_cleanup = QtWidgets.QCheckBox(parent=MaintenanceOptionsPage) + self.enable_cleanup.setObjectName("enable_cleanup") + self.horizontalLayout_2.addWidget(self.enable_cleanup) + self.vboxlayout.addLayout(self.horizontalLayout_2) self.tableWidget = QtWidgets.QTableWidget(parent=MaintenanceOptionsPage) self.tableWidget.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents) self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers) @@ -124,6 +130,14 @@ def setupUi(self, MaintenanceOptionsPage): self.retranslateUi(MaintenanceOptionsPage) QtCore.QMetaObject.connectSlotsByName(MaintenanceOptionsPage) + MaintenanceOptionsPage.setTabOrder(self.config_file, self.open_folder_button) + MaintenanceOptionsPage.setTabOrder(self.open_folder_button, self.autobackup_dir) + MaintenanceOptionsPage.setTabOrder(self.autobackup_dir, self.browse_autobackup_dir) + MaintenanceOptionsPage.setTabOrder(self.browse_autobackup_dir, self.load_backup_button) + MaintenanceOptionsPage.setTabOrder(self.load_backup_button, self.save_backup_button) + MaintenanceOptionsPage.setTabOrder(self.save_backup_button, self.select_all) + MaintenanceOptionsPage.setTabOrder(self.select_all, self.enable_cleanup) + MaintenanceOptionsPage.setTabOrder(self.enable_cleanup, self.tableWidget) def retranslateUi(self, MaintenanceOptionsPage): self.label.setText(_("Configuration file:")) @@ -132,5 +146,5 @@ def retranslateUi(self, MaintenanceOptionsPage): self.browse_autobackup_dir.setText(_("Browse…")) self.load_backup_button.setText(_("Load backup…")) self.save_backup_button.setText(_("Save backup…")) - self.enable_cleanup.setText(_("Remove selected options")) self.select_all.setText(_("Select all")) + self.enable_cleanup.setText(_("Remove selected options")) diff --git a/ui/options_maintenance.ui b/ui/options_maintenance.ui index 34a44ef546..7ab1503cfb 100644 --- a/ui/options_maintenance.ui +++ b/ui/options_maintenance.ui @@ -138,13 +138,6 @@ - - - - Remove selected options - - - @@ -185,11 +178,38 @@ - - - Select all + + + 0 - + + + + Select all + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Remove selected options + + + + @@ -214,6 +234,17 @@ + + config_file + open_folder_button + autobackup_dir + browse_autobackup_dir + load_backup_button + save_backup_button + select_all + enable_cleanup + tableWidget +