From 5edad5d440e9fa59bf63a75a9fb362e295de91a3 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Fri, 26 Apr 2024 16:21:51 +0200 Subject: [PATCH] SettingDesc.fields -> SettingDesc.highlights, more consistent --- picard/profile.py | 2 +- picard/ui/options/dialog.py | 6 +++--- test/test_profiles.py | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/picard/profile.py b/picard/profile.py index 0360c45d7..f1ff5f976 100644 --- a/picard/profile.py +++ b/picard/profile.py @@ -29,7 +29,7 @@ from collections import ( ) -SettingDesc = namedtuple('SettingDesc', ('name', 'fields')) +SettingDesc = namedtuple('SettingDesc', ('name', 'highlights')) class UserProfileGroups(): diff --git a/picard/ui/options/dialog.py b/picard/ui/options/dialog.py index a3afd5f49..7560e4384 100644 --- a/picard/ui/options/dialog.py +++ b/picard/ui/options/dialog.py @@ -252,12 +252,12 @@ class OptionsDialog(PicardDialog, SingletonDialog): if load_settings: page.load() for opt in option_group['settings']: - for opt_field in opt.fields: + for objname in opt.highlights: try: - obj = getattr(page.ui, opt_field) + obj = getattr(page.ui, objname) except AttributeError: continue - style = "#%s { color: %s; background-color: %s; }" % (opt_field, fg_color, bg_color) + style = "#%s { color: %s; background-color: %s; }" % (objname, fg_color, bg_color) self._check_and_highlight_option(obj, opt.name, working_profiles, working_settings, style) def _check_and_highlight_option(self, obj, option_name, working_profiles, working_settings, style): diff --git a/test/test_profiles.py b/test/test_profiles.py index eaa414bb6..63566ace8 100644 --- a/test/test_profiles.py +++ b/test/test_profiles.py @@ -68,7 +68,8 @@ class TestPicardProfilesCommon(PicardTestCase): group = 'group%d' % (n % 2) title = 'title_' + group name = 'opt%d' % n - UserProfileGroups.append_to_group(group, name, tuple(range(0, n)), title=title) + highlights = ('obj%d' % i for i in range(0, n)) + UserProfileGroups.append_to_group(group, name, highlights, title=title) option_settings = list(UserProfileGroups.all_settings()) self.test_setting_0 = option_settings[0] self.test_setting_1 = option_settings[1] @@ -122,17 +123,17 @@ class TestUserProfileGroups(TestPicardProfilesCommon): def test_settings_have_no_blank_keys(self): for key in UserProfileGroups.keys(): settings = UserProfileGroups.settings(key) - for key, fields in settings: - self.assertNotEqual(key.strip(), "") + for name, highlights in settings: + self.assertNotEqual(name.strip(), "") def test_groups_have_title(self): for value in UserProfileGroups.values(): self.assertTrue(value['title'].startswith('title_')) def test_groups_have_highlights(self): - for key in UserProfileGroups.keys(): - for setting in UserProfileGroups.settings(key): - self.assertIsNotNone(setting.fields) + for group in UserProfileGroups.keys(): + for setting in UserProfileGroups.settings(group): + self.assertIsNotNone(setting.highlights) def test_order(self): result_before = [value['title'] for value in UserProfileGroups.values()]