Bug 102029 - wish: no/small icons in album tree
Summary: wish: no/small icons in album tree
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Thumbs-IconView (show other bugs)
Version: 0.7.2
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-21 00:27 UTC by Jens
Modified: 2017-07-28 15:15 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.9.2
Sentry Crash Report:


Attachments
Patch for small icons in tagfilterview.cpp (3.96 KB, patch)
2005-09-25 12:39 UTC, Jens
Details
patch for (configurable) small icons in all sidebars (15.44 KB, patch)
2005-10-31 00:06 UTC, Jens
Details
patch for (configurable) small icons in all sidebars (29.69 KB, patch)
2005-11-01 01:00 UTC, Jens
Details
new patch against 0.9-svn (70.50 KB, patch)
2006-05-29 00:11 UTC, Jens
Details
new patch against 0.9-svn with "diff -uw -x" (24.26 KB, patch)
2006-05-29 23:29 UTC, Jens
Details
_correct_ new patch against 0.9-svn with "diff -uw -x" (20.55 KB, patch)
2006-05-29 23:49 UTC, Jens
Details
screenshot (135.25 KB, image/png)
2007-04-01 13:56 UTC, Marcel Wiesweg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jens 2005-03-21 00:27:29 UTC
Version:           0.7.2 (using KDE 3.4.0 Level "a" , SUSE 9.2 UNSUPPORTED)
Compiler:          gcc version 3.3.4 (pre 3.3.5 20040809)
OS:                Linux (i686) release 2.6.8-24.11-default

Hi,

I would like to be able to remove/hide the album thumbnail in the tree view, or set it to "small icons" like in Konq's sidebar. With a growing number of albums, this becomes a waste of space pretty quickly.

Thank you! ;)

Jens
Comment 1 Jesús Jiménez 2005-07-07 22:12:01 UTC
*** This bug has been confirmed by popular vote. ***
Comment 2 Jens 2005-09-04 10:40:43 UTC
Hi,

I just tried 0.8.0 beta1. It looks great! However, this wish hasn't been implemented yet. Is there any chance it might go into 0.8? I guess the source code change would be rather small, but I wouldn't know where to begin looking.

I would be happy with a non-GUI configuration option in digikamrc, for the beginning.

Thank you! :-)

Comment 3 Thorsten Schnebeck 2005-09-04 12:08:54 UTC
We have two alternatives:
1) Do not touch an original image
2) Do not overwrite a file that exists without checks

to 1)
This is noble but hard to implement. You need versioning, you have to define whats an original. Only a e.g. RAW-file or also other images in the process chain? One way to work this way is that there is maximum only one working copy of every image in digiKams file tree. This way you can use the "revert"-command not only during one IE session but also in albumview on every "open"-type command. And you need a new explicit "drop original" command making the workimage the new original. Of course the albumview shows only the working copy and may a different frame color or RMB->"open original" indicates that there is still an original image behind. This concept could work but needs modification on how images are managed for sure to the database level!

to 2) This is my concept. I want to change an image with the IE and external programs. I know digikam can not take care of changes I did in external programs but it should take care on anything I do in the IE.
Today you can open an image in the IE resize and click on "save". And now there has to come a warning, a reminder or a notice. And this does not happen - you loose your original data. Or my old mistake: open a jpeg makeing very small changes and press save, but having a digikam JPEG quality of 65% case last time I save for web :-/ I reconfigure IE that I disable every "save" action and use "save as" as default. BTW I also droped the "revert"-Action from my toolbar cause undo/redo works very well.

So as I suggest in #0 I'm fine when digiKam takes care and protects the
- metadata,
- imagesize and
- imagequality (== filesize)
of photos.
Protection does not means annoying pop up warning. There could be an informative save dialog showing
- filename and type
- old and new filesize,
- old and new image geometry,
- an option to save metadata also indicating if metadata are there,
- an option to save embedded preview,
- configured but also changeable compression setting for supported filetype
every time I press on "save".

Bye

  Thorsten       
Comment 4 Thorsten Schnebeck 2005-09-04 12:36:43 UTC
??? Wrong bug :-) Please delete

Bye

  Thorsten
Comment 5 Jens 2005-09-25 12:39:20 UTC
Created attachment 12697 [details]
Patch for small icons in tagfilterview.cpp

Hello,

as discussed on IRC, here's my first digikam patch (actually my very first C++
patch). It introduces an IconSize= value in digikamrc for the Tags view and
automatically adjusts the icon spacing and the tree view. I plan doing
something similar for the album, calendar and search views.

Please comment. It's probably horrible coding style. I promise I'll do better
next time. ;)

Jens
Comment 6 Jens 2005-10-03 16:48:20 UTC
Hi,

Has anybody tested my patch and can comment on it?
How are chances for it to be integrated into digikam?
Sorry, I don't have write access to SVN (yet), I'd like to contribute a couple more ideas though.

Thanks!

Jens
Comment 7 caulier.gilles 2005-10-03 18:25:58 UTC
Jens,

0.8.0 is in the way but all features are frozen. We will try to integrate your patch in next release (0.8.1) if the team is agree (it's right for me).

I will try to take a look in your code (later than 0.8.0 release date).

Thanks for your contributions

Gilles Caulier

Comment 8 Jens 2005-10-03 23:45:57 UTC
Thanks!

I'm looking forward to do a bit more hacking on digikam.
I want to use it to sort through my ~10'000 pictures. ;)

Jens
Comment 9 Jens 2005-10-31 00:06:23 UTC
Created attachment 13230 [details]
patch for (configurable) small icons in all sidebars

Hello,

second version of my patch. About half as much code, and more efficient.
I think my C++ abilities have improved slightly. =)

Please review.

Thanks,

Jens
Comment 10 Jens 2005-11-01 01:00:14 UTC
Created attachment 13238 [details]
patch for (configurable) small icons in all sidebars

Next attempt, which follows your style guide and cleans up the code a bit more.
Comment 11 caulier.gilles 2005-11-01 10:20:38 UTC
Thanks for your patch. I will take a look to 0.8.1. Please make it complilable with current svn until 0.8.0 release date, planed to november 15.

Gilles Caulier
Comment 12 Jens 2005-11-01 10:51:29 UTC
OK, will do.

I will also try to add a configure item in digiKam's configuration dialog for the sidebar icon size. Please suggest a suitable position for this item, I would otherwise just use "Miscellaneous".
Comment 13 caulier.gilles 2005-11-01 18:02:01 UTC
Yes, "Miscellaneous" is the most common setup tab to main interface and image editor. I'm speaking about IE because in 0.8.1 new image properties sidebar tabs will be added in IE and showfoto :

http://digikam3rdparty.free.fr/SideBar/

Note that it will be necessary to create a new patch for showfoto (When my code will be commited just later 0.8.0 release date) about this point. I think that "General" settings tab is the most adapted to add sidebar icon size settings in Showfoto.

Gilles
Comment 14 caulier.gilles 2005-11-01 18:06:32 UTC
About SideBar icon size settings, i think that a kdevelop config style is better :

- Not provides sidebar icons size.
- Provides 3 options to set SideBar tab contents :
   * Icons alone.
   * Text alone.
   * Icons + Text.

Gilles
Comment 15 Jens 2005-11-02 16:05:13 UTC
Gilles, your screenshots look really good. Way to go! :-)

About the icon size: I was thinking maybe I should not pollute the config dialog, but just provide a RMB context menu in the sidebar which lets the user choose the icon size (eg. 16, 24, 32 pixels) with appropriate thumbnails.

re: compiling: my patch applies and compiles fine with current SVN, I created it using "svn diff" so there should not be a problem. If there is, please tell me!

Jens
Comment 16 caulier.gilles 2005-11-02 16:08:22 UTC
RMB context menu to set side bar , i'm agree, if other digiKam developpers are agree...

Gilles
Comment 17 Joern Ahrens 2005-11-02 16:09:34 UTC
No, there is no need for a context menu for this option. This function isn't need often and so a context menu only bloats the gui.
Comment 18 Jens 2005-11-02 16:34:31 UTC
Since the context menu would be completely invisible when not used, and use no space at all, how can it bloat the GUI?
Comment 19 Jens 2006-05-29 00:11:43 UTC
Created attachment 16314 [details]
new patch against 0.9-svn

Hello,

I created a new patch that allows the icon size in the sidebars to be
configured from 8 to 32 pixels in size. Below a certain size (20) creation of
album thumbnails as well as blendIcons() will be suppressed, because the
thumbnails would be too small anyway.

There is also a settings page, however setting a new value there will only save
it to digikamrc and not (yet) apply it at once (I did not find out how to do
this with the signal/slot mechanism). Also, it is probably not (yet) optimally
arranged on the QGridLayout, I looked at setupiofiles.cpp and copied a bit of
code from there but there is still room for improvement.

The patch is quite large because there were a few whitespace-only changes in
the source file but it applies cleanly to current SVN.

I would welcome any comments.

Jens
Comment 20 caulier.gilles 2006-05-29 08:14:49 UTC
Jens,

Your patch need to be cleaned. The sustancial changes cannot be checked easily (if i want to check your change).

A lot of lines have been marked modified because your editor have saved the source file with removing the white space at end of line. This is a settings in kate/kdevelop.

You can edit this patch manually and remove all unwanted changed. Your code can be checked correctly like this.

Thanks in advance.

Gilles
Comment 21 Jens 2006-05-29 09:23:16 UTC
Hi,

I already suspected this. I will clean the patch. I can also run "svn diff --diff-cmd diff -uw -x" which ignores whitespace changes.

Why do you not let Kate/Kdevelop remove trailing whitespaces in your setup?

Jens
Comment 22 caulier.gilles 2006-05-29 09:25:53 UTC
Because i have forget to do it on all computer where i develop (:=))))... Fixed now...

Gilles
Comment 23 Jens 2006-05-29 23:29:51 UTC
Created attachment 16345 [details]
new patch against 0.9-svn with "diff -uw -x"

OK, here is another patch, made with a diff command that ignores whitespace
changes. I also removed the "digikam.kdevelop" diff which probably doesn't work
for you anyway (different paths etc).

Still missing is a signal/slot combo to redisplay the sidebars when the icon
size changes (so changes require a restart of digikam). I do not really know
where to put this.

Jens
Comment 24 Jens 2006-05-29 23:49:03 UTC
Created attachment 16346 [details]
_correct_ new patch against 0.9-svn with "diff -uw -x"

OK, here goes again (forgot to save) ;) ...
Comment 25 caulier.gilles 2006-05-30 18:46:29 UTC
ok. just patched my repository in local. Sounds good excepted some problems to refresh sidebar selected contents using a small icon size.

