Repository: napari/napari

Issue:
Support Enum preference types in preferences window
## 🐛 Bug

We are unable to show preferences that are `Enum` types in the preferences window

see: https://github.com/napari/napari/pull/2211#pullrequestreview-610272341 for a little background



Discussion:
@tlambert03 indeed, I think I want to rework a bit all this logic to remove the qtform external dependency and support more use cases here. 
thanks!

Resolving patch:
diff --git a/napari/_qt/dialogs/preferences_dialog.py b/napari/_qt/dialogs/preferences_dialog.py
--- a/napari/_qt/dialogs/preferences_dialog.py
+++ b/napari/_qt/dialogs/preferences_dialog.py
@@ -95,7 +95,6 @@ def make_dialog(self):
         # Because there are multiple pages, need to keep a dictionary of values dicts.
         # One set of keywords are for each page, then in each entry for a page, there are dicts
         # of setting and its value.
-
         self._values_orig_dict = {}
         self._values_dict = {}
         self._setting_changed_dict = {}
@@ -130,8 +129,20 @@ def get_page_dict(self, setting):
             Dictionary of properties within the json schema.
 
         """
-
         schema = json.loads(setting['json_schema'])
+
+        # Resolve allOf references
+        definitions = schema.get("definitions", {})
+        if definitions:
+            for key, data in schema["properties"].items():
+                if "allOf" in data:
+                    allof = data["allOf"]
+                    allof = [d["$ref"].rsplit("/")[-1] for d in allof]
+                    for definition in allof:
+                        local_def = definitions[definition]
+                        schema["properties"][key]["enum"] = local_def["enum"]
+                        schema["properties"][key]["type"] = "string"
+
         # Need to remove certain properties that will not be displayed on the GUI
         properties = schema.pop('properties')
         model = setting['model']
diff --git a/napari/utils/settings/_defaults.py b/napari/utils/settings/_defaults.py
--- a/napari/utils/settings/_defaults.py
+++ b/napari/utils/settings/_defaults.py
@@ -263,12 +263,20 @@ class ApplicationSettings(BaseNapariSettings):
     window_state: str = None
     window_statusbar: bool = True
     preferences_size: Tuple[int, int] = None
-    # TODO: Might be breaking preferences?
-    gui_notification_level: NotificationSeverity = NotificationSeverity.INFO
-    console_notification_level: NotificationSeverity = (
-        NotificationSeverity.NONE
+    gui_notification_level: NotificationSeverity = Field(
+        NotificationSeverity.INFO,
+        title=trans._("GUI notification level"),
+        description=trans._(
+            "Set the notification level for the notification manager."
+        ),
+    )
+    console_notification_level: NotificationSeverity = Field(
+        NotificationSeverity.NONE,
+        title=trans._("Console notification level"),
+        description=trans._(
+            "Set the notification level for the console notifications."
+        ),
     )
-
     open_history: List = [os.path.dirname(Path.home())]
     save_history: List = [os.path.dirname(Path.home())]
 
@@ -288,8 +296,6 @@ class NapariConfig:
             "window_fullscreen",
             "window_state",
             "window_statusbar",
-            "gui_notification_level",
-            "console_notification_level",
             "open_history",
             "save_history",
             "ipy_interactive",


Test patch: