Skip to content

Commit

Permalink
Merge pull request #2434 from rdswift/options_maint_page_update
Browse files Browse the repository at this point in the history
PICARD-2876: Update the Options > Advanced > Maintenance page
  • Loading branch information
zas authored Apr 25, 2024
2 parents 92ca2d8 + ba65c3f commit 055547b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 31 deletions.
27 changes: 12 additions & 15 deletions picard/ui/options/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
})
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
24 changes: 19 additions & 5 deletions picard/ui/ui_options_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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:"))
Expand All @@ -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"))
53 changes: 42 additions & 11 deletions ui/options_maintenance.ui
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enable_cleanup">
<property name="text">
<string>Remove selected options</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="description">
<property name="text">
Expand Down Expand Up @@ -185,11 +178,38 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="select_all">
<property name="text">
<string>Select all</string>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</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>
<widget class="QTableWidget" name="tableWidget">
Expand All @@ -214,6 +234,17 @@
</item>
</layout>
</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/>
<connections/>
</ui>

0 comments on commit 055547b

Please sign in to comment.