From db05675957ab4ea379c14a1fcbfb911757ea2d4c Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Wed, 27 Mar 2024 13:56:58 +0100 Subject: [PATCH] PICARD-2848: Rename option "toolbar_multiselect" to "allow_multi_dirs_selection" - the old name isn't explicit enough, and it isn't related to toolbar anymore at all --- picard/__init__.py | 2 +- picard/config_upgrade.py | 8 ++++++++ picard/profile.py | 2 +- picard/ui/mainwindow.py | 2 +- picard/ui/options/interface.py | 16 ++++++++-------- picard/ui/ui_options_interface.py | 12 ++++++------ test/test_config_upgrade.py | 9 +++++++++ ui/options_interface.ui | 4 ++-- 8 files changed, 36 insertions(+), 19 deletions(-) diff --git a/picard/__init__.py b/picard/__init__.py index cbb891caa2..2f064db6e7 100644 --- a/picard/__init__.py +++ b/picard/__init__.py @@ -40,7 +40,7 @@ PICARD_DISPLAY_NAME = "MusicBrainz Picard" PICARD_APP_ID = "org.musicbrainz.Picard" PICARD_DESKTOP_NAME = PICARD_APP_ID + ".desktop" -PICARD_VERSION = Version(3, 0, 0, 'dev', 2) +PICARD_VERSION = Version(3, 0, 0, 'dev', 3) # optional build version diff --git a/picard/config_upgrade.py b/picard/config_upgrade.py index 66bb44ca9a..bc0d7e1040 100644 --- a/picard/config_upgrade.py +++ b/picard/config_upgrade.py @@ -511,6 +511,13 @@ def upgrade_to_v3_0_0_dev_2(config): config.persist['splitters_OptionsDialog'] = b'' +def upgrade_to_v3_0_0_dev_3(config): + """Option "toolbar_multiselect" was renamed to "allow_multi_dirs_selection".""" + old_opt = 'toolbar_multiselect' + new_opt = 'allow_multi_dirs_selection' + rename_option(config, old_opt, new_opt, BoolOption, False) + + def rename_option(config, old_opt, new_opt, option_type, default): _s = config.setting if old_opt in _s: @@ -558,4 +565,5 @@ def upgrade_config(config): cfg.register_upgrade_hook(upgrade_to_v2_9_0_alpha_2) cfg.register_upgrade_hook(upgrade_to_v3_0_0_dev_1) cfg.register_upgrade_hook(upgrade_to_v3_0_0_dev_2) + cfg.register_upgrade_hook(upgrade_to_v3_0_0_dev_3) cfg.run_upgrade_hooks(log.debug) diff --git a/picard/profile.py b/picard/profile.py index 5fe3f66a31..b86ac678c9 100644 --- a/picard/profile.py +++ b/picard/profile.py @@ -187,7 +187,7 @@ class UserProfileGroups(): SettingDesc('show_menu_icons', N_("Show icons in menus"), ['show_menu_icons']), SettingDesc('ui_language', N_("User interface language"), ['ui_language', 'label']), SettingDesc('ui_theme', N_("User interface color theme"), ['ui_theme', 'label_theme']), - SettingDesc('toolbar_multiselect', N_("Allow selection of multiple directories"), ['toolbar_multiselect']), + SettingDesc('allow_multi_dirs_selection', N_("Allow selection of multiple directories"), ['allow_multi_dirs_selection']), SettingDesc('builtin_search', N_("Use builtin search rather than looking in browser"), ['builtin_search']), SettingDesc('use_adv_search_syntax', N_("Use advanced search syntax"), ['use_adv_search_syntax']), SettingDesc('show_new_user_dialog', N_("Show a usage warning dialog when Picard starts"), ['new_user_dialog']), diff --git a/picard/ui/mainwindow.py b/picard/ui/mainwindow.py index e783fcff84..ce91508668 100644 --- a/picard/ui/mainwindow.py +++ b/picard/ui/mainwindow.py @@ -1280,7 +1280,7 @@ def add_directory(self): dir_list = [] config = get_config() - if not config.setting['toolbar_multiselect']: + if not config.setting['allow_multi_dirs_selection']: directory = QtWidgets.QFileDialog.getExistingDirectory(self, "", current_directory) if directory: dir_list.append(directory) diff --git a/picard/ui/options/interface.py b/picard/ui/options/interface.py index 7f26da6d82..f83c67fc8d 100644 --- a/picard/ui/options/interface.py +++ b/picard/ui/options/interface.py @@ -72,7 +72,7 @@ class InterfaceOptionsPage(OptionsPage): options = [ BoolOption('setting', 'toolbar_show_labels', True), - BoolOption('setting', 'toolbar_multiselect', False), + BoolOption('setting', 'allow_multi_dirs_selection', False), BoolOption('setting', 'show_menu_icons', True if not IS_MACOS else False), # On macOS it is not common that the global menu shows icons BoolOption('setting', 'builtin_search', True), BoolOption('setting', 'use_adv_search_syntax', False), @@ -143,16 +143,16 @@ def fcmp(x): if not OS_SUPPORTS_THEMES: self.ui.ui_theme_container.hide() - self.ui.toolbar_multiselect.stateChanged.connect(self.multi_selection_warning) + self.ui.allow_multi_dirs_selection.stateChanged.connect(self.multi_selection_warning) def load(self): # Don't display the multi-selection warning when loading values. # This is required because loading a different option profile could trigger the warning. - self.ui.toolbar_multiselect.blockSignals(True) + self.ui.allow_multi_dirs_selection.blockSignals(True) config = get_config() self.ui.toolbar_show_labels.setChecked(config.setting['toolbar_show_labels']) - self.ui.toolbar_multiselect.setChecked(config.setting['toolbar_multiselect']) + self.ui.allow_multi_dirs_selection.setChecked(config.setting['allow_multi_dirs_selection']) self.ui.show_menu_icons.setChecked(config.setting['show_menu_icons']) self.ui.builtin_search.setChecked(config.setting['builtin_search']) self.ui.use_adv_search_syntax.setChecked(config.setting['use_adv_search_syntax']) @@ -168,12 +168,12 @@ def load(self): self.ui.ui_theme.setCurrentIndex(self.ui.ui_theme.findData(current_theme)) # re-enable the multi-selection warning - self.ui.toolbar_multiselect.blockSignals(False) + self.ui.allow_multi_dirs_selection.blockSignals(False) def save(self): config = get_config() config.setting['toolbar_show_labels'] = self.ui.toolbar_show_labels.isChecked() - config.setting['toolbar_multiselect'] = self.ui.toolbar_multiselect.isChecked() + config.setting['allow_multi_dirs_selection'] = self.ui.allow_multi_dirs_selection.isChecked() config.setting['show_menu_icons'] = self.ui.show_menu_icons.isChecked() self.tagger.enable_menu_icons(config.setting['show_menu_icons']) config.setting['builtin_search'] = self.ui.builtin_search.isChecked() @@ -218,7 +218,7 @@ def starting_directory_browse(self): item.setText(path) def multi_selection_warning(self): - if not self.ui.toolbar_multiselect.isChecked(): + if not self.ui.allow_multi_dirs_selection.isChecked(): return dialog = QtWidgets.QMessageBox( @@ -232,7 +232,7 @@ def multi_selection_warning(self): QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, self) if dialog.exec() == QtWidgets.QMessageBox.StandardButton.No: - self.ui.toolbar_multiselect.setCheckState(QtCore.Qt.CheckState.Unchecked) + self.ui.allow_multi_dirs_selection.setCheckState(QtCore.Qt.CheckState.Unchecked) register_options_page(InterfaceOptionsPage) diff --git a/picard/ui/ui_options_interface.py b/picard/ui/ui_options_interface.py index 074b22fb00..c7b2b3f06f 100644 --- a/picard/ui/ui_options_interface.py +++ b/picard/ui/ui_options_interface.py @@ -52,9 +52,9 @@ def setupUi(self, InterfaceOptionsPage): self.miscellaneous_box.setObjectName("miscellaneous_box") self.vboxlayout1 = QtWidgets.QVBoxLayout(self.miscellaneous_box) self.vboxlayout1.setObjectName("vboxlayout1") - self.toolbar_multiselect = QtWidgets.QCheckBox(self.miscellaneous_box) - self.toolbar_multiselect.setObjectName("toolbar_multiselect") - self.vboxlayout1.addWidget(self.toolbar_multiselect) + self.allow_multi_dirs_selection = QtWidgets.QCheckBox(self.miscellaneous_box) + self.allow_multi_dirs_selection.setObjectName("allow_multi_dirs_selection") + self.vboxlayout1.addWidget(self.allow_multi_dirs_selection) self.builtin_search = QtWidgets.QCheckBox(self.miscellaneous_box) self.builtin_search.setObjectName("builtin_search") self.vboxlayout1.addWidget(self.builtin_search) @@ -104,8 +104,8 @@ def setupUi(self, InterfaceOptionsPage): InterfaceOptionsPage.setTabOrder(self.toolbar_show_labels, self.show_menu_icons) InterfaceOptionsPage.setTabOrder(self.show_menu_icons, self.ui_language) InterfaceOptionsPage.setTabOrder(self.ui_language, self.ui_theme) - InterfaceOptionsPage.setTabOrder(self.ui_theme, self.toolbar_multiselect) - InterfaceOptionsPage.setTabOrder(self.toolbar_multiselect, self.builtin_search) + InterfaceOptionsPage.setTabOrder(self.ui_theme, self.allow_multi_dirs_selection) + InterfaceOptionsPage.setTabOrder(self.allow_multi_dirs_selection, self.builtin_search) InterfaceOptionsPage.setTabOrder(self.builtin_search, self.use_adv_search_syntax) InterfaceOptionsPage.setTabOrder(self.use_adv_search_syntax, self.new_user_dialog) InterfaceOptionsPage.setTabOrder(self.new_user_dialog, self.quit_confirmation) @@ -123,7 +123,7 @@ def retranslateUi(self, InterfaceOptionsPage): self.label.setText(_("User interface language:")) self.label_theme.setText(_("User interface color theme:")) self.miscellaneous_box.setTitle(_("Miscellaneous")) - self.toolbar_multiselect.setText(_("Allow selection of multiple directories")) + self.allow_multi_dirs_selection.setText(_("Allow selection of multiple directories")) self.builtin_search.setText(_("Use builtin search rather than looking in browser")) self.use_adv_search_syntax.setText(_("Use advanced query syntax")) self.new_user_dialog.setText(_("Show the new user dialog when starting Picard")) diff --git a/test/test_config_upgrade.py b/test/test_config_upgrade.py index cdc57b249c..b7a56d5e82 100644 --- a/test/test_config_upgrade.py +++ b/test/test_config_upgrade.py @@ -58,6 +58,7 @@ upgrade_to_v2_6_0_beta_3, upgrade_to_v2_6_0_dev_1, upgrade_to_v2_8_0_dev_2, + upgrade_to_v3_0_0_dev_3, ) from picard.const import ( DEFAULT_FILE_NAMING_FORMAT, @@ -364,3 +365,11 @@ def test_upgrade_to_v2_8_0_dev_2(self): self.assertEqual(expected, self.config.setting['toolbar_layout']) upgrade_to_v2_8_0_dev_2(self.config) self.assertEqual(expected, self.config.setting['toolbar_layout']) + + def test_upgrade_to_v3_0_0_dev_3(self): + BoolOption('setting', 'allow_multi_dirs_selection', False) + + self.config.setting['toolbar_multiselect'] = True + upgrade_to_v3_0_0_dev_3(self.config) + self.assertNotIn('toolbar_multiselect', self.config.setting) + self.assertTrue(self.config.setting['allow_multi_dirs_selection']) diff --git a/ui/options_interface.ui b/ui/options_interface.ui index 80938c09f1..0f3b07b99d 100644 --- a/ui/options_interface.ui +++ b/ui/options_interface.ui @@ -95,7 +95,7 @@ - + Allow selection of multiple directories @@ -218,7 +218,7 @@ show_menu_icons ui_language ui_theme - toolbar_multiselect + allow_multi_dirs_selection builtin_search use_adv_search_syntax new_user_dialog