-
-
Notifications
You must be signed in to change notification settings - Fork 420
PICARD-3040: Register a custom protocol handler for browser integration #2596
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
base: master
Are you sure you want to change the base?
Conversation
To test this on Linux, run Edit the
Afterwards run:
It should now be possible to run
It also works from within browsers, but at least with Firefox and Chrome it is a bit special. Pasting the custom URI into the address bar just triggers web searches. But if it is part of a link (e.g. |
b1dcda6
to
9aad628
Compare
The URL handler on macOS is not called. The app is started and brought to the foreground, but the handler never receives the URL. There is a bug report https://bugreports.qt.io/browse/QTBUG-131741 for Qt 6. |
7b64040
to
281b1c7
Compare
I tested this on Windows and macOS. On Windows using the installer everything works as expected. Windows, like Linux, passes the custom URL via command line (hooray for single instance mode), and it gets processed as expected. The installer registers the protocol handler via registry and this also gets cleaned up again on uninstalling. I still need to test this with the appx package (as used for the store). Theoretically this works the same, but protocol registration happens via the appxmanifest metadata. Testing this needs code signing to work (only signed appx packages can be installed), and I need to do the proper setup for this on my machine. Unfortunately the macOS test results are a bit mixed. Registering the protocol handler via the app package metadata (info.plist) works as expected. The handler works (tried with Safari and command line But event processing is not working as expected in Qt. Like with file open macOS handles the protocol by sending an event to the app. The Qt documentation for QDesktopServices suggest that it should work when registering the handler via I first assumed our custom event handling in https://github.com/metabrainz/picard/blob/master/picard/tagger.py#L792-L804 is interfering, so I made sure no event is processed there and Then I figured out that with Qt 6.7 the event with the custom protocol URL ends up as a Unfortunately with Qt 6.8.2 the event neither shows up as a So far I think this is a Qt bug. As mentioned above there is the suspicious bug https://bugreports.qt.io/browse/QTBUG-131741 , but it is marked as resolved for 6.8.2. I'll see that I can create a small reproducer and report this to Qt. |
Summary
Problem
This PR implements a custom URL handler in an attempt to provide a solution for PICARD-3040. This PR focuses on adding the ability to handle the protocol to Picard and register the handler on various systems.
The handler allows opening URIs like
org.musicbrainz.picard:openalbum?id=3fd4b04a-28fa-45b7-89d7-bcb883be287c
.Solution
QDesktopServices.setUrlHandler
(macOS).Action