2

I'm trying to debug a problem with opening CBR files in Calibre (it was explained here). Specific Callibre problem is mostly not revelant, and it boild down to the issue that files and folders are opened by improper external programs.

After some debugging I found out that the culprit is most probably a call to QDesktopServices.openUrl(qurl) which selects wrong application to handle a specific file.

Qt documentation is somewhat laconic as to how this method works (I really care about Python version, but I guess that behaviour is identical):

If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser.

My linux enviorment seems to be configured properly, if I double click on this file in Nautilus (I don't really have full KDE enviorment ready) it opens in a proper program.

So questions are:

  • How does openUrl find proper application to open a file.
  • How can I change what application will handle that file.
jb.
  • 23,300
  • 18
  • 98
  • 136
  • 1
    What specific Linux DE are you using? For qt5, desktop services are handled by platform integration plugins, and only a few DEs are supported by default. If calling `openUrl` with a valid local file url just returns `False` without printing any Qt debug messages, it most likely means there is no platform integration plugin available on your system. If that is the case, you can use [setUrlHandler](http://doc.qt.io/qt-5/qdesktopservices.html#setUrlHandler) to explicitly invoke something like [`xdg-open`](http://linux.die.net/man/1/xdg-open) (which is what most plugins would do anyway). – ekhumoro Aug 27 '15 at 22:51
  • @ekhumoro I use debian with i3 window maganer. ``openUrl`` returns true, because it opens the file, however file is opened in an improper program (and a different program than one used by thunar and doplhin). – jb. Aug 28 '15 at 05:37

1 Answers1

-1

After some additional research it turns out that QDesktopServices.openUrl uses XDG utulities under the hood. Results are consistent whith xdg-open.

jb.
  • 23,300
  • 18
  • 98
  • 136