Bug 307885

Summary: PreviewList not correctly aligned when starting an image editor tool [patch]
Product: [Applications] digikam Reporter: Andi Clemens <andi.clemens>
Component: Plugin-Editor-AutoColorsAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: andi.clemens, caulier.gilles, praveshgupta1993
Priority: NOR    
Version: 3.0.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 3.2.0
Sentry Crash Report:
Attachments: example
resizedPreviewList(Auto Correction Tool Preview List)
Auto Correction after Sidebar Resize
Black & White Tool Preview List
Black & White Tool Preview List after Sidebar Resize
Preview List Patch

Description Andi Clemens 2012-10-05 09:21:33 UTC
When I start an imageplugin, e.g. color correction, the preview items in the filter list are not correctly alligned. Also I'm not able to click on some of the preview items.

When I resize the toolpanel, the items get re-aligned and I can click on all the items.

Reproducible: Always

Steps to Reproduce:
1. Open an image in the editor, make sure it has portrait orientation
2. Open "Color->Auto Correction"
Actual Results:  
The filter preview items are not aligned correctly and some items are not click-able

Expected Results:  
The filter preview items should be aligned correctly
Comment 1 Andi Clemens 2012-10-05 09:22:32 UTC
Created attachment 74352 [details]
example
Comment 2 caulier.gilles 2012-10-05 09:33:30 UTC
Andi,

Widget relevant is in image editor :

https://projects.kde.org/projects/extragear/graphics/digikam/repository/revisions/master/entry/utilities/imageeditor/widgets/previewlist.cpp

Gilles Caulier
Comment 3 Andi Clemens 2012-10-05 09:55:45 UTC
I know, but I haven't found the problem yet so I added the bugreport... :-)
Comment 4 caulier.gilles 2012-10-05 10:33:39 UTC
I can reproduce the problem here, and i tried to found the origin.

I force icon size to listview to force layout of icon before to render and plug thumbs, which are computed by separated thread. This want mean that list view is show empty before to render preview.

I don't touch yet sizeHintxxx() methods to re-implemented. Perhaps it's the godd way. What do you think about ?

Or it's a Qt4 bug. I don't know...

Gilles Caulier
Comment 5 Andi Clemens 2012-10-05 16:29:26 UTC
Yes maybe re-implementing the sizeHint method will work... onResize the list is drawn correctly, so this might be a good way to fix the issue
Comment 6 Pravesh Gupta 2013-04-29 14:39:20 UTC
I am also able to reproduce the bug.

In my mind, a simple solution to this is to make iconSize and gridSize smaller.
I have tried with different combinations and i think the previewList in the attachment(named 'resizedPreviewList' ) is good to view.
Should it be done?

Pravesh
Comment 7 Pravesh Gupta 2013-04-29 14:40:49 UTC
Created attachment 79549 [details]
resizedPreviewList(Auto Correction Tool Preview List)
Comment 8 caulier.gilles 2013-04-29 14:41:35 UTC
But it sound like a Qt icon-view canvas refesh which is not call at the right time... No ?

Gilles Caulier
Comment 9 caulier.gilles 2013-04-29 14:43:41 UTC
If your solution is a turn around the dysfunction, why not...

dysfunction disappear for all tool sidebar size, when you close and reopen it ?

Gilles Caulier
Comment 10 Pravesh Gupta 2013-04-29 15:08:54 UTC
Hi Gilles,

Please can you elaborate comment 9.

Pravesh
Comment 11 Pravesh Gupta 2013-04-29 15:39:42 UTC
Hi Gilles,

It disappears for Auto Correction tool.
And for White Balance Tool it makes more use of the space by displaying 2 images in a row. 
But the current problem then comes in White Balance Tool i.e. the 2 consecutive rows are not wholly displayed.

Pravesh
Comment 12 caulier.gilles 2013-04-29 15:41:02 UTC
1 / Open tool including PreviewList
2/ Change width of sidebar including tool settings (reduce, increase)
3/ close tool
4/ re-open tool and check if preview icon are aligned.
5/ try again to 1/ 

Gilles Caulier
Comment 13 caulier.gilles 2013-04-29 15:44:46 UTC
Don't forget one point.

