From 7a3f99f258a3343d4097efea908bc7582cda5fda Mon Sep 17 00:00:00 2001 From: Bob Swift Date: Wed, 15 Sep 2021 10:56:03 -0600 Subject: [PATCH] Add config file name and link to Maintenance options page --- picard/ui/options/maintenance.py | 12 ++++ picard/ui/ui_options_maintenance.py | 44 +++++++----- ui/options_maintenance.ui | 100 +++++++++++++--------------- 3 files changed, 88 insertions(+), 68 deletions(-) diff --git a/picard/ui/options/maintenance.py b/picard/ui/options/maintenance.py index d28c6e963..50734afa2 100644 --- a/picard/ui/options/maintenance.py +++ b/picard/ui/options/maintenance.py @@ -19,8 +19,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +from os import path + from PyQt5 import ( QtCore, + QtGui, QtWidgets, ) @@ -82,10 +85,14 @@ class MaintenanceOptionsPage(OptionsPage): 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) def load(self): config = get_config() + # Show the path and file name of the currently used configuration file. + self.ui.config_file.setText(config.fileName()) + # Setting options from all option pages and loaded plugins (including plugins currently disabled). key_options = set(config.setting.as_dict()) @@ -133,6 +140,11 @@ class MaintenanceOptionsPage(OptionsPage): self.ui.select_all.setEnabled(False) self.enable_cleanup_changed() + def open_config_dir(self): + config = get_config() + config_dir = path.split(config.fileName())[0] + QtGui.QDesktopServices.openUrl(QtCore.QUrl.fromLocalFile(config_dir)) + def column_items(self, column): for idx in range(self.ui.tableWidget.rowCount()): yield self.ui.tableWidget.item(idx, column) diff --git a/picard/ui/ui_options_maintenance.py b/picard/ui/ui_options_maintenance.py index 56c03f60d..f5589717f 100644 --- a/picard/ui/ui_options_maintenance.py +++ b/picard/ui/ui_options_maintenance.py @@ -13,15 +13,20 @@ class Ui_MaintenanceOptionsPage(object): MaintenanceOptionsPage.resize(334, 397) self.vboxlayout = QtWidgets.QVBoxLayout(MaintenanceOptionsPage) self.vboxlayout.setObjectName("vboxlayout") - self.description = QtWidgets.QLabel(MaintenanceOptionsPage) - self.description.setText("") - self.description.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.description.setWordWrap(True) - self.description.setIndent(0) - self.description.setObjectName("description") - self.vboxlayout.addWidget(self.description) - spacerItem = QtWidgets.QSpacerItem(20, 8, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) - self.vboxlayout.addItem(spacerItem) + self.label = QtWidgets.QLabel(MaintenanceOptionsPage) + self.label.setObjectName("label") + self.vboxlayout.addWidget(self.label) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) + self.horizontalLayout.setObjectName("horizontalLayout") + self.config_file = QtWidgets.QLineEdit(MaintenanceOptionsPage) + self.config_file.setReadOnly(True) + self.config_file.setObjectName("config_file") + self.horizontalLayout.addWidget(self.config_file) + self.open_folder_button = QtWidgets.QToolButton(MaintenanceOptionsPage) + self.open_folder_button.setObjectName("open_folder_button") + self.horizontalLayout.addWidget(self.open_folder_button) + self.vboxlayout.addLayout(self.horizontalLayout) self.option_counts = QtWidgets.QLabel(MaintenanceOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) @@ -31,18 +36,23 @@ class Ui_MaintenanceOptionsPage(object): self.option_counts.setText("") self.option_counts.setObjectName("option_counts") self.vboxlayout.addWidget(self.option_counts) - spacerItem1 = QtWidgets.QSpacerItem(20, 8, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) - self.vboxlayout.addItem(spacerItem1) + self.enable_cleanup = QtWidgets.QCheckBox(MaintenanceOptionsPage) + self.enable_cleanup.setObjectName("enable_cleanup") + self.vboxlayout.addWidget(self.enable_cleanup) + self.description = QtWidgets.QLabel(MaintenanceOptionsPage) + self.description.setText("") + self.description.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.description.setWordWrap(True) + self.description.setIndent(0) + self.description.setObjectName("description") + self.vboxlayout.addWidget(self.description) + spacerItem = QtWidgets.QSpacerItem(20, 8, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + self.vboxlayout.addItem(spacerItem) self.line = QtWidgets.QFrame(MaintenanceOptionsPage) self.line.setFrameShape(QtWidgets.QFrame.HLine) self.line.setFrameShadow(QtWidgets.QFrame.Sunken) self.line.setObjectName("line") self.vboxlayout.addWidget(self.line) - spacerItem2 = QtWidgets.QSpacerItem(20, 8, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) - self.vboxlayout.addItem(spacerItem2) - self.enable_cleanup = QtWidgets.QCheckBox(MaintenanceOptionsPage) - self.enable_cleanup.setObjectName("enable_cleanup") - self.vboxlayout.addWidget(self.enable_cleanup) self.select_all = QtWidgets.QCheckBox(MaintenanceOptionsPage) self.select_all.setObjectName("select_all") self.vboxlayout.addWidget(self.select_all) @@ -61,5 +71,7 @@ class Ui_MaintenanceOptionsPage(object): def retranslateUi(self, MaintenanceOptionsPage): _translate = QtCore.QCoreApplication.translate + self.label.setText(_("Configuration File:")) + self.open_folder_button.setText(_("Open folder")) self.enable_cleanup.setText(_("Remove selected options")) self.select_all.setText(_("Select all")) diff --git a/ui/options_maintenance.ui b/ui/options_maintenance.ui index d42cc9950..3dcb5d8ec 100644 --- a/ui/options_maintenance.ui +++ b/ui/options_maintenance.ui @@ -11,6 +11,54 @@ + + + + Configuration File: + + + + + + + 0 + + + + + true + + + + + + + Open folder + + + + + + + + + + 0 + 0 + + + + + + + + + + + Remove selected options + + + @@ -43,35 +91,6 @@ - - - - - 0 - 0 - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - @@ -79,29 +98,6 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - - - Remove selected options - - -