Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filepath changes in preview mode #862

Merged
merged 2 commits into from Jan 27, 2024

Conversation

corubba
Copy link
Contributor

@corubba corubba commented Jan 21, 2024

There are multiple fields that store different parts of the filepath, like __filename and __dirname. With a real MockTag (like in non-preview mode) these fields are passed to the matching properties of the MockTag class, which in turn all (sometimes with some indirection) read/write from/to a single attribute named __filepath, which contains the absolute path of the file. This also means that writing one of the fields will automatically update all the others.
The preview doesn't have these properties/attribute, it is just a dict. And it wasn't treating these fields special, and didn't update the related fields. This is the reason why for example the __filename field, which is displayed in the table or tag panel, still showed the original value after you used the "tag to filename" function which only set the __path field. As soon as the preview is written, the MockTag implementation is used again, and the fields are properly updated again.

This implements the automatic update of the filepath fields in the preview, so it will always show what the result will be.

Also add/update some useful tooltips to explain what these ominous buttons in the UI are exactly doing (and how they differ). Thanks to #860 there is no need anymore to (re-)generate resource.py.

The remove_from_preview function was added in 5862184 but never used, so removed the dead code.

Fixes #847

There are multiple fields that store different parts of the filepath,
like __filename and __dirname. With a real MockTag (like in non-preview
mode) these fields are passed to the matching properties of the MockTag
class, which in turn all (sometimes with some indirection) read/write
from/to a single attribute named __filepath, which contains the absolute
path of the file. This also means that writing one of the fields will
automatically update all the others.
The preview doesn't have these properties/attribute, it is just a dict.
And it wasn't treating these fields special, and didn't update the
related fields. This is the reason why for example the __filename field,
which is displayed in the table or tag panel, still showed the original
value after you used the "tag to filename" function which only set the
__path field. As soon as the preview is written, the MockTag implemen-
tation is used again, and the fields are properly updated again.

This implements the automatic update of the filepath fields in the
preview, so it will always show what the result will be.

The remove_from_preview function was added in 5862184 but never used,
so removed the dead code.
@corubba corubba added the bug This is a bug, and should be fixed label Jan 21, 2024
@sandrotosi sandrotosi merged commit f556602 into puddletag:master Jan 27, 2024
@corubba corubba deleted the bugfix/filepath-preview branch January 27, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug, and should be fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview Mode - something strange....
2 participants