D8690: Fix use of OpenUrlArguments
Julian Wolff
noreply at phabricator.kde.org
Wed Nov 15 10:02:15 UTC 2017
progwolff added inline comments.
INLINE COMMENTS
> aacid wrote in part.cpp:1400
> I don't think this is a good idea, do you have an actual case in which this helps or is it just a guess?
>
> Also have you tried that this doesn't break the fixes that https://phabricator.kde.org/R223:fba90677fcc9ccf0e6f5efe75e7446703d669d36 speaks of?
Sorry for the delay...
>From my understanding of that commit, my changes won't break it.
argMime is only set, if an external application sets the mimeType via OpenUrlArguments. So, the order in 1355 is arbitrary if the file is opened in Okular standalone.
Questionable is, what behaviour we should expect when Okular is used as a KPart and the external application sets the mime type.
Docs say:
QString KParts::OpenUrlArguments::mimeType ( ) const
The mimetype to use when opening the url, when known by the calling application.
Definition at line 93 of file openurlarguments.cpp.
"The mimetype to use" sounds to me like we should trust the calling application and prefer the mimeType given to us, instead of guessing it from the file name. We still fall back to pathMime if opening it with argMime fails.
An actual usecase would be creating a new rtf/markdown/whatever file in Kate. The new file would not have a file name from which we could derive the mime type from. Without my changes, Okular would guess that it's plain text, as a file name without an ending leads to pathMime "text/plain". It would therefore display the file as plain text, even if Kate knows that it's rtf/markdown/whatever (e.g. from the syntax highlighting mode).
Note that Kate does not do this yet. Just want to give you an example of how it could be used.
The reordering is also needed for the test you demanded.
> I mean maybe what makes sense is to set the mimetype to txt and then giving it a pdf file and checking that the txt backend was used instead of the pdf one?
This will not work without the reordering. A pdf file with ending ".pdf" has pathMime "application/pdf" and thus is displayed as pdf, not as plain text, even if argMime is set to "text/plain"
REPOSITORY
R223 Okular
REVISION DETAIL
https://phabricator.kde.org/D8690
To: progwolff, aacid
Cc: #okular, ngraham, aacid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/okular-devel/attachments/20171115/fda4aa39/attachment.html>
More information about the Okular-devel
mailing list