Skip to content

Commit

Permalink
PICARD-2848: Rename option "toolbar_multiselect" to "allow_multi_dirs…
Browse files Browse the repository at this point in the history
…_selection"

- the old name isn't explicit enough, and it isn't related to toolbar anymore at all
  • Loading branch information
zas committed Mar 30, 2024
1 parent 8af19d4 commit db05675
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion picard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions picard/config_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion picard/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
2 changes: 1 addition & 1 deletion picard/ui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions picard/ui/options/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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'])
Expand All @@ -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()
Expand Down Expand Up @@ -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(
Expand All @@ -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)
12 changes: 6 additions & 6 deletions picard/ui/ui_options_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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"))
Expand Down
9 changes: 9 additions & 0 deletions test/test_config_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'])
4 changes: 2 additions & 2 deletions ui/options_interface.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QCheckBox" name="toolbar_multiselect">
<widget class="QCheckBox" name="allow_multi_dirs_selection">
<property name="text">
<string>Allow selection of multiple directories</string>
</property>
Expand Down Expand Up @@ -218,7 +218,7 @@
<tabstop>show_menu_icons</tabstop>
<tabstop>ui_language</tabstop>
<tabstop>ui_theme</tabstop>
<tabstop>toolbar_multiselect</tabstop>
<tabstop>allow_multi_dirs_selection</tabstop>
<tabstop>builtin_search</tabstop>
<tabstop>use_adv_search_syntax</tabstop>
<tabstop>new_user_dialog</tabstop>
Expand Down

0 comments on commit db05675

Please sign in to comment.