Bug 240861 - Enlarge image in folder preview when there's only one image
Summary: Enlarge image in folder preview when there's only one image
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 16.12.2
Platform: unspecified All
: NOR wishlist
Target Milestone: ---
Assignee: Peter Penz
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2010-06-06 07:46 UTC by KDE Brainstorm Submissions
Modified: 2011-08-31 07:35 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.7.0


Attachments
Mockup (18.53 KB, image/png)
2010-06-06 07:46 UTC, KDE Brainstorm Submissions
Details
Example of the "easy part" (831 bytes, patch)
2010-11-15 06:20 UTC, Jeffery MacEachern
Details
Proposal for the "hard part". (2.20 KB, patch)
2011-01-10 20:46 UTC, Martin Engelmann
Details
2nd proposal to enlarge a single thumb of a file (5.36 KB, patch)
2011-01-14 23:24 UTC, Martin Engelmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description KDE Brainstorm Submissions 2010-06-06 07:46:17 UTC
Created attachment 47727 [details]
Mockup

Version:           unspecified (using KDE 4.4.3) 
OS:                All

While looking at my music collection, Dolphin does it job well of showing me previews of the images in all of these folders. However, since all folders correspond to one album each, there is always only 1 image per folder. Yet the folder preview puts that image in the top-left corner of the folder. What would be nice is that more of the surface of the preview should be used by the image, but only when the folder only contains one image.


This feature request was originally submitted through KDE Brainstorm, and has been submitted to Bugzilla due to popular demand. Original idea: http://forum.kde.org/brainstorm.php?mode=idea&i=84413

Reproducible: Didn't try
Comment 1 KDE Brainstorm Submissions 2010-06-06 07:46:49 UTC
Please see below for a mockup.
Comment 2 Tom Deblauwe 2010-10-18 11:10:09 UTC
is this bug still to be done? Any pointers in what file the directory preview is generated? really having a hard time finding it :)
Comment 3 Peter Penz 2010-10-18 11:20:07 UTC
The code for this is in http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/thumbnail/thumbnail.cpp (method ThumbnailProtocol::thumbForDirectory()) I think it should not be too tricky to solve...
Comment 4 Jeffery MacEachern 2010-11-15 06:18:39 UTC
I took a look at this, and it's easy enough to change the behaviour based on the number of files; the harder part is changing the behaviour based on the number of *thumbnailable* files.  i.e. I have it set to enlarge a single image, but if it's, say, a single image and a bunch of $foo files that don't have thumbnailers, then it falls back on the old behaviour. I'll see what I can do later.
Comment 5 Jeffery MacEachern 2010-11-15 06:20:53 UTC
Created attachment 53424 [details]
Example of the "easy part"

This provides the behaviour I mentioned above. Some reworking of other code will be necessary to do it properly, though.
Comment 6 Martin Engelmann 2011-01-10 20:46:03 UTC
Created attachment 55834 [details]
Proposal for the "hard part".

The number of tiles is set based on the result of the new function hasMultipleThumbnailableFiles. It checks for each file in the directory if it is thumbnailable using the function pluginForMimeType. The code is mostly copid from other functions of the class.

There could be one perfomance issue:
Until at least two thumbnailable files are found, pluginForMimeType is called for each file. This function contains two nested loops to find the correct plugin. With a large number of plugins and/or a large number of not thumbnailable files _could_ influence the performace. This has not been tested yet.
Comment 7 Jeffery MacEachern 2011-01-10 20:59:37 UTC
@Martin: That's more or less what I was thinking of as well (although I haven't tested your patch yet). Maybe post this on ReviewBoard to get more feedback? I had hoped there would be a nicer way to do this, but I doubt there is.

(Also, one note: you spelled the function name wrong)
Comment 8 Peter Penz 2011-01-11 16:37:31 UTC
@Martin: Thanks for the patch! However as you said already the performance is a problem here: QDir::entryList() and pluginForMimeType() are very expensive operations and now we invoked them 2 times more often than with the old approach...

Probably a trick might be that the first generated image should get scaled twice (one with the current size and one with the double-size). If the main-loop is exited after one item we can apply the double-sized image afterwards. Just a suggestion ;-)
Comment 9 Martin Engelmann 2011-01-14 23:24:28 UTC
Created attachment 56029 [details]
2nd proposal to enlarge a single thumb of a file

In this patch there are two previews generated for the folder. The first one (img) is generated with up to 4 thumbnails, the second one (oneTileImg) only with one thumbnail. The second preview won't be touched after the thumb is generated for the first thumbnail-able file.

The bool variable hasThumbnail is substituted by the int variable validThumbnails. This holds the number of successful generated thumbs. If only one thumbnail-able file has been found oneTilImg is returned, otherwise img.
Comment 10 Martin Engelmann 2011-01-15 10:41:38 UTC
Posted to reviewboard:
http://svn.reviewboard.kde.org/r/6332/
Comment 11 Martin Engelmann 2011-02-07 20:10:37 UTC
Pushed to git.

Peter and Jeffery: Thanks for your support and the reviews.

--

Git commit 33dc8a5de3dc3e8f9f64c3d1df6dee5a05b4c36d by Martin Engelmann.
Committed on 07/02/11 at 19:58.
Pushed by mengelmann into branch 'master'.
 
Enlarge image in folder preview when there's only one image

BUG: 240861
 
M  +52   -24   kioslave/thumbnail/thumbnail.cpp     
M  +5    -0    kioslave/thumbnail/thumbnail.h     
 
http://commits.kde.org/kde-runtime/33dc8a5de3dc3e8f9f64c3d1df6dee5a05b4c36d
Comment 12 kde-bugtracker 2011-02-07 21:10:16 UTC
Thank you KDE team for implementing this idea! Your work is greatly appreciated.