Martchus / syncthingtray

Tray application and Dolphin/Plasma integration for Syncthing
https://martchus.github.io/syncthingtray/
Other
1.66k stars 44 forks source link

Web view on Windows #178

Closed RuiNtD closed 1 year ago

RuiNtD commented 1 year ago

Relevant components

Is your feature request specific to a certain platform/environment? Please specify. Windows

Is your feature request related to a problem? Please describe. It would be nice to be able to access the web UI on Windows without opening my browser.

Describe the solution you'd like Web view support on Windows

Describe alternatives you've considered 🤔

Additional context Add any other context or screenshots about the feature request here.

Martchus commented 1 year ago

This should already work. Note that binaries provided by myself on GitHub don't have the web UI enabled because I am reluctant to ship a web browser.

Any third party is welcome to provide such builds. I will nevertheless close the issue for now as it is nothing I will work on. If someone likes to work on it, one can still leave a comment and I'll reopen the issue.

Martchus commented 1 year ago

Note that if Qt WebView gains support for using Windows' native web rendering facilities I will implement support for utilizing it and enable it in my Windows build. However, to my knowledge this is not possible yet.

RuiNtD commented 1 year ago

Any chance an option could be added instead to open the web UI in Chrome / Edge app mode?

msedge -app="http://localhost:8384"
Martchus commented 1 year ago

I haven't had that idea yet. That's something that would be easy to implement, one just has to do it. Maybe it is even possible to pass auth credentials this way.

Maybe I'll do it at some point so I'll reopen the issue.

Martchus commented 1 year ago

I've just tried /c/Program\ Files\ \(x86\)/Microsoft/Edge/Application/msedge --app="http://localhost:8384" and it looks really good. Definitely better than shipping a complete browser stack (as it was required for Qt WebEngine). It will still be a bit of work to implement:

Alternatively, one could also try to use https://learn.microsoft.com/en-us/microsoft-edge/webview2 directly, even though Qt doesn't support it. According to https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/overview-features-apis?tabs=dotnetcsharp there are APIs to deal with authentication.

RuiNtD commented 1 year ago

The path of Edge needs to be located dynamically. Supposedly one can read it somewhere from the registry and fall back to some common location.

I mean, considering it's pre-installed on Windows 10 and 11, install location should be consistent. Even then, the executable could be made customizable, since the same flags should work on any Chromium based browser.

RuiNtD commented 1 year ago

I also found this reference online for registry values that point to MS Edge: Source: https://www.tenforums.com/browsers-email/178354-edge-executable-file-location-registry.html

I feel like HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe would be the most reliable registry value to check for MS Edge. You could also fall back to chrome.exe if Edge has been (forcefully) uninstalled, which can be located in registry with a similar key.

Martchus commented 1 year ago

I've created a first commit (58b8a4e5403ddae8ef0c5fc1bf6a90b625ec110e) to support this feature in general. At this point it just tries to locate chromium in path but you can override the executable via SYNCTHINGWIDGETS_CHROMIUM_BASED_BROWSER. I've only tested it under GNU/Linux with Chromium itself so far but it should work under Windows as well if you set the mentioned environment variable to the path of Edge.

The next step would be a better automatic detection and the possibility to override the command-line from the UI.

Martchus commented 1 year ago

Tested it on Windows with SYNCTHINGWIDGETS_CHROMIUM_BASED_BROWSER=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe for my system and it works just fine.

Just for the sake of it, I've also tested whether the web view using Qt WebEngine works and it works as well. However, it was really slow. For instance the animations of Syncthing's UI were not fluent at all. Maybe it is because I've been using a debug build of Qt (the official MSVC build).

Martchus commented 1 year ago

With https://github.com/Martchus/syncthingtray/commit/033cd21d839380b8a2b396ec821f4fe8c5dfcf72 the automatic detection should be good enough. Being able to select a binary manually is still missing.

Note sure whether I'll look also into the other ideas mentioned in https://github.com/Martchus/syncthingtray/issues/178#issuecomment-1484225906 as they are more effort to implement and maybe not even possible besides focusing an already opened window.

RuiNtD commented 1 year ago

BTW, it might be a good idea to add brave.exe to the list. c:

Martchus commented 1 year ago

I've been adding a way to configure a custom command via the UI.

One could also add Vivaldi. However, I would actually add none of them because this also needs testing - and I'm not willing to regularly test a bunch of browsers. I've been adding Edge to the list because it should be installed by default on Windows and I've added Chromium/Chrome to the list because it is very likely installed on Windows and GNU/Linux. Those two should suffice. If one wants to use a different browser this is now easily possible and the extra configuration step makes it also clear that one leaves the realm of supported configurations.

I think that's as good as it gets for this feature for now.

RuiNtD commented 1 year ago

Trying out Web View on 1.4.0, and it doesn't save the setting across restarts.

Martchus commented 1 year ago

Right, I can reproduce the problem. I suspect it only happens with builds where built-in web view support is disabled as I have tested this actually a lot with builds with built-in web view support enabled.

Martchus commented 1 year ago

Fixed in 1.4.1.