Files in desktop:/ are local files but QUrl doesn't know this.
Also allows us to determin mime type and icon for files on a network share.
While at it, improve default naming logic.
BUG: 375103
FIXED-IN: 5.9.0
Files in desktop:/ are local files but QUrl doesn't know this.
Also allows us to determin mime type and icon for files on a network share.
While at it, improve default naming logic.
BUG: 375103
FIXED-IN: 5.9.0
When I drag a file from desktop:/ into my panel I now get a proper icon widget rather than just a generic Link to the file. Most noticeable when I drag a .desktop file of an application there.
When I drag a file from smb:/ into my panel, I get a busy indicator on the applet until it has determined the icon/mime and then updates accordingly.
Dropped a www URL on my desktop and still get a blue HTML icon (didnt work with KFileItem but works with KIO::iconNameForUrl)
Verified that jump list actions still work, migration path (ie. plasma generating the .desktop files in plasma_icons if not existing) still works, even with multiple identical ones (ie. (1), (2), hence the file name being determined *after* the stat finished)
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
It will now always show file extension (used to do QFileInfo(localUrlString).baseName() before)
applets/icon/iconapplet.cpp | ||
---|---|---|
159 | Why only http? This would be useful for FTP, SMB and many other things, no? |
applets/icon/iconapplet.cpp | ||
---|---|---|
159 | There you would usually have a filename that makes sense. |
applets/icon/iconapplet.cpp | ||
---|---|---|
159 | No, not necessarily. You can point to the root of a FTP server with ftp://ftp.kde.org/ and you can even point to your home dir on an FTP server with ftp://user@host (and no trailing slash). Similarly there's smb://workgroup or smb://host (I forgot the exact syntax for workgroups), no filename. Why not handle any case without a filename in the same way, http or not? |
applets/icon/iconapplet.cpp | ||
---|---|---|
159 | I see. Still when I do http://www.kde.org/index.php I would get "index.php" as name which is non-descript. |
Ok, I'll put it after
if (name.isEmpty()) { name = url.path(); }
and do a
if (name.isEmpty() || url.scheme().startsWith(QLatin1String("http"))) { name = url.host(); }
But then every HTTP URL, even with a filename, will use the host as filename?
Useful if you have only one link to a given website, but what if you have 5 links to different pages on that website?
Or maybe I didn't understand the order you wanted to use.
file:/// → "/" (would be neat to also ask kfileplaces at some point)
ftp://www.somehost.com/ → "www.somehost.com"
ftp://www.somehost.com/foo/bar/ → "bar"
(I think showing domain for websites always by default is fine, if user really has multiple links he or she can still change the name)
What I used to do about all this is to turn every '/' into a unicode fraction slash (so that it still looks like a '/' to the user, but can be used in a filename), and name the link with the full URL like "ftp://www.somehost.com/foo/bar/".
See KIO::encodeFileName (and copyjob.cpp:813, i.e. if you use KIO::link() this happens automatically in KIO).
But maybe that's because I like URLs :-)
applets/icon/iconapplet.cpp | ||
---|---|---|
108 | Not convinced that KIO::encodeFileName would be better than a MD5 filename, then? |
applets/icon/iconapplet.cpp | ||
---|---|---|
108 | Ah, that's what you meant with that. I got confused as to where and why I should use this … so, will work for when there's no fileName? Then I can just use that indeed. |