Endilll / vapoursynth-preview

Preview for VapourSynth scripts
Apache License 2.0
69 stars 21 forks source link

Implement saving and reloading of a global config file #37

Closed shssoichiro closed 3 years ago

shssoichiro commented 3 years ago

This is intended as a potential solution to #8. It is rather rough, I am not familiar with PyQT and this is probably not the ideal way to do things. However, it does work.

This changes the current storage, which is per vapoursynth script, to a per-file storage which contains only the elements relevant to that video (scening, last frame viewed, etc.), and a global config file, stored in either ~/.config/vspreview or %APPDATA%/vspreview depending on OS, which contains a user's settings they would like to carry over between sessions, such as window dimensions and which toolbars are open. This is a breaking change to how configs currently work, but it will not require any user intervention, as vspreview will simply issue ignorable warnings, and on close will overwrite the storage file with the new format.

The reason I took this approach for saving and loading with a dict instead of with yaml tags is because yaml tags seemed to automatically place the entire yaml object into our main class. That is not compatible with what we want to do here, which is load some components from one file, and some components from another file, therefore this more manual but fine-grained approach was taken.

Endilll commented 3 years ago

User can very well have different UI setups for different projects. I'm sure layout for working with DVD and 4K are quite different in terms of window size. Same for opened toolbars: some sources require you to go through video and create a list for scenes that require additional processing, some doesn't. And you don't want Scening toolbar for the latter.

While I agree that having global config is beneficial, and makes space for some constants currently hardcoded in main.py, a major design effort is required for the whole config subsystem before touching the source code. Current implementation proves design points I put there initially to be correct, but I missed too many use cases back then, and implementation is quite convoluted in terms of what's happening underneath.

Endilll commented 3 years ago

Since I'm not sure what direction VSP is going to take (and very scarce on time to think about it), there's no way I can be sure that this PR is a move in the right direction.

What I also don't like about this PR is that Misc toolbar is concerned with all other toolbars. Toolbars being independent even when it comes to saving and loading state is a strong point of current design.