Also in setup dialog, no need a fine icon size setting. Use a QComboBox with 3 size values : 12, 24, 32. I think it's enough.

Let's me some time to check your code indeep.

Gilles
Comment 26 Jens 2006-05-30 18:53:27 UTC
Hi,

thanks for testing. I'm OK with the QComboBox if you have steps of 4 (ie. 8, 12, 16, 20, 24, 28, 32). Is that OK? The reason is that powers of 2 are the "usual" icon sizes (i.e 8, 16, 32) but the ones between fit quite well too.

btw: I see now that my patches from half a year ago were really bad. I hope I have improved..=;)

Jens
Comment 27 Jens 2006-06-05 13:52:39 UTC
Hello,

it seems I forgot to patch the camera download album selection dialog:

Index: utilities/cameragui/albumselectdialog.cpp
===================================================================
--- utilities/cameragui/albumselectdialog.cpp   (Revision 546727)
+++ utilities/cameragui/albumselectdialog.cpp   (Arbeitskopie)
@@ -47,6 +47,7 @@
 #include "album.h"
 #include "albummanager.h"
 #include "albumselectdialog.h"
+#include "albumsettings.h"

 namespace Digikam
 {
@@ -107,7 +108,7 @@

     KIconLoader *iconLoader = KApplication::kApplication()->iconLoader();
     QPixmap icon = iconLoader->loadIcon("folder", KIcon::NoGroup,
-                                        32, KIcon::DefaultState, 0, true);
+                                        AlbumSettings::instance()->getDefaultTreeIconSize(), KIcon::DefaultState, 0, true);

     AlbumList aList = AlbumManager::instance()->allPAlbums();



PS: Do you want album thumbnails there too? I could give it a try.

-- 
Jens
Comment 28 Luka Renko 2007-03-21 00:19:20 UTC
SVN commit 644807 by lure:

Make size of icons used in sidebars configurable in order to allow more
entries to be presented. 

Configuration change is effective after restart of digikam (may improve
this in future).

Original patch by Jens B. Benecke, modified configuration dialog.

BUG: 102029


 M  +2 -1      NEWS  
 M  +15 -0     digikam/albumsettings.cpp  
 M  +3 -0      digikam/albumsettings.h  
 M  +40 -12    digikam/albumthumbnailloader.cpp  
 M  +13 -11    digikam/albumthumbnailloader.h  
 M  +3 -2      digikam/datefolderview.cpp  
 M  +3 -2      digikam/folderitem.cpp  
 M  +5 -1      digikam/folderview.cpp  
 M  +2 -1      digikam/searchfolderview.cpp  
 M  +1 -1      libs/imageproperties/imagedescedittab.cpp  
 M  +2 -1      utilities/cameragui/albumselectdialog.cpp  
 M  +33 -11    utilities/setup/setupgeneral.cpp  
Comment 29 Jens 2007-03-21 00:24:39 UTC
Thank you! :-))
Comment 30 Luka Renko 2007-03-21 06:38:53 UTC
Jens, thank you for providing the patch. ;-)
Comment 31 Marcel Wiesweg 2007-04-01 13:56:12 UTC
Created attachment 20143 [details]
screenshot

There are currently still regressions for size 32. I can show how to fix them
for size 32, but I don't know why the changes are necessary for smaller sizes.

In the screenshot,
1) There is garbage around the tag icons, best seen around "Marcel" on the
right, and the blending is done with a wrong offset
2) On the left, for tags without any icon ("Test", "Test/Autoadded"), the icon
is slightly to small
3) On the right, for tags without any icon ("Orte/Andalusien"), the icon is too
large.

To solve for size 32:
1) In AlbumThumbnailLoader::createTagThumbnail, lines 398 - 400:
   The thumbnail need to be cropped from 32 to 20, so it needs to be
	int w2 = d->iconSize - 12;
	int h1 = albumThumbnail.height();
	int h2 = d->iconSize - 12;
2) The reason is this change (line 146):
     if (album->isRoot())
-	 return getStandardTagRootIcon(size);
+	 return getStandardTagRootIcon((size > d->minBlendSize) ? size-8 :
size);
     else
-	 return getStandardTagIcon(size);
+	 return getStandardTagIcon((size > d->minBlendSize) ? size-8 : size);

3) The reason is this change:
--- digikam/libs/imageproperties/imagedescedittab.cpp	(revision 644806)
+++ digikam/libs/imageproperties/imagedescedittab.cpp	(revision 644807)
@@ -1291,7 +1291,7 @@
     {
	 if (icon.isNull())
	 {
-	     item->setPixmap(0, loader->getStandardTagIcon(album, 20));
+	     item->setPixmap(0, loader->getStandardTagIcon(album));
	 }
	 else
	 {
The icons in the TAlbumListView have always been smaller than in the other
views: For 32, they have had size 20.
Comment 32 Marcel Wiesweg 2007-04-06 18:34:26 UTC
SVN commit 651128 by mwiesweg:

Fix the regressions from the "album thumbnail size configurable" patch.
- Blending size and position needs to be scaled
- remove hardcoded sizes
- fix the problems with size==32 described in b.k.o.

For size==16, albums do not have thumbnails now, but tags have.
I think it should be either both or none?

One showstopper is left:
Configuration change must be applied immediately.

CCBUG: 102029


 M  +59 -37    digikam/albumthumbnailloader.cpp  
 M  +28 -7     digikam/albumthumbnailloader.h  
 M  +2 -2      libs/imageproperties/imagedescedittab.cpp  


--- trunk/extragear/graphics/digikam/digikam/albumthumbnailloader.cpp #651127:651128
@@ -18,6 +18,10 @@
  *
  * ============================================================ */
 
+// C includes
+
+#include <math.h>
+
 // Qt includes
 
 #include <qmap.h>
@@ -124,68 +128,81 @@
     m_instance = 0;
 }
 
-QPixmap AlbumThumbnailLoader::getStandardTagIcon(int size)
+QPixmap AlbumThumbnailLoader::getStandardTagIcon(RelativeSize relativeSize)
 {
-    if(size==0)
-        size = d->iconSize;
-    return loadIcon("tag", size);
+    return loadIcon("tag", computeIconSize(relativeSize));
 }
 
-QPixmap AlbumThumbnailLoader::getStandardTagRootIcon(int size)
+QPixmap AlbumThumbnailLoader::getStandardTagRootIcon(RelativeSize relativeSize)
 {
-    if(size==0)
-        size = d->iconSize;
-    return loadIcon("tag-folder", size);
+    return loadIcon("tag-folder", computeIconSize(relativeSize));
 }
 
-QPixmap AlbumThumbnailLoader::getStandardTagIcon(TAlbum *album, int size)
+QPixmap AlbumThumbnailLoader::getStandardTagIcon(TAlbum *album, RelativeSize relativeSize)
 {
-    if(size==0)
-        size = d->iconSize;
     if (album->isRoot())
-        return getStandardTagRootIcon((size > d->minBlendSize) ? size-8 : size);
+        return getStandardTagRootIcon(relativeSize);
     else
-        return getStandardTagIcon((size > d->minBlendSize) ? size-8 : size);
+        return getStandardTagIcon(relativeSize);
 }
 
-QPixmap AlbumThumbnailLoader::getStandardAlbumIcon(int size)
+QPixmap AlbumThumbnailLoader::getStandardAlbumIcon(RelativeSize relativeSize)
 {
-    if(size==0)
-        size = d->iconSize;
-    return loadIcon("folder", size);
+    return loadIcon("folder", computeIconSize(relativeSize));
 }
 
-QPixmap AlbumThumbnailLoader::getStandardAlbumRootIcon(int size)
+QPixmap AlbumThumbnailLoader::getStandardAlbumRootIcon(RelativeSize relativeSize)
 {
-    if(size==0)
-        size = d->iconSize;
-    return loadIcon("folder_image", size);
+    return loadIcon("folder_image", computeIconSize(relativeSize));
 }
 
-QPixmap AlbumThumbnailLoader::getStandardAlbumIcon(PAlbum *album, int size)
+QPixmap AlbumThumbnailLoader::getStandardAlbumIcon(PAlbum *album, RelativeSize relativeSize)
 {
-    if(size==0)
-        size = d->iconSize;
     if (album->isRoot())
-        return getStandardAlbumRootIcon(size);
+        return getStandardAlbumRootIcon(relativeSize);
     else
-        return getStandardAlbumIcon(size);
+        return getStandardAlbumIcon(relativeSize);
 }
 
+int AlbumThumbnailLoader::computeIconSize(RelativeSize relativeSize)
+{
+    if (relativeSize == SmallerSize)
+    {
+        // when size was 32 smaller was 20. Scale.
+        return lround(20.0 / 32.0 * (double)d->iconSize);
+    }
+    return d->iconSize;
+}
+
+QRect AlbumThumbnailLoader::computeBlendRect(int iconSize)
+{
+    // when drawing a 20x20 thumbnail in a 32x32 icon, starting point was (6,9). Scale.
+    double largerSize = iconSize;
+    double x = 6.0 / 32.0 * largerSize;
+    double y = 9.0 / 32.0 * largerSize;
+    double size = 20.0 / 32.0 * largerSize;
+    return QRect(lround(x), lround(y), lround(size), lround(size));
+}
+
 QPixmap AlbumThumbnailLoader::loadIcon(const QString &name, int size)
 {
-    if(size==0)
-        size = d->iconSize;
     KIconLoader *iconLoader = KApplication::kApplication()->iconLoader();
     return iconLoader->loadIcon(name, KIcon::NoGroup,
                                 size, KIcon::DefaultState,
                                 0, true);
 }
 
-bool AlbumThumbnailLoader::getTagThumbnail(TAlbum *album, QPixmap &icon, int size)
+bool AlbumThumbnailLoader::getTagThumbnail(TAlbum *album, QPixmap &icon)
 {
-    if(size==0)
-        size = d->iconSize;
+    int size = computeIconSize(SmallerSize);
+    /*
+    if (size >= d->minBlendSize)
+    {
+        QRect rect = computeBlendRect(size);
+        size = rect.width();
+    }
+    */
+
     if(!album->icon().isEmpty())
     {
         if(album->icon().startsWith("/"))
@@ -198,7 +215,7 @@
         }
         else
         {
-            icon = loadIcon(album->icon(), (size >= d->minBlendSize) ? size-12 : size);
+            icon = loadIcon(album->icon(), size);
             return false;
         }
     }
@@ -391,13 +408,15 @@
     // tag thumbnails are cropped
 
     QPixmap tagThumbnail;
+    int thumbSize = QMAX(albumThumbnail.width(), albumThumbnail.height());
 
-    if(!albumThumbnail.isNull())
+    if(!albumThumbnail.isNull() && thumbSize >= d->minBlendSize)
     {
+        QRect rect = computeBlendRect(thumbSize);
         int w1 = albumThumbnail.width();
-        int w2 = d->iconSize;
+        int w2 = rect.width();
         int h1 = albumThumbnail.height();
-        int h2 = d->iconSize;
+        int h2 = rect.height();
         tagThumbnail.resize(w2,h2);
         bitBlt(&tagThumbnail, 0, 0, &albumThumbnail, (w1-w2)/2, (h1-h2)/2, w2, h2);
     }
@@ -431,12 +450,15 @@
 
 QPixmap AlbumThumbnailLoader::blendIcons(QPixmap dstIcon, const QPixmap &tagIcon)
 {
-    if(d->iconSize >= d->minBlendSize)
+    int dstIconSize = QMAX(dstIcon.width(), dstIcon.height());
+
+    if (dstIconSize >= d->minBlendSize)
     {
         if(!tagIcon.isNull())
         {
+            QRect rect = computeBlendRect(dstIconSize);
             QPainter p(&dstIcon);
-            p.drawPixmap(6, 9, tagIcon, 0, 0, -1, -1);
+            p.drawPixmap(rect.x(), rect.y(), tagIcon, 0, 0, rect.width(), rect.height());
             p.end();
         }
         return dstIcon;
--- trunk/extragear/graphics/digikam/digikam/albumthumbnailloader.h #651127:651128
@@ -50,6 +50,21 @@
     static void cleanUp();
 
     /**
+     * Album thumbnail size is configurable via the settings menu.
+     * Some widgets use smaller icons than other widgets.
+     * These widgets do not need to know the currently set icon size from
+     * the setup and calculate a smaller size, but can simply request
+     * a relatively smaller icon.
+     * Depending on the user-chosen icon size, this size may in fact not
+     * be smaller than the normal size.
+     */
+    enum RelativeSize
+    {
+        NormalSize,
+        SmallerSize
+    };
+
+    /**
      * Request thumbnail for given album.
      * The thumbnail will be loaded
      * and returned asynchronously by the signals.
@@ -70,22 +85,26 @@
       * If a custom icon is associated with the tag,
       * it is loaded asynchronously, icon is set to null,
       * and true is returned.
+      * Tag thumbnails are always smaller than album thumbnails -
+      * as small as an album thumbnail with SmallerSize.
+      * They are supposed to be blended into the standard tag icon
+      * obtained below, or used as is when SmallerSize is requested anyway.
       * @return Returns true if icon is loaded asynchronously.
       */
-    bool getTagThumbnail(TAlbum *album, QPixmap &icon, int size = 0);
+    bool getTagThumbnail(TAlbum *album, QPixmap &icon);
 
     /**
      * Return standard tag and album icons.
      * The third methods check if album is the root,
      * and returns the standard icon or the root standard icon.
      */
-    QPixmap getStandardTagIcon(int size = 0);
-    QPixmap getStandardTagRootIcon(int size = 0);
-    QPixmap getStandardTagIcon(TAlbum *album, int size = 0);
+    QPixmap getStandardTagIcon(RelativeSize size = NormalSize);
+    QPixmap getStandardTagRootIcon(RelativeSize size = NormalSize);
+    QPixmap getStandardTagIcon(TAlbum *album, RelativeSize size = NormalSize);
 
-    QPixmap getStandardAlbumIcon(int size);
-    QPixmap getStandardAlbumRootIcon(int size);
-    QPixmap getStandardAlbumIcon(PAlbum *album, int size = 0);
+    QPixmap getStandardAlbumIcon(RelativeSize size = NormalSize);
+    QPixmap getStandardAlbumRootIcon(RelativeSize size = NormalSize);
+    QPixmap getStandardAlbumIcon(PAlbum *album, RelativeSize size = NormalSize);
 
     /**
      * Blend tagIcon centered on dstIcon, where dstIcon is a standard
@@ -130,6 +149,8 @@
     void addURL(Album *album, const KURL &url);
     QPixmap loadIcon(const QString &name, int size = 0);
     QPixmap createTagThumbnail(const QPixmap &albumThumbnail);
+    int computeIconSize(RelativeSize size);
+    QRect computeBlendRect(int iconSize);
 
 };
 
--- trunk/extragear/graphics/digikam/libs/imageproperties/imagedescedittab.cpp #651127:651128
@@ -1291,7 +1291,7 @@
     {
         if (icon.isNull())
         {
-            item->setPixmap(0, loader->getStandardTagIcon(album));
+            item->setPixmap(0, loader->getStandardTagIcon(album, AlbumThumbnailLoader::SmallerSize));
         }
         else
         {
@@ -1423,7 +1423,7 @@
                 {
                     if (icon.isNull())
                     {
-                        icon = loader->getStandardTagIcon(album, 20);
+                        icon = loader->getStandardTagIcon(album, AlbumThumbnailLoader::SmallerSize);
                     }
                 }
                 QString text = album->title() + " (" + ((TAlbum*)album->parent())->prettyURL() + ')';
Comment 33 Marcel Wiesweg 2007-04-09 15:04:24 UTC
SVN commit 651817 by mwiesweg:

Remove the need for restart when changing album thumbnail size in setup:
- add method to set thumbnail size in AlbumThumbnailLoader (clean cache etc.)
- add signal from AlbumThumbnailLoader signalling the need to reload all thumbnails
- connect to this signal in the relevant classes

CCBUG: 102029
(bug is now really fixed)


 M  +19 -6     digikam/albumfolderview.cpp  
 M  +1 -0      digikam/albumfolderview.h  
 M  +23 -8     digikam/albumthumbnailloader.cpp  
 M  +17 -0     digikam/albumthumbnailloader.h  
 M  +2 -0      digikam/digikamapp.cpp  
 M  +13 -3     digikam/folderview.cpp  
 M  +12 -11    digikam/folderview.h  
 M  +20 -7     digikam/tagfilterview.cpp  
 M  +1 -0      digikam/tagfilterview.h  
 M  +14 -1     digikam/tagfolderview.cpp  
 M  +1 -0      digikam/tagfolderview.h  
 M  +13 -0     libs/imageproperties/imagedescedittab.cpp  
 M  +2 -1      libs/imageproperties/imagedescedittab.h  


--- trunk/extragear/graphics/digikam/digikam/albumfolderview.cpp #651816:651817
@@ -223,27 +223,30 @@
 
     connect(d->albumMan, SIGNAL(signalAlbumAdded(Album*)),
             this, SLOT(slotAlbumAdded(Album*)));
-            
+
     connect(d->albumMan, SIGNAL(signalAlbumDeleted(Album*)),
             this, SLOT(slotAlbumDeleted(Album*)));
-            
+
     connect(d->albumMan, SIGNAL(signalAlbumsCleared()),
             this, SLOT(slotAlbumsCleared()));
-            
+
     connect(d->albumMan, SIGNAL(signalAlbumIconChanged(Album*)),
             this, SLOT(slotAlbumIconChanged(Album*)));
-            
+
     connect(d->albumMan, SIGNAL(signalAlbumRenamed(Album*)),
             this, SLOT(slotAlbumRenamed(Album*)));
 
     AlbumThumbnailLoader *loader = AlbumThumbnailLoader::instance();
-    
+
     connect(loader, SIGNAL(signalThumbnail(Album *, const QPixmap&)),
             this, SLOT(slotGotThumbnailFromIcon(Album *, const QPixmap&)));
-            
+
     connect(loader, SIGNAL(signalFailed(Album *)),
             this, SLOT(slotThumbnailLost(Album *)));
 
+    connect(loader, SIGNAL(signalReloadThumbnails()),
+            this, SLOT(slotReloadThumbnails()));
+
     connect(this, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
             this, SLOT(slotContextMenu(QListViewItem*, const QPoint&, int)));
 
@@ -377,6 +380,16 @@
     // we already set the standard icon before loading
 }
 
+void AlbumFolderView::slotReloadThumbnails()
+{
+    AlbumList tList = AlbumManager::instance()->allPAlbums();
+    for (AlbumList::iterator it = tList.begin(); it != tList.end(); ++it)
+    {
+        PAlbum* album  = (PAlbum*)(*it);
+        setAlbumThumbnail(album);
+    }
+}
+
 void AlbumFolderView::slotAlbumIconChanged(Album* album)
 {
     if(!album || album->type() != Album::PHYSICAL)
--- trunk/extragear/graphics/digikam/digikam/albumfolderview.h #651816:651817
@@ -70,6 +70,7 @@
 
     void slotGotThumbnailFromIcon(Album *album, const QPixmap& thumbnail);
     void slotThumbnailLost(Album *album);
+    void slotReloadThumbnails();
     void slotSelectionChanged();
 
     void slotAlbumAdded(Album *);
--- trunk/extragear/graphics/digikam/digikam/albumthumbnailloader.cpp #651816:651817
@@ -322,22 +322,37 @@
     }
 }
 
-/*
 void AlbumThumbnailLoader::setThumbnailSize(int size)
 {
-    if (d->size == size)
+    if (d->iconSize == size)
         return;
 
-    d->size = size;
-    d->cache->clear();
-    if (d->thumbJob)
+    d->iconSize = size;
+
+    // clear task list
+    d->urlAlbumMap.clear();
+    // clear cached thumbnails
+    d->tagThumbnailMap.clear();
+
+    if (d->iconAlbumThumbJob)
     {
-        d->thumbJob->kill();
-        d->thumbJob = 0;
+        d->iconAlbumThumbJob->kill();
+        d->iconAlbumThumbJob= 0;
     }
+    if (d->iconTagThumbJob)
+    {
+        d->iconTagThumbJob->kill();
+        d->iconTagThumbJob= 0;
+    }
+
+    emit signalReloadThumbnails();
 }
-*/
 
+int AlbumThumbnailLoader::thumbnailSize() const
+{
+    return d->iconSize;
+}
+
 void AlbumThumbnailLoader::slotGotThumbnailFromIcon(const KURL &url, const QPixmap &thumbnail)
 {
     // We need to find all albums for which the given url has been requested,
--- trunk/extragear/graphics/digikam/digikam/albumthumbnailloader.h #651816:651817
@@ -50,6 +50,17 @@
     static void cleanUp();
 
     /**
+     * Change the size of the thumbnails.
+     * If the size differs from the current size,
+     * signalReloadThumbnails will be emitted.
+     */
+    void setThumbnailSize(int size);
+    /**
+     * Get the current default icon size
+     */
+    int  thumbnailSize() const;
+
+    /**
      * Album thumbnail size is configurable via the settings menu.
      * Some widgets use smaller icons than other widgets.
      * These widgets do not need to know the currently set icon size from
@@ -129,6 +140,12 @@
      */
     void signalFailed(Album *album);
 
+    /**
+     * Indicates that all album and tag thumbnails need to be reloaded.
+     * This is usually because the icon size has changed in the setup.
+     */
+    void signalReloadThumbnails();
+
 protected slots:
 
     void slotGotThumbnailFromIcon(const KURL&, const QPixmap&);
--- trunk/extragear/graphics/digikam/digikam/digikamapp.cpp #651816:651817
@@ -1486,6 +1486,8 @@
 
     d->view->applySettings(d->albumSettings);
 
+    AlbumThumbnailLoader::instance()->setThumbnailSize(d->albumSettings->getDefaultTreeIconSize());
+
     if (ImageWindow::imagewindowCreated())
         ImageWindow::imagewindow()->applySettings();
 
--- trunk/extragear/graphics/digikam/digikam/folderview.cpp #651816:651817
@@ -35,6 +35,7 @@
 #include "ddebug.h"
 #include "albummanager.h"
 #include "albumsettings.h"
+#include "albumthumbnailloader.h"
 #include "themeengine.h"
 #include "dragobjects.h"
 #include "folderitem.h"
@@ -74,7 +75,7 @@
 {
 
     d = new FolderViewPriv;
-    
+
     d->active = false;
     d->dragItem         = 0;
     d->oldHighlightItem = 0;
@@ -84,7 +85,10 @@
 
     connect(AlbumManager::instance(), SIGNAL(signalAllAlbumsLoaded()),
             this, SLOT(slotAllAlbumsLoaded()));
-    
+
+    connect(AlbumThumbnailLoader::instance(), SIGNAL(signalReloadThumbnails()),
+            this, SLOT(slotIconSizeChanged()));
+
     setColumnAlignment(0, Qt::AlignLeft|Qt::AlignVCenter);
     fontChange(font());
 }
@@ -150,11 +154,17 @@
 {
     // this is bad, since the settings value might not always be the _real_ height of the thumbnail.
     // (e.g. when it is blended, as for the tags)
-    d->itemHeight = QMAX(AlbumSettings::instance()->getDefaultTreeIconSize() + 2*itemMargin(), fontMetrics().height());
+    d->itemHeight = QMAX(AlbumThumbnailLoader::instance()->thumbnailSize() + 2*itemMargin(), fontMetrics().height());
     QListView::fontChange(oldFont);
     slotThemeChanged();
 }
 
+void FolderView::slotIconSizeChanged()
+{
+    d->itemHeight = QMAX(AlbumThumbnailLoader::instance()->thumbnailSize() + 2*itemMargin(), fontMetrics().height());
+    slotThemeChanged();
+}
+
 void FolderView::contentsMouseMoveEvent(QMouseEvent *e)
 {
     QListView::contentsMouseMoveEvent(e);
--- trunk/extragear/graphics/digikam/digikam/folderview.h #651816:651817
@@ -55,7 +55,7 @@
     QRect    itemRect(QListViewItem *item) const;
     QPixmap  itemBasePixmapRegular() const;
     QPixmap  itemBasePixmapSelected() const;
-    
+
 protected:
 
     void contentsMousePressEvent(QMouseEvent *e);
@@ -65,38 +65,39 @@
     void contentsDragMoveEvent(QDragMoveEvent *e);
     void contentsDragLeaveEvent(QDragLeaveEvent * e);
     void contentsDropEvent(QDropEvent *e);
-            
+
     virtual bool acceptDrop(const QDropEvent *e) const;
-        
+
     void startDrag();
     FolderItem* dragItem() const;
-    
+
     void resizeEvent(QResizeEvent* e);
     void fontChange(const QFont& oldFont);
-    
+
     virtual void selectItem(int id);
- 
+
     /**
      * load the last state from the view from disk
      */
     virtual void loadViewState();
-    
+
     /**
      * writes the views state to disk
      */
     virtual void saveViewState();
-    
+
     bool mouseInItemRect(QListViewItem* item, int x) const;
-    
+
 protected slots:
-    
+
     virtual void slotSelectionChanged();
     virtual void slotAllAlbumsLoaded();
 
 private slots:
 
     void slotThemeChanged();
-    
+    void slotIconSizeChanged();
+
 private:
 
     FolderViewPriv      *d;
--- trunk/extragear/graphics/digikam/digikam/tagfilterview.cpp #651816:651817
@@ -208,30 +208,33 @@
 
     connect(AlbumManager::instance(), SIGNAL(signalAlbumAdded(Album*)),
             this, SLOT(slotTagAdded(Album*)));
-            
+
     connect(AlbumManager::instance(), SIGNAL(signalAlbumDeleted(Album*)),
             this, SLOT(slotTagDeleted(Album*)));
-            
+
     connect(AlbumManager::instance(), SIGNAL(signalAlbumRenamed(Album*)),
             this, SLOT(slotTagRenamed(Album*)));
-            
+
     connect(AlbumManager::instance(), SIGNAL(signalAlbumsCleared()),
             this, SLOT(slotClear()));
-            
+
     connect(AlbumManager::instance(), SIGNAL(signalAlbumIconChanged(Album*)),
             this, SLOT(slotAlbumIconChanged(Album*)));
-            
+
     connect(AlbumManager::instance(), SIGNAL(signalTAlbumMoved(TAlbum*, TAlbum*)),
             this, SLOT(slotTagMoved(TAlbum*, TAlbum*)));
 
     AlbumThumbnailLoader *loader = AlbumThumbnailLoader::instance();
-    
+
     connect(loader, SIGNAL(signalThumbnail(Album *, const QPixmap&)),
             this, SLOT(slotGotThumbnailFromIcon(Album *, const QPixmap&)));
-            
+
     connect(loader, SIGNAL(signalFailed(Album *)),
             this, SLOT(slotThumbnailLost(Album *)));
 
+    connect(loader, SIGNAL(signalReloadThumbnails()),
+            this, SLOT(slotReloadThumbnails()));
+
     connect(this, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
             this, SLOT(slotContextMenu(QListViewItem*, const QPoint&, int)));
 
@@ -702,6 +705,16 @@
     // we already set the standard icon before loading
 }
 
+void TagFilterView::slotReloadThumbnails()
+{
+    AlbumList tList = AlbumManager::instance()->allTAlbums();
+    for (AlbumList::iterator it = tList.begin(); it != tList.end(); ++it)
+    {
+        TAlbum* tag  = (TAlbum*)(*it);
+        setTagThumbnail(tag);
+    }
+}
+
 void TagFilterView::slotAlbumIconChanged(Album* album)
 {
     if(!album || album->type() != Album::TAG)
--- trunk/extragear/graphics/digikam/digikam/tagfilterview.h #651816:651817
@@ -85,6 +85,7 @@
     void slotABCContextMenu();
     void slotGotThumbnailFromIcon(Album *album, const QPixmap& thumbnail);
     void slotThumbnailLost(Album *album);
+    void slotReloadThumbnails();
 
 private:
 
--- trunk/extragear/graphics/digikam/digikam/tagfolderview.cpp #651816:651817
@@ -162,13 +162,16 @@
             this, SLOT(slotAlbumMoved(TAlbum*, TAlbum*)));
 
     AlbumThumbnailLoader *loader = AlbumThumbnailLoader::instance();
-    
+
     connect(loader, SIGNAL(signalThumbnail(Album *, const QPixmap&)),
             this, SLOT(slotGotThumbnailFromIcon(Album *, const QPixmap&)));
 
     connect(loader, SIGNAL(signalFailed(Album *)),
             this, SLOT(slotThumbnailLost(Album *)));
 
+    connect(loader, SIGNAL(signalReloadThumbnails()),
+            this, SLOT(slotReloadThumbnails()));
+
     connect(this, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
             SLOT(slotContextMenu(QListViewItem*, const QPoint&, int)));
 
@@ -339,6 +342,16 @@
     // we already set the standard icon before loading
 }
 
+void TagFolderView::slotReloadThumbnails()
+{
+    AlbumList tList = AlbumManager::instance()->allTAlbums();
+    for (AlbumList::iterator it = tList.begin(); it != tList.end(); ++it)
+    {
+        TAlbum* tag  = (TAlbum*)(*it);
+        setTagThumbnail(tag);
+    }
+}
+
 void TagFolderView::slotAlbumIconChanged(Album* album)
 {
     if(!album || album->type() != Album::TAG)
--- trunk/extragear/graphics/digikam/digikam/tagfolderview.h #651816:651817
@@ -76,6 +76,7 @@
     void slotABCContextMenu();
     void slotGotThumbnailFromIcon(Album *album, const QPixmap& thumbnail);
     void slotThumbnailLost(Album *album);
+    void slotReloadThumbnails();
 
 private:
 
--- trunk/extragear/graphics/digikam/libs/imageproperties/imagedescedittab.cpp #651816:651817
@@ -303,6 +303,9 @@
     connect(loader, SIGNAL(signalFailed(Album *)),
             this, SLOT(slotThumbnailLost(Album *)));
 
+    connect(loader, SIGNAL(signalReloadThumbnails()),
+            this, SLOT(slotReloadThumbnails()));
+
     ImageAttributesWatch *watch = ImageAttributesWatch::instance();
 
     connect(watch, SIGNAL(signalImageTagsChanged(Q_LLONG)),
@@ -1326,6 +1329,16 @@
     // we already set the standard icon before loading
 }
 
+void ImageDescEditTab::slotReloadThumbnails()
+{
+    AlbumList tList = AlbumManager::instance()->allTAlbums();
+    for (AlbumList::iterator it = tList.begin(); it != tList.end(); ++it)
+    {
+        TAlbum* tag  = (TAlbum*)(*it);
+        setTagThumbnail(tag);
+    }
+}
+
 void ImageDescEditTab::slotImageTagsChanged(Q_LLONG imageId)
 {
     // don't lose modifications
--- trunk/extragear/graphics/digikam/libs/imageproperties/imagedescedittab.h #651816:651817
@@ -111,10 +111,11 @@
     void slotAlbumRenamed(Album* a);
     void slotAlbumsCleared();
     void slotAlbumMoved(TAlbum* tag, TAlbum* newParent);
-    
+
     void slotABCContextMenu();
     void slotGotThumbnailFromIcon(Album *album, const QPixmap& thumbnail);
     void slotThumbnailLost(Album *album);
+    void slotReloadThumbnails();
 
     void slotImageTagsChanged(Q_LLONG imageId);
     void slotImagesChanged(int albumId);