Skip to content

Added preference setting to solve persistence as optional toggle. #244

Closed
Sekuora wants to merge 4 commits into
nutti:masterfrom
Sekuora:master
Closed

Added preference setting to solve persistence as optional toggle. #244
Sekuora wants to merge 4 commits into
nutti:masterfrom
Sekuora:master

Conversation

@Sekuora

@Sekuora Sekuora commented Jun 6, 2026

Copy link
Copy Markdown

Dear nutti, this is a proposal that adds persistence in the add-on. Creating settings that could be later on shared between other installations of screencast keys and survive add-on reloads.

I hope you can evaluate if it serves the development of the add-on. Otherwise, I hope it serves as inspiration for future add-on features.

What was changed:

  • Added a new add-on preference: Persist Preferences.
  • When enabled, the add-on saves its preferences to:
    Blender user config/screencast_keys/preferences.json
  • When the add-on is enabled again, it loads that .json file and restores saved preferences.
  • When Persist Preferences is disabled, it removes the .json file and keeps the behavior that restores settings to defaults.

How it works:

image
2026-06-05.20-15-45.mp4
  • Additional benefits are that this save data file can be shared. With import/export buttons (not done yet).
  • Implementation can go further and store custom mouse data, local to the add-on. Currently stores custom image data paths only.

Example persistence file:
preferences.json

What gets persisted:

  • Normal display settings like color, font size, margins, alignment, etc.
  • UI settings like sidebar/overlay visibility, panel space, and panel category.
  • Custom mouse image settings and file paths.
  • Display event text alias settings, including alias collection values.
  • Other supported Blender RNA preference values: booleans, numbers, strings, enums, arrays, and collections.

Implementation details:

  • Added generic preference serialization/deserialization helpers in preferences.py.
  • Used as much of best practices for blender add-ons persistent settings as possible.
  • Added load-on-register and save/remove-on-unregister hooks in __init__.py.
  • Moved the existing display-event-alias initialization into a helper so restored aliases are not overwritten.

Sekuora added 2 commits June 5, 2026 20:01
Added a new add-on preference: Persist Preferences.
When enabled, the add-on saves its preferences to:
Blender user config/screencast_keys/preferences.json

@nutti nutti left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting feature.
Thank you @Sekuora .

We need some document for the user.
Is it possible to update this document as well?
https://github.com/nutti/Screencast-Keys/blob/master/docs/tutorial.md

Also, introducing importing/exporting configuration function is a nice idea.

@nutti nutti left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferences.SK_Preferences.ui_in_sidebar_update_fn(prefs, context)
preferences.SK_Preferences.ui_in_overlay_update_fn(prefs, context)

# Fix: https://github.com/nutti/Screencast-Keys/issues/195

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is my understanding correct, this is still valid when there is no configuration file,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tested and there's no traces of that.

The fix is now part of the function def ensure_display_event_text_aliases(prefs) in preferences.py.

This will create a dictionary containing all the known keys taking from ops.EventType.names[event.name] same ones used by default and guarantees a single entry per item.

Then it reads from the user overrides which don't need to be persisted on the save file for this to work, keeping the fix.

Comment thread src/screencast_keys/preferences.py Outdated
return

data = {
"version": 1,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we follow semantic versioning?
In this case, 1.0.0 is good.

Comment thread src/screencast_keys/preferences.py Outdated


def ensure_display_event_text_aliases(prefs):
from . import ops # pylint: disable=C0415

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to the top-level import instead of here.


data = {
"version": 1,
"persist_preferences": True,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this item mean?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the entry point for the persist Boolean of the new setting. It has to be written explicitly the first time a preferences file is created to keep track if the user want to restore this setting file or delete it. Maybe I can think of aa different name.

@nutti nutti added the enhancement New feature or request label Jun 13, 2026
@nutti nutti added this to the Version 4.3.0 milestone Jun 13, 2026
Sekuora added 2 commits June 13, 2026 17:13
Fixed the misplaced import.
Changed version from single number to string type
Wrote an explanation for the persist preferences feature.

@Sekuora Sekuora left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thanks for the review.
I changed this:

  1. The save file version name from 1 to 1.0.0
  2. Permissions in manifest file now include "files" using the extensions guide format.
  3. Explanation of what the persist preferences feature does in docs.

please let me know if anything else comes up.

@Sekuora Sekuora closed this Jul 3, 2026
@nutti

nutti commented Jul 5, 2026

Copy link
Copy Markdown
Owner

@Sekuora
Sorry for the late response.
Do you want to abandon this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants