Page MenuHome

Fix: Possible to add multiple presets with the same name
Needs ReviewPublic

Authored by Hans Goudey (HooglyBoogly) on Sep 29 2020, 11:13 PM.

Details

Summary

The preset system doesn't seem to be designed to handle this.
This check would resolve T80188, although not for existing files.

Diff Detail

Repository
rB Blender
Branch
preset-already-exists-check (branched from master)
Build Status
Buildable 10477
Build 10477: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Sep 29 2020, 11:13 PM
Hans Goudey (HooglyBoogly) created this revision.
Campbell Barton (campbellbarton) requested changes to this revision.EditedSep 30 2020, 6:04 AM

In general this is fine, it can be more user friendly though.

This can show a message when the filename exists, (before they press OK).

The WARNING + CANCEL can be kept (to disallow adding the preset if this operator is activated some other way).


Suggested implementation:

  • Add a draw function to so a label if the preset exists.
  • Move the preset-exists check into a staticmethod so it can be called by check and execute.
  • Use the check callback to set a class variable to true when it does.
  • Use this variable when drawing the UI, showing a label and the red-alert highlight, as we do when overwriting files.

Or, if you prefer to commit this change as is. It's still be nicer to put the check in a static method.


Note that we could support overwriting existing presets, users may prefer this to having to manually remove first. Although that gets more complicated when some presets are from the system which the user wont have write access.

This revision now requires changes to proceed.Sep 30 2020, 6:04 AM

I agree it could be more user friendly

One issue with drawing a warning label is that it would cause the popover to resize, then it can't resize back properly when the warning goes away.

Graying out the "Add preset" button might be a simpler method. Ideally it could be done with poll so that we could set a message for the tooltip, but that has no access to properties.

  • Use the check callback to set a class variable to true when it does.
  • Use this variable when drawing the UI, showing a label and the red-alert highlight, as we do when overwriting files.

Only issue I'm seeing with this is that the class variable would be in the add operator, which I don't think can be accessed in the Menu.draw_preset function. Maybe I'm wrong though.

  • WIP implementing Campbell's suggestions