User Preferences: Added "Enabled add-ons only" preference

This checkbox replaces the "Disabled" and "Enabled" entries in the
filter drop-down. As a result, it now takes a single click to limit the
shown entries to enabled add-ons only. This is also an actual flag in
the preferences, and thus its state is saved between runs on Blender (in
contrast to the filter, which is always reset to "All").

Reviewed by: brecht, billreynish
This commit is contained in:
Sybren A. Stüvel 2019-08-15 10:21:04 +02:00
parent ecc3b033a7
commit 078d02f557
Notes: blender-bot 2023-02-14 08:39:23 +01:00
Referenced by issue #68816, Inconsistent Selection Behaviour of Hidden Armature using Circle Selection Tool
Referenced by issue #68752, Report are reported multiple time
5 changed files with 20 additions and 9 deletions

View File

@ -667,6 +667,7 @@ class PREFERENCES_OT_addon_install(Operator):
info = addon_utils.module_bl_info(mod)
# show the newly installed addon.
context.preferences.view.show_addons_enabled_only = False
context.window_manager.addon_filter = 'All'
context.window_manager.addon_search = info["name"]
break
@ -796,6 +797,7 @@ class PREFERENCES_OT_addon_show(Operator):
info["show_expanded"] = True
context.preferences.active_section = 'ADDONS'
context.preferences.view.show_addons_enabled_only = False
context.window_manager.addon_filter = 'All'
context.window_manager.addon_search = info["name"]
bpy.ops.screen.userpref_show('INVOKE_DEFAULT')

View File

@ -126,8 +126,6 @@ def register():
items = [
('All', "All", "All Add-ons"),
('User', "User", "All Add-ons Installed by User"),
('Enabled', "Enabled", "All Enabled Add-ons"),
('Disabled', "Disabled", "All Disabled Add-ons"),
]
items_unique = set()

View File

@ -1744,6 +1744,7 @@ class USERPREF_PT_addons(Panel):
row.operator("preferences.addon_refresh", icon='FILE_REFRESH', text="Refresh")
row = layout.row()
row.prop(context.preferences.view, "show_addons_enabled_only")
row.prop(context.window_manager, "addon_filter", text="")
row.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
@ -1770,6 +1771,7 @@ class USERPREF_PT_addons(Panel):
"(see console for details)",
)
show_enabled_only = context.preferences.view.show_addons_enabled_only
filter = context.window_manager.addon_filter
search = context.window_manager.addon_search.lower()
support = context.window_manager.addon_support
@ -1786,13 +1788,15 @@ class USERPREF_PT_addons(Panel):
continue
# check if addon should be visible with current filters
if (
(filter == "All") or
(filter == info["category"]) or
(filter == "Enabled" and is_enabled) or
(filter == "Disabled" and not is_enabled) or
(filter == "User" and (mod.__file__.startswith(addon_user_dirs)))
):
is_visible = (
(filter == "All") or
(filter == info["category"]) or
(filter == "User" and (mod.__file__.startswith(addon_user_dirs)))
)
if show_enabled_only:
is_visible = is_visible and is_enabled
if is_visible:
if search and search not in info["name"].lower():
if info["author"]:
if search not in info["author"].lower():

View File

@ -868,6 +868,7 @@ typedef enum eUserPref_Flag {
USER_NONEGFRAMES = (1 << 24),
USER_TXT_TABSTOSPACES_DISABLE = (1 << 25),
USER_TOOLTIPS_PYTHON = (1 << 26),
USER_ADDONS_ENABLED_ONLY = (1 << 27),
} eUserPref_Flag;
typedef enum eUserPref_PrefFlag {

View File

@ -4090,6 +4090,12 @@ static void rna_def_userdef_view(BlenderRNA *brna)
"Show the frames per second screen refresh rate, while animation is played back");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "show_addons_enabled_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_ADDONS_ENABLED_ONLY);
RNA_def_property_ui_text(prop,
"Enabled Add-ons Only",
"Only show enabled add-ons. Un-check to see all installed add-ons");
static const EnumPropertyItem factor_display_items[] = {
{USER_FACTOR_AS_FACTOR, "FACTOR", 0, "Factor", "Display factors as values between 0 and 1"},
{USER_FACTOR_AS_PERCENTAGE, "PERCENTAGE", 0, "Percentage", "Display factors as percentages"},