files-community / Files

A modern file manager that helps users organize their files and folders.
https://files.community
MIT License
34.86k stars 2.21k forks source link

Feature: Reload settings when json file is modified #10935

Open yaira2 opened 1 year ago

yaira2 commented 1 year ago

What feature or improvement do you think would benefit Files?

Reloading the settings file when settings are made externally will help when users are customizing advanced theming settings.

Requirements

Files Version

v2.4.11

Windows Version

Windows 11

Comments

No response

btomblinson commented 1 year ago

I am looking at this request, I am assuming you are referring to the user_settings.json file?

btomblinson commented 1 year ago

@yaira2 I was digging into the basejsonsettings code as well with the idea of adding a FileSystemWatcher but the code for what’s there makes it difficult to just add that because of all the interfaces, furthermore I would be concerned about potentially live swapping user_settings while the application is running

yaira2 commented 1 year ago

@btomblinson user_settings is the right file.

@d2dyno1 would you be able to point @btomblinson in the right direction?

d2dyno1 commented 1 year ago

I agree that BaseJsonSettings is showing its age now and it's not really suited for the direction we're going for (it's incompatible with the new storage abstractions). That's why I have plans to rewrite it at some point porting over the code that I already have (link). However, you could try incorporating FileSystemWatcher in the mess I created which then could be ported over 🙂

btomblinson commented 1 year ago

@yaira2 @d2dyno1 my thinking is to replace the “generic” json settings code that’s there with something specifically built around the filesystemwatcher, and the application would pull the settings from a static class that acts like a cache, this is simply just a settings file do you need all the interfaces and abstractions around it? Like treat it as the Configuration class that’s used for app.config and web.config

d2dyno1 commented 1 year ago

I'd rather have those abstractions in-place just for the sake of maintainability and flexibility in case we wanted to change something in the future. IDatabaseModel already solves this for us enabling caching of settings which we can also use to share settings between classes (that implement ISettingsModel).

Take a look at the link I referenced in my previous comment to familiarize a bit with the code I have in mind

HappyFishkeeper commented 9 months ago

I'm trying to add keyboard shortcuts to Actions in the user_settings file. For example, I tried to add this:

{ "SortByName": "Alt+Shift+N", "SortBySize": "Alt+Shift+S" },

I did this with Files closed. The first time, I did it with Notepad++; the second time, I used Visual Studio Community. I saved the file each time, and then opened Files. The user_settings file is overwritten when Files is opened, so that the keyboard shortcuts are not saved.

I then tried to edit the user_settings file to add the keyboard shortcuts mentioned in the documentation:

{ "CopyItem": "Ctrl+V", "PasteItem": "Ctrl+C" },

I had the same problem – the user_settings file was overwritten again, so that "Actions": null. I have made sure that Files is not running in the background, by closing out the app from the system tray and confirming in the Task Manager that the executable is not running. I even tried restarting Windows before running Files, but nothing made a difference.

Am I missing something?

Josh65-2201 commented 9 months ago

You aren't using correct formatting https://files.community/docs/customize-settings/actions#:~:text=valid%20key%20combination.-,For%20example,-%2C%20if%20you%20want Please also join the Discord https://discord.gg/files for more help