UI: Improved Operator to Delete Custom Keyconfigs #118778

Merged
Harley Acheson merged 1 commits from Harley/blender:RemoveCustomKeyconfig into main 2024-03-14 22:40:14 +01:00
Member

Changes to python operators that add and remove custom keyconfigs.
Removal gets poll function, separate name and description, and
confirmation.


In Preferences / Keymap you are able to add and remove custom keyconfigs by clicking on the "+" and "-" buttons.

However both of these buttons run the same operator, with the removal using a specific property. But this means that hovering over either "Add" or "Remove" show the exact tooltip text and description. This is hovering over the removal button:

image

But problems go a bit deeper with these. You can always add a new keyconfig, but you can only remove custom keyconfigs, not any of the built-in ones. And the removal button gives no indication of when it works, it just gives an error when it doesn't. And removing a custom keyconfig is a very destructive operation, yet does not give a confirmation.

This PR changes the "Add" operator slightly to give a more specific tooltip:

image

A new operator is made for removal. Not only does it get its own name and description, but a poll function too. So it will be disabled if the current item is not a custom keyconfig, and the tooltip will inform you on why it is disabled:

image

When it is used to remove a custom keyconfig, it will show a confirmation:

image

Changes to python operators that add and remove custom keyconfigs. Removal gets poll function, separate name and description, and confirmation. --- In Preferences / Keymap you are able to add and remove custom keyconfigs by clicking on the "+" and "-" buttons. However both of these buttons run the same operator, with the removal using a specific property. But this means that hovering over either "Add" or "Remove" show the exact tooltip text and description. This is hovering over the **removal** button: ![image](/attachments/b94a3a88-a963-4fa7-9186-508534e7166d) But problems go a bit deeper with these. You can always add a new keyconfig, but you can only remove custom keyconfigs, not any of the built-in ones. And the removal button gives no indication of when it works, it just gives an error when it doesn't. And removing a custom keyconfig is a very destructive operation, yet does not give a confirmation. This PR changes the "Add" operator slightly to give a more specific tooltip: ![image](/attachments/79a2c3bb-5d3c-42d2-83fb-2eca83b2dcb5) A new operator is made for removal. Not only does it get its own name and description, but a poll function too. So it will be disabled if the current item is not a custom keyconfig, and the tooltip will inform you on why it is disabled: ![image](/attachments/76ae0b4a-9ced-45cc-8c61-8caf586ccc0d) When it is used to remove a custom keyconfig, it will show a confirmation: ![image](/attachments/f042072c-37c2-4a90-8158-b1e8d049a9cb)
Harley Acheson added this to the User Interface project 2024-02-27 02:57:02 +01:00
Hans Goudey reviewed 2024-02-27 04:07:09 +01:00
Hans Goudey left a comment
Member

+1 for having a separate "remove" operator rather than giving a "remove" argument to the "add" operator!

+1 for having a separate "remove" operator rather than giving a "remove" argument to the "add" operator!
@ -596,0 +600,4 @@
preset_menu = "USERPREF_MT_keyconfigs"
preset_subdir = "keyconfig"
remove_active: BoolProperty(
Member

remove_active is unused now.

Also, seems it should be fully removed from the AddPresetKeyconfig operator, which seems to mean removing pre_cb and post_cb?

`remove_active` is unused now. Also, seems it should be fully removed from the `AddPresetKeyconfig` operator, which seems to mean removing `pre_cb` and `post_cb`?
Harley marked this conversation as resolved

For the label and descriptions, I think it would be better to use "keymap configuration" than "keyconfig".

For the label and descriptions, I think it would be better to use "keymap configuration" than "keyconfig".
Author
Member

@brecht - For the label and descriptions, I think it would be better to use "keymap configuration" than "keyconfig".

Thanks! I struggled with that wording since we currently use both "Keyconfig" and "Key-config" and each seems odd.

@HooglyBoogly remove_active is unused now.

That's a bit odd, so maybe I am missing something. If I just remove that section it won't work because this is an AddPresetBase which defines that - set to false. This is just overriding that to true. I could probably remove that and then override the "add" function but that seemed to look confusing, doing this removal in a function called "add".

Also, seems it should be fully removed from the AddPresetKeyconfig operator, which seems to mean removing pre_cb and post_cb?

Oh yes, Thanks! I guess no need to worry about any other scripts but ours calling the add with remove argument.

> @brecht - For the label and descriptions, I think it would be better to use "keymap configuration" than "keyconfig". Thanks! I struggled with that wording since we currently use both "Keyconfig" and "Key-config" and each seems odd. > @HooglyBoogly remove_active is unused now. That's a bit odd, so maybe I am missing something. If I just remove that section it won't work because this is an `AddPresetBase` which defines that - set to false. This is just overriding that to true. I could probably remove that and then override the "add" function but that seemed to look confusing, doing this removal in a function called "add". > Also, seems it should be fully removed from the AddPresetKeyconfig operator, which seems to mean removing pre_cb and post_cb? Oh yes, Thanks! I guess no need to worry about any other scripts but ours calling the add with remove argument.
Harley Acheson force-pushed RemoveCustomKeyconfig from 6e14d3aebb to 8d2ed94302 2024-03-14 22:38:48 +01:00 Compare
Harley Acheson merged commit 57729aa8bb into main 2024-03-14 22:40:14 +01:00
Harley Acheson deleted branch RemoveCustomKeyconfig 2024-03-14 22:40:16 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#118778
No description provided.