[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Threshold icon type
From: Antonio Larrosa =?iso-8859-1?q?Jim=E9nez?= <larrosa () kde ! org>
Date: 2001-07-15 0:19:34
[Download RAW message or body]
Hi,
Tackat asked me some time ago for a mode in the iconloader that allows it
to specify a threshold in the following way:
If the distance between the icon size requested and the icon size
available is below the threshold, the icon is returned by the iconloader
as it is, but if that distance is greater than the threshold, then the
icon is resized to the requested size.
This patch implements that, and sets the type for all the directories on
the hicolor icon theme to be Threshold instead of Fixed as tackat told me
he would like this to work.
I know it's very late to introduce these kind of changes, but tackat told
me he really thinks it should be done, so I post the patch here, and leave
him argue about it with Waldo ;-)
Btw, I've tested for a few minutes and it seems to work as expected, but
some more testing wouldn't be bad.
Greetings,
--
Antonio Larrosa Jimenez
KDE Core developer - larrosa@kde.org
SuSE Labs developer - larrosa@suse.de
http://perso.wanadoo.es/antlarr
KDE - The development framework of the future, today.
["kdelibs.diff" (text/x-diff)]
Index: kdecore/kiconloader.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kiconloader.cpp,v
retrieving revision 1.160
diff -u -p -r1.160 kiconloader.cpp
--- kdecore/kiconloader.cpp 2001/05/10 12:07:42 1.160
+++ kdecore/kiconloader.cpp 2001/07/14 23:56:53
@@ -147,6 +147,7 @@ struct KIconLoaderPrivate
QImage lastImage; // last loaded image without effect applied
QString lastImageKey; // key for icon without effect
bool lastIconType; // see KIcon::type
+ bool lastIconThreshold; // see KIcon::threshold
};
/*** KIconLoader: the icon loader ***/
@@ -519,6 +520,7 @@ QPixmap KIconLoader::loadIcon(const QStr
QImage *img = 0;
int iconType;
+ int iconThreshold;
if ( ( path_store != 0L ) ||
noEffectKey != d->lastImageKey )
@@ -562,15 +564,18 @@ QPixmap KIconLoader::loadIcon(const QStr
return pix;
iconType = icon.type;
+ iconThreshold = icon.threshold;
d->lastImage = img->copy();
d->lastImageKey = noEffectKey;
d->lastIconType = iconType;
+ d->lastIconThreshold = iconThreshold;
}
else
{
img = new QImage( d->lastImage.copy() );
iconType = d->lastIconType;
+ iconThreshold = d->lastIconThreshold;
}
// Blend in all overlays
@@ -600,6 +605,11 @@ QPixmap KIconLoader::loadIcon(const QStr
if ((iconType == KIcon::Scalable) && (size != img->width()))
{
*img = img->smoothScale(size, size);
+ }
+ if ((iconType == KIcon::Threshold) && (size != img->width()))
+ {
+ if ( abs(size-img->width())>iconThreshold )
+ *img = img->smoothScale(size, size);
}
if ((group >= 0) && d->mpGroups[group].dblPixels)
{
Index: kdecore/kicontheme.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kicontheme.cpp,v
retrieving revision 1.35
diff -u -p -r1.35 kicontheme.cpp
--- kdecore/kicontheme.cpp 2001/03/09 02:45:28 1.35
+++ kdecore/kicontheme.cpp 2001/07/14 23:56:54
@@ -61,11 +61,13 @@ public:
int size() const { return mSize; }
int minSize() const { return mMinSize; }
int maxSize() const { return mMaxSize; }
+ int threshold() const { return mThreshold; }
private:
bool mbValid;
int mType, mSize, mContext;
int mMinSize, mMaxSize;
+ int mThreshold;
QString mDir;
};
@@ -233,6 +235,7 @@ QStringList KIconTheme::queryIcons(int s
if ((dir->type() == KIcon::Scalable) &&
(size >= dir->minSize()) && (size <= dir->maxSize()))
return dir->iconList();
+ if (dir->type() == KIcon::Threshold) return dir->iconList();
}
dirs.toFirst();
@@ -304,10 +307,14 @@ KIcon KIconTheme::iconPath(const QString
if ((dir->type() == KIcon::Scalable) &&
((size < dir->minSize()) || (size > dir->maxSize())))
continue;
+ if ((dir->type() == KIcon::Threshold) &&
+ (abs(dir->size()-size) > dir->threshold()))
+ continue;
} else
{
dw = dir->size() - size;
- if ((dw > 7) || (abs(dw) >= abs(delta)))
+ if (dir->type() != KIcon::Threshold &&
+ ((dw > 7) || (abs(dw) >= abs(delta))))
continue;
}
@@ -317,6 +324,7 @@ KIcon KIconTheme::iconPath(const QString
icon.path = path;
icon.size = dir->size();
icon.type = dir->type();
+ icon.threshold = dir->threshold();
icon.context = dir->context();
// if we got in MatchExact that far, we find no better
@@ -431,6 +439,8 @@ KIconThemeDir::KIconThemeDir(const QStri
mType = KIcon::Fixed;
else if (tmp == "Scalable")
mType = KIcon::Scalable;
+ else if (tmp == "Threshold")
+ mType = KIcon::Threshold;
else {
kdDebug(264) << "Invalid Type= line for icon theme: " << mDir << "\n";
return;
@@ -439,7 +449,8 @@ KIconThemeDir::KIconThemeDir(const QStri
{
mMinSize = config->readNumEntry("MinSize", mSize);
mMaxSize = config->readNumEntry("MaxSize", mSize);
- }
+ } else if (mType == KIcon::Threshold)
+ mThreshold = config->readNumEntry("Threshold", 2);
mbValid = true;
}
Index: kdecore/kicontheme.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kicontheme.h,v
retrieving revision 1.14
diff -u -p -r1.14 kicontheme.h
--- kdecore/kicontheme.h 2001/03/26 21:34:55 1.14
+++ kdecore/kicontheme.h 2001/07/14 23:56:54
@@ -39,7 +39,7 @@ public:
bool isValid() const { return size != 0; }
enum Context { Any, Action, Application, Device, FileSystem, MimeType };
- enum Types { Fixed, Scalable };
+ enum Types { Fixed, Scalable, Threshold };
enum MatchType { MatchExact, MatchBest };
// if you add a group here, make sure to change the config reading in
// KIconLoader too
@@ -56,8 +56,11 @@ public:
/** The context of the icon. */
int context;
- /** The type of the icon: Fixed or Scalable. */
+ /** The type of the icon: Fixed, Scalable or Threshold. */
int type;
+
+ /** The threshold in case type == Threshold */
+ int threshold;
/** The full path of the icon. */
QString path;
Index: pics/hicolor/index.desktop
===================================================================
RCS file: /home/kde/kdelibs/pics/hicolor/index.desktop,v
retrieving revision 1.120
diff -u -p -r1.120 index.desktop
--- pics/hicolor/index.desktop 2001/07/08 20:34:01 1.120
+++ pics/hicolor/index.desktop 2001/07/14 23:57:04
@@ -95,68 +95,68 @@ Directories=16x16/actions,22x22/actions,
[16x16/actions]
Size=16
Context=Actions
-Type=Fixed
+Type=Threshold
[22x22/actions]
Size=22
Context=Actions
-Type=Fixed
+Type=Threshold
[32x32/actions]
Size=32
Context=Actions
-Type=Fixed
+Type=Threshold
[16x16/apps]
Size=16
Context=Applications
-Type=Fixed
+Type=Threshold
[16x16/devices]
Size=16
Context=Devices
-Type=Fixed
+Type=Threshold
[32x32/apps]
Size=32
Context=Applications
-Type=Fixed
+Type=Threshold
[32x32/devices]
Size=32
Context=Devices
-Type=Fixed
+Type=Threshold
[16x16/filesystems]
Size=16
Context=FileSystems
-Type=Fixed
+Type=Threshold
[32x32/filesystems]
Size=32
Context=FileSystems
-Type=Fixed
+Type=Threshold
[16x16/mimetypes]
Size=16
Context=MimeTypes
-Type=Fixed
+Type=Threshold
[32x32/mimetypes]
Size=32
Context=MimeTypes
-Type=Fixed
+Type=Threshold
[48x48/apps]
Size=48
Context=Applications
-Type=Fixed
+Type=Threshold
[48x48/devices]
Size=48
Context=Devices
-Type=Fixed
+Type=Threshold
[48x48/filesystems]
Size=48
Context=FileSystems
-Type=Fixed
+Type=Threshold
[48x48/mimetypes]
Size=48
Context=MimeTypes
-Type=Fixed
+Type=Threshold
[64x64/mimetypes]
Size=64
Context=MimeTypes
-Type=Fixed
+Type=Threshold
[64x64/filesystems]
Size=64
Context=FileSystems
-Type=Fixed
+Type=Threshold
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic