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
This commit is contained in:
Bob Swift
2024-04-25 09:47:33 -06:00
parent 4bfbe012b3
commit ba65c3f245
3 changed files with 73 additions and 31 deletions

View File

@@ -2,7 +2,7 @@
# #
# Picard, the next-generation MusicBrainz tagger # 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-2023 Philipp Wolfer
# Copyright (C) 2021-2024 Laurent Monin # Copyright (C) 2021-2024 Laurent Monin
# #
@@ -91,23 +91,21 @@ class MaintenanceOptionsPage(OptionsPage):
self.ui = Ui_MaintenanceOptionsPage() self.ui = Ui_MaintenanceOptionsPage()
self.ui.setupUi(self) self.ui.setupUi(self)
self.ui.description.setText(_( 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 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 " "unused option settings, then the list will be empty and the removal checkbox will be "
"disabled.\n\n" "disabled.\n\n"
"Note that unused option settings could come from plugins that have been uninstalled, " "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 " "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 " "the plugin is reinstalled. Options belonging to plugins that are installed but "
"currently disabled will not be listed for possible removal.\n\n" "currently disabled are not listed for possible removal.\n\n"
"To remove one or more settings, first enable the removal by checking the \"Remove " "To remove one or more settings, select the settings that you want to remove by "
"selected options\" box. You can then select the settings to remove by checking the " "checking the box next to the setting, and enable the removal by checking the \"Remove "
"box next to the setting. When you choose \"Make It So!\" to save your option " "selected options\" box. When you choose \"Make It So!\" to save your option "
"settings, the selected items will be removed." "settings, the selected items will be removed."
)) ))
self.ui.tableWidget.setHorizontalHeaderLabels([_("Option"), _("Value")]) self.ui.tableWidget.setHorizontalHeaderLabels([_("Option"), _("Value")])
self.ui.select_all.stateChanged.connect(self.select_all_changed) 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.open_folder_button.clicked.connect(self.open_config_dir)
self.ui.save_backup_button.clicked.connect(self.save_backup) self.ui.save_backup_button.clicked.connect(self.save_backup)
self.ui.load_backup_button.clicked.connect(self.load_backup) self.ui.load_backup_button.clicked.connect(self.load_backup)
@@ -176,7 +174,7 @@ class MaintenanceOptionsPage(OptionsPage):
self.ui.option_counts.setText( self.ui.option_counts.setText(
_("The configuration file currently contains %(totalcount)d option " _("The configuration file currently contains %(totalcount)d option "
"settings, %(unusedcount)d which are unused.") % { "settings (%(unusedcount)d unused).") % {
'totalcount': len(file_options), 'totalcount': len(file_options),
'unusedcount': len(orphan_options), 'unusedcount': len(orphan_options),
}) })
@@ -204,9 +202,7 @@ class MaintenanceOptionsPage(OptionsPage):
self.ui.tableWidget.setCellWidget(row, 1, tableitem) self.ui.tableWidget.setCellWidget(row, 1, tableitem)
self.ui.tableWidget.resizeColumnsToContents() self.ui.tableWidget.resizeColumnsToContents()
self.ui.select_all.setCheckState(QtCore.Qt.CheckState.Unchecked) self.ui.select_all.setCheckState(QtCore.Qt.CheckState.Unchecked)
if not len(orphan_options): self._set_cleanup_state()
self.ui.select_all.setEnabled(False)
self.enable_cleanup_changed()
def open_config_dir(self): def open_config_dir(self):
config = get_config() config = get_config()
@@ -397,10 +393,11 @@ class MaintenanceOptionsPage(OptionsPage):
value = config.setting.raw_value(key) value = config.setting.raw_value(key)
return repr(value) return repr(value)
def enable_cleanup_changed(self): def _set_cleanup_state(self):
state = self.ui.enable_cleanup.checkState() == QtCore.Qt.CheckState.Checked state = self.ui.tableWidget.rowCount() > 0
self.ui.select_all.setEnabled(state) 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) register_options_page(MaintenanceOptionsPage)

View File

@@ -92,9 +92,6 @@ class Ui_MaintenanceOptionsPage(object):
self.option_counts.setText("") self.option_counts.setText("")
self.option_counts.setObjectName("option_counts") self.option_counts.setObjectName("option_counts")
self.vboxlayout.addWidget(self.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 = QtWidgets.QLabel(parent=MaintenanceOptionsPage)
self.description.setText("") self.description.setText("")
self.description.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.description.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop)
@@ -109,9 +106,18 @@ class Ui_MaintenanceOptionsPage(object):
self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.line.setObjectName("line") self.line.setObjectName("line")
self.vboxlayout.addWidget(self.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 = QtWidgets.QCheckBox(parent=MaintenanceOptionsPage)
self.select_all.setObjectName("select_all") 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 = QtWidgets.QTableWidget(parent=MaintenanceOptionsPage)
self.tableWidget.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents) self.tableWidget.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)
self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers) self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
@@ -124,6 +130,14 @@ class Ui_MaintenanceOptionsPage(object):
self.retranslateUi(MaintenanceOptionsPage) self.retranslateUi(MaintenanceOptionsPage)
QtCore.QMetaObject.connectSlotsByName(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): def retranslateUi(self, MaintenanceOptionsPage):
self.label.setText(_("Configuration file:")) self.label.setText(_("Configuration file:"))
@@ -132,5 +146,5 @@ class Ui_MaintenanceOptionsPage(object):
self.browse_autobackup_dir.setText(_("Browse…")) self.browse_autobackup_dir.setText(_("Browse…"))
self.load_backup_button.setText(_("Load backup…")) self.load_backup_button.setText(_("Load backup…"))
self.save_backup_button.setText(_("Save backup…")) self.save_backup_button.setText(_("Save backup…"))
self.enable_cleanup.setText(_("Remove selected options"))
self.select_all.setText(_("Select all")) self.select_all.setText(_("Select all"))
self.enable_cleanup.setText(_("Remove selected options"))

View File

@@ -138,13 +138,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="enable_cleanup">
<property name="text">
<string>Remove selected options</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="description"> <widget class="QLabel" name="description">
<property name="text"> <property name="text">
@@ -185,11 +178,38 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="select_all"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="text"> <property name="topMargin">
<string>Select all</string> <number>0</number>
</property> </property>
</widget> <item>
<widget class="QCheckBox" name="select_all">
<property name="text">
<string>Select all</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="enable_cleanup">
<property name="text">
<string>Remove selected options</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QTableWidget" name="tableWidget"> <widget class="QTableWidget" name="tableWidget">
@@ -214,6 +234,17 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<tabstops>
<tabstop>config_file</tabstop>
<tabstop>open_folder_button</tabstop>
<tabstop>autobackup_dir</tabstop>
<tabstop>browse_autobackup_dir</tabstop>
<tabstop>load_backup_button</tabstop>
<tabstop>save_backup_button</tabstop>
<tabstop>select_all</tabstop>
<tabstop>enable_cleanup</tabstop>
<tabstop>tableWidget</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>