preview are computed outside GUI thread. It's invoke tool filter algorithms to apply on image and reducing result as thumb.

Of course, depending of complexity of algorithm used, preview can take more and less time...

This want mean that during thumb computation icon size can be not very well defined. I suspect a race condition somewhere.

Note : this preview widget is used also in B&W tool... Can you reproduce  ? It's i think the tool which have the most of thumbs to compute.

Gilles Caulier
Comment 14 Pravesh Gupta 2013-04-29 15:53:50 UTC
Created attachment 79551 [details]
Auto Correction after Sidebar Resize
Comment 15 Pravesh Gupta 2013-04-29 15:54:37 UTC
Created attachment 79552 [details]
Black & White Tool Preview List
Comment 16 Pravesh Gupta 2013-04-29 15:55:26 UTC
Created attachment 79553 [details]
Black & White Tool Preview List after Sidebar Resize
Comment 17 Pravesh Gupta 2013-04-29 15:58:05 UTC
Hi Gilles,

I have attached attachments of changes in previewList after changing gridSize and iconSize.
Auto Correction after Sidebar Resize 
Black & White Tool Preview List
Black & White Tool Preview List after Sidebar Resize 

Pravesh
Comment 18 Pravesh Gupta 2013-04-30 14:48:52 UTC
Hi Gilles,

Image thumbnails in the preview List does not resize when width of sidebar is changed.
But if we set imageThumbnail size to 96*96, even then whole previews of B&W Tool can not be represented in single view, so to view other previews of B&W we have to scroll down . The height of the grid Area in B&W preview is to be increased some more or images should be around size 90*90, so that at least 2 rows can be displayed at a time.
But if we do this, then Image Previews in the Auto ColorCorrection Tool becomes very small as compared to the area allocated to them and thus looks somewhat odd.

So I think icon size (96*96), and gridSize as (125, 96+font().height()) is fine. At least preview List  for Auto Correction Tool is good to view.

Pravesh
Comment 19 Pravesh Gupta 2013-04-30 14:59:29 UTC
Sorry, In my previous comment 18, I told that to view at least 4 images with their name at around iconSize 90* 90 is required, but it is 70*70. 
This size makes Auto Correction Preview List Grid Space not correctly utitilized, and looks odd.

Is there any other way?

Pravesh
Comment 20 caulier.gilles 2013-05-01 12:41:19 UTC
Pravesh,

Please attach a patch of your changes given the best results.

Gilles Caulier
Comment 21 Pravesh Gupta 2013-05-12 14:40:57 UTC
Created attachment 79852 [details]
Preview List Patch

Hi Gilles,

I am attaching the patch which changes the image icon and grid size. This corrects preview list for Auto-Corrrection Tool. 
Preview List for Black & White Tool is more good to view but still cannot completely show all the previews in the small space allocated to it.

Please review it.

Pravesh
Comment 22 caulier.gilles 2013-05-12 16:33:04 UTC
Git commit 956d2657180398480bc4f6f720941edbf7331ef3 by Gilles Caulier.
Committed on 12/05/2013 at 18:31.
Pushed by cgilles into branch 'master'.

apply patch #79852 from Pravesh Gupta
FIXED-IN: 3.2.0

M  +2    -2    utilities/imageeditor/widgets/previewlist.cpp

http://commits.kde.org/digikam/956d2657180398480bc4f6f720941edbf7331ef3
Comment 23 Pravesh Gupta 2013-05-12 17:03:05 UTC
Hi Gilles,

I want to notify that as was in the patch submitted by me setGridSize method should have QRect of width 125 as it will result in better previewList region utilization when Black & White Tool is called.

setGridSize(QSize(125, 100 + fontMetrics().height()));

While according to the commit, this objective is not reached. 
Please review and correct asap.

Pravesh
Comment 24 caulier.gilles 2013-05-12 17:14:12 UTC
Git commit 348c231cd6dd50039f3fdc0e065fbc4a8bcfc862 by Gilles Caulier.
Committed on 12/05/2013 at 19:13.
Pushed by cgilles into branch 'master'.

polish icon size

M  +1    -1    utilities/imageeditor/widgets/previewlist.cpp

http://commits.kde.org/digikam/348c231cd6dd50039f3fdc0e065fbc4a8bcfc862