You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
606 lines
17 KiB
606 lines
17 KiB
15 years ago
|
/* vi: ts=8 sts=4 sw=4
|
||
|
*
|
||
|
* $Id$
|
||
|
*
|
||
13 years ago
|
* This file is part of the KDE project, module tdecore.
|
||
15 years ago
|
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
|
||
|
* Antonio Larrosa <larrosa@kde.org>
|
||
|
*
|
||
|
* This is free software; it comes under the GNU Library General
|
||
|
* Public License, version 2. See the file "COPYING.LIB" for the
|
||
|
* exact licensing terms.
|
||
|
*
|
||
|
* kicontheme.cpp: Lowlevel icon theme handling.
|
||
|
*/
|
||
|
|
||
|
#include <sys/stat.h>
|
||
|
#include <unistd.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <config.h>
|
||
|
|
||
15 years ago
|
#include <tqstring.h>
|
||
|
#include <tqstringlist.h>
|
||
|
#include <tqvaluelist.h>
|
||
|
#include <tqmap.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqpixmapcache.h>
|
||
|
#include <tqimage.h>
|
||
|
#include <tqfileinfo.h>
|
||
|
#include <tqdir.h>
|
||
15 years ago
|
|
||
|
#include <kdebug.h>
|
||
|
#include <kstandarddirs.h>
|
||
|
#include <kglobal.h>
|
||
|
#include <kconfig.h>
|
||
|
#include <ksimpleconfig.h>
|
||
|
#include <kinstance.h>
|
||
|
|
||
|
#include "kicontheme.h"
|
||
|
|
||
|
class KIconThemePrivate
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
TQString example, screenshot;
|
||
|
TQString linkOverlay, lockOverlay, zipOverlay, shareOverlay;
|
||
15 years ago
|
bool hidden;
|
||
|
KSharedConfig::Ptr sharedConfig;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* A subdirectory in an icon theme.
|
||
|
*/
|
||
|
class KIconThemeDir
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
KIconThemeDir(const TQString& dir, const KConfigBase *config);
|
||
15 years ago
|
|
||
|
bool isValid() const { return mbValid; }
|
||
15 years ago
|
TQString iconPath(const TQString& name) const;
|
||
|
TQStringList iconList() const;
|
||
|
TQString dir() const { return mDir; }
|
||
15 years ago
|
|
||
|
KIcon::Context context() const { return mContext; }
|
||
|
KIcon::Type type() const { return mType; }
|
||
|
int size() const { return mSize; }
|
||
|
int minSize() const { return mMinSize; }
|
||
|
int maxSize() const { return mMaxSize; }
|
||
|
int threshold() const { return mThreshold; }
|
||
|
|
||
|
private:
|
||
|
bool mbValid;
|
||
|
KIcon::Type mType;
|
||
|
KIcon::Context mContext;
|
||
|
int mSize, mMinSize, mMaxSize;
|
||
|
int mThreshold;
|
||
|
|
||
15 years ago
|
TQString mDir;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
/*** KIconTheme ***/
|
||
|
|
||
15 years ago
|
KIconTheme::KIconTheme(const TQString& name, const TQString& appName)
|
||
15 years ago
|
{
|
||
|
d = new KIconThemePrivate;
|
||
|
|
||
15 years ago
|
TQStringList icnlibs;
|
||
|
TQStringList::ConstIterator it, itDir;
|
||
|
TQStringList themeDirs;
|
||
|
TQString cDir;
|
||
15 years ago
|
|
||
|
// Applications can have local additions to the global "locolor" and
|
||
|
// "hicolor" icon themes. For these, the _global_ theme description
|
||
|
// files are used..
|
||
|
|
||
|
if (!appName.isEmpty() &&
|
||
|
( name == "crystalsvg" || name== "hicolor" || name == "locolor" ) )
|
||
|
{
|
||
|
icnlibs = KGlobal::dirs()->resourceDirs("data");
|
||
|
for (it=icnlibs.begin(); it!=icnlibs.end(); ++it)
|
||
|
{
|
||
|
cDir = *it + appName + "/icons/" + name;
|
||
15 years ago
|
if (TQFile::exists( cDir ))
|
||
15 years ago
|
themeDirs += cDir + "/";
|
||
|
}
|
||
|
}
|
||
|
// Find the theme description file. These are always global.
|
||
|
|
||
|
icnlibs = KGlobal::dirs()->resourceDirs("icon");
|
||
|
icnlibs += KGlobal::dirs()->resourceDirs("xdgdata-icon");
|
||
|
icnlibs += "/usr/share/pixmaps";
|
||
|
// These are not in the icon spec, but e.g. GNOME puts some icons there anyway.
|
||
|
icnlibs += KGlobal::dirs()->resourceDirs("xdgdata-pixmap");
|
||
|
for (it=icnlibs.begin(); it!=icnlibs.end(); ++it)
|
||
|
{
|
||
|
cDir = *it + name + "/";
|
||
|
if (KStandardDirs::exists(cDir))
|
||
|
{
|
||
|
themeDirs += cDir;
|
||
|
if (mDir.isEmpty()
|
||
|
&& (KStandardDirs::exists( cDir + "index.desktop") || KStandardDirs::exists( cDir + "index.theme")))
|
||
|
mDir = cDir;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (mDir.isEmpty())
|
||
|
{
|
||
|
kdDebug(264) << "Icon theme " << name << " not found.\n";
|
||
|
return;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString fileName, mainSection;
|
||
|
if(TQFile::exists(mDir + "index.desktop")) {
|
||
15 years ago
|
fileName = mDir + "index.desktop";
|
||
|
mainSection="KDE Icon Theme";
|
||
|
} else {
|
||
|
fileName = mDir + "index.theme";
|
||
|
mainSection="Icon Theme";
|
||
|
}
|
||
|
// Use KSharedConfig to avoid parsing the file many times, from each kinstance.
|
||
|
// Need to keep a ref to it to make this useful
|
||
|
d->sharedConfig = KSharedConfig::openConfig( fileName, true /*readonly*/, false /*useKDEGlobals*/ );
|
||
|
KConfig& cfg = *d->sharedConfig;
|
||
|
//was: KSimpleConfig cfg(fileName);
|
||
|
|
||
|
cfg.setGroup(mainSection);
|
||
|
mName = cfg.readEntry("Name");
|
||
|
mDesc = cfg.readEntry("Comment");
|
||
|
mDepth = cfg.readNumEntry("DisplayDepth", 32);
|
||
|
mInherits = cfg.readListEntry("Inherits");
|
||
|
if ( name != "crystalsvg" )
|
||
15 years ago
|
for ( TQStringList::Iterator it = mInherits.begin(); it != mInherits.end(); ++it )
|
||
15 years ago
|
if ( *it == "default" || *it == "hicolor" ) *it="crystalsvg";
|
||
|
|
||
|
d->hidden = cfg.readBoolEntry("Hidden", false);
|
||
|
d->example = cfg.readPathEntry("Example");
|
||
|
d->screenshot = cfg.readPathEntry("ScreenShot");
|
||
|
d->linkOverlay = cfg.readEntry("LinkOverlay", "link");
|
||
|
d->lockOverlay = cfg.readEntry("LockOverlay", "lock");
|
||
|
d->zipOverlay = cfg.readEntry("ZipOverlay", "zip");
|
||
|
d->shareOverlay = cfg.readEntry("ShareOverlay","share");
|
||
|
|
||
15 years ago
|
TQStringList dirs = cfg.readPathListEntry("Directories");
|
||
15 years ago
|
mDirs.setAutoDelete(true);
|
||
|
for (it=dirs.begin(); it!=dirs.end(); ++it)
|
||
|
{
|
||
|
cfg.setGroup(*it);
|
||
|
for (itDir=themeDirs.begin(); itDir!=themeDirs.end(); ++itDir)
|
||
|
{
|
||
|
if (KStandardDirs::exists(*itDir + *it + "/"))
|
||
|
{
|
||
|
KIconThemeDir *dir = new KIconThemeDir(*itDir + *it, &cfg);
|
||
|
if (!dir->isValid())
|
||
|
{
|
||
|
kdDebug(264) << "Icon directory " << *itDir << " group " << *it << " not valid.\n";
|
||
|
delete dir;
|
||
|
}
|
||
|
else
|
||
|
mDirs.append(dir);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Expand available sizes for scalable icons to their full range
|
||
|
int i;
|
||
15 years ago
|
TQMap<int,TQValueList<int> > scIcons;
|
||
15 years ago
|
for (KIconThemeDir *dir=mDirs.first(); dir!=0L; dir=mDirs.next())
|
||
|
{
|
||
13 years ago
|
if ((dir->type() == KIcon::Scalable) && !scIcons.contains(dir->size()))
|
||
15 years ago
|
{
|
||
15 years ago
|
TQValueList<int> lst;
|
||
15 years ago
|
for (i=dir->minSize(); i<=dir->maxSize(); i++)
|
||
|
lst += i;
|
||
|
scIcons[dir->size()] = lst;
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQStringList groups;
|
||
15 years ago
|
groups += "Desktop";
|
||
|
groups += "Toolbar";
|
||
|
groups += "MainToolbar";
|
||
|
groups += "Small";
|
||
|
groups += "Panel";
|
||
|
const int defDefSizes[] = { 32, 22, 22, 16, 32 };
|
||
|
cfg.setGroup(mainSection);
|
||
|
for (it=groups.begin(), i=0; it!=groups.end(); ++it, i++)
|
||
|
{
|
||
|
mDefSize[i] = cfg.readNumEntry(*it + "Default", defDefSizes[i]);
|
||
15 years ago
|
TQValueList<int> exp, lst = cfg.readIntListEntry(*it + "Sizes");
|
||
|
TQValueList<int>::ConstIterator it2;
|
||
15 years ago
|
for (it2=lst.begin(); it2!=lst.end(); ++it2)
|
||
|
{
|
||
13 years ago
|
if (scIcons.contains(*it2))
|
||
15 years ago
|
exp += scIcons[*it2];
|
||
|
else
|
||
|
exp += *it2;
|
||
|
}
|
||
|
mSizes[i] = exp;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
KIconTheme::~KIconTheme()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
bool KIconTheme::isValid() const
|
||
|
{
|
||
|
return !mDirs.isEmpty();
|
||
|
}
|
||
|
|
||
|
bool KIconTheme::isHidden() const
|
||
|
{
|
||
|
return d->hidden;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KIconTheme::example() const { return d->example; }
|
||
|
TQString KIconTheme::screenshot() const { return d->screenshot; }
|
||
|
TQString KIconTheme::linkOverlay() const { return d->linkOverlay; }
|
||
|
TQString KIconTheme::lockOverlay() const { return d->lockOverlay; }
|
||
|
TQString KIconTheme::zipOverlay() const { return d->zipOverlay; }
|
||
|
TQString KIconTheme::shareOverlay() const { return d->shareOverlay; }
|
||
15 years ago
|
|
||
|
int KIconTheme::defaultSize(KIcon::Group group) const
|
||
|
{
|
||
|
if ((group < 0) || (group >= KIcon::LastGroup))
|
||
|
{
|
||
|
kdDebug(264) << "Illegal icon group: " << group << "\n";
|
||
|
return -1;
|
||
|
}
|
||
|
return mDefSize[group];
|
||
|
}
|
||
|
|
||
15 years ago
|
TQValueList<int> KIconTheme::querySizes(KIcon::Group group) const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQValueList<int> empty;
|
||
15 years ago
|
if ((group < 0) || (group >= KIcon::LastGroup))
|
||
|
{
|
||
|
kdDebug(264) << "Illegal icon group: " << group << "\n";
|
||
|
return empty;
|
||
|
}
|
||
|
return mSizes[group];
|
||
|
}
|
||
|
|
||
15 years ago
|
TQStringList KIconTheme::queryIcons(int size, KIcon::Context context) const
|
||
15 years ago
|
{
|
||
|
int delta = 1000, dw;
|
||
|
|
||
15 years ago
|
TQPtrListIterator<KIconThemeDir> dirs(mDirs);
|
||
15 years ago
|
KIconThemeDir *dir;
|
||
|
|
||
14 years ago
|
// Try to find exact match
|
||
15 years ago
|
TQStringList result;
|
||
15 years ago
|
for ( ; dirs.current(); ++dirs)
|
||
|
{
|
||
|
dir = dirs.current();
|
||
|
if ((context != KIcon::Any) && (context != dir->context()))
|
||
|
continue;
|
||
|
if ((dir->type() == KIcon::Fixed) && (dir->size() == size))
|
||
|
{
|
||
|
result += dir->iconList();
|
||
|
continue;
|
||
|
}
|
||
|
if ((dir->type() == KIcon::Scalable) &&
|
||
|
(size >= dir->minSize()) && (size <= dir->maxSize()))
|
||
|
{
|
||
|
result += dir->iconList();
|
||
|
continue;
|
||
|
}
|
||
|
if ((dir->type() == KIcon::Threshold) &&
|
||
|
(abs(size-dir->size())<dir->threshold()))
|
||
|
result+=dir->iconList();
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
|
||
|
dirs.toFirst();
|
||
|
|
||
|
// Find close match
|
||
|
KIconThemeDir *best = 0L;
|
||
|
for ( ; dirs.current(); ++dirs)
|
||
|
{
|
||
|
dir = dirs.current();
|
||
|
if ((context != KIcon::Any) && (context != dir->context()))
|
||
|
continue;
|
||
|
dw = dir->size() - size;
|
||
|
if ((dw > 6) || (abs(dw) >= abs(delta)))
|
||
|
continue;
|
||
|
delta = dw;
|
||
|
best = dir;
|
||
|
}
|
||
|
if (best == 0L)
|
||
15 years ago
|
return TQStringList();
|
||
15 years ago
|
|
||
|
return best->iconList();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQStringList KIconTheme::queryIconsByContext(int size, KIcon::Context context) const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQPtrListIterator<KIconThemeDir> dirs(mDirs);
|
||
15 years ago
|
int dw;
|
||
|
KIconThemeDir *dir;
|
||
|
|
||
|
// We want all the icons for a given context, but we prefer icons
|
||
|
// of size size . Note that this may (will) include duplicate icons
|
||
15 years ago
|
//TQStringList iconlist[34]; // 33 == 48-16+1
|
||
|
TQStringList iconlist[128]; // 33 == 48-16+1
|
||
15 years ago
|
// Usually, only the 0, 6 (22-16), 10 (32-22), 16 (48-32 or 32-16),
|
||
|
// 26 (48-22) and 32 (48-16) will be used, but who knows if someone
|
||
|
// will make icon themes with different icon sizes.
|
||
|
|
||
|
for ( ; dirs.current(); ++dirs)
|
||
|
{
|
||
|
dir = dirs.current();
|
||
|
if ((context != KIcon::Any) && (context != dir->context()))
|
||
|
continue;
|
||
|
dw = abs(dir->size() - size);
|
||
|
iconlist[(dw<127)?dw:127]+=dir->iconList();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQStringList iconlistResult;
|
||
15 years ago
|
for (int i=0; i<128; i++) iconlistResult+=iconlist[i];
|
||
|
|
||
|
return iconlistResult;
|
||
|
}
|
||
|
|
||
|
bool KIconTheme::hasContext(KIcon::Context context) const
|
||
|
{
|
||
15 years ago
|
TQPtrListIterator<KIconThemeDir> dirs(mDirs);
|
||
15 years ago
|
KIconThemeDir *dir;
|
||
|
|
||
|
for ( ; dirs.current(); ++dirs)
|
||
|
{
|
||
|
dir = dirs.current();
|
||
|
if ((context == KIcon::Any) || (context == dir->context()))
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
15 years ago
|
KIcon KIconTheme::iconPath(const TQString& name, int size, KIcon::MatchType match) const
|
||
15 years ago
|
{
|
||
|
KIcon icon;
|
||
15 years ago
|
TQString path;
|
||
15 years ago
|
int delta = -1000, dw;
|
||
|
KIconThemeDir *dir;
|
||
|
|
||
|
dw = 1000; // shut up, gcc
|
||
15 years ago
|
TQPtrListIterator<KIconThemeDir> dirs(mDirs);
|
||
15 years ago
|
for ( ; dirs.current(); ++dirs)
|
||
|
{
|
||
|
dir = dirs.current();
|
||
|
|
||
|
if (match == KIcon::MatchExact)
|
||
|
{
|
||
|
if ((dir->type() == KIcon::Fixed) && (dir->size() != size))
|
||
|
continue;
|
||
|
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 < 0 means need to scale up to get an icon of the requested size
|
||
|
if (dir->type() == KIcon::Fixed)
|
||
|
{
|
||
|
dw = dir->size() - size;
|
||
|
} else if (dir->type() == KIcon::Scalable)
|
||
|
{
|
||
|
if (size < dir->minSize())
|
||
|
dw = dir->minSize() - size;
|
||
|
else if (size > dir->maxSize())
|
||
|
dw = dir->maxSize() - size;
|
||
|
else
|
||
|
dw = 0;
|
||
|
} else if (dir->type() == KIcon::Threshold)
|
||
|
{
|
||
|
if (size < dir->size() - dir->threshold())
|
||
|
dw = dir->size() - dir->threshold() - size;
|
||
|
else if (size > dir->size() + dir->threshold())
|
||
|
dw = dir->size() + dir->threshold() - size;
|
||
|
else
|
||
|
dw = 0;
|
||
|
}
|
||
|
/* Skip this if we've found a closer one, unless
|
||
|
it's a downscale, and we only had upscales befores.
|
||
|
This is to avoid scaling up unless we have to,
|
||
|
since that looks very ugly */
|
||
15 years ago
|
if (/*(abs(dw) >= abs(delta)) ||*/
|
||
15 years ago
|
(delta > 0 && dw < 0))
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
path = dir->iconPath(name);
|
||
|
if (path.isEmpty())
|
||
|
continue;
|
||
|
icon.path = path;
|
||
|
icon.size = dir->size();
|
||
|
icon.type = dir->type();
|
||
|
icon.threshold = dir->threshold();
|
||
|
icon.context = dir->context();
|
||
|
|
||
14 years ago
|
// if we got in MatchExact that far, we find no better
|
||
15 years ago
|
if (match == KIcon::MatchExact)
|
||
|
return icon;
|
||
|
else
|
||
|
{
|
||
|
delta = dw;
|
||
14 years ago
|
if (delta==0) return icon; // We won't find a better match anyway
|
||
15 years ago
|
}
|
||
|
}
|
||
|
return icon;
|
||
|
}
|
||
|
|
||
|
// static
|
||
15 years ago
|
TQString *KIconTheme::_theme = 0L;
|
||
15 years ago
|
|
||
|
// static
|
||
15 years ago
|
TQStringList *KIconTheme::_theme_list = 0L;
|
||
15 years ago
|
|
||
|
// static
|
||
15 years ago
|
TQString KIconTheme::current()
|
||
15 years ago
|
{
|
||
|
// Static pointer because of unloading problems wrt DSO's.
|
||
|
if (_theme != 0L)
|
||
|
return *_theme;
|
||
|
|
||
15 years ago
|
_theme = new TQString();
|
||
15 years ago
|
KConfig *config = KGlobal::config();
|
||
|
KConfigGroupSaver saver(config, "Icons");
|
||
|
*_theme = config->readEntry("Theme",defaultThemeName());
|
||
14 years ago
|
if ( *_theme == TQString::tqfromLatin1("hicolor") ) *_theme = defaultThemeName();
|
||
15 years ago
|
/* if (_theme->isEmpty())
|
||
|
{
|
||
15 years ago
|
if (TQPixmap::defaultDepth() > 8)
|
||
15 years ago
|
*_theme = defaultThemeName();
|
||
|
else
|
||
14 years ago
|
*_theme = TQString::tqfromLatin1("locolor");
|
||
15 years ago
|
}*/
|
||
|
return *_theme;
|
||
|
}
|
||
|
|
||
|
// static
|
||
15 years ago
|
TQStringList KIconTheme::list()
|
||
15 years ago
|
{
|
||
|
// Static pointer because of unloading problems wrt DSO's.
|
||
|
if (_theme_list != 0L)
|
||
|
return *_theme_list;
|
||
|
|
||
15 years ago
|
_theme_list = new TQStringList();
|
||
|
TQStringList icnlibs = KGlobal::dirs()->resourceDirs("icon");
|
||
15 years ago
|
icnlibs += (KGlobal::dirs()->resourceDirs("xdgdata-icon"));
|
||
|
icnlibs += "/usr/share/pixmaps";
|
||
|
// These are not in the icon spec, but e.g. GNOME puts some icons there anyway.
|
||
|
icnlibs += KGlobal::dirs()->resourceDirs("xdgdata-pixmap");
|
||
15 years ago
|
TQStringList::ConstIterator it;
|
||
15 years ago
|
for (it=icnlibs.begin(); it!=icnlibs.end(); ++it)
|
||
|
{
|
||
15 years ago
|
TQDir dir(*it);
|
||
15 years ago
|
if (!dir.exists())
|
||
|
continue;
|
||
15 years ago
|
TQStringList lst = dir.entryList(TQDir::Dirs);
|
||
|
TQStringList::ConstIterator it2;
|
||
15 years ago
|
for (it2=lst.begin(); it2!=lst.end(); ++it2)
|
||
|
{
|
||
|
if ((*it2 == ".") || (*it2 == "..") || (*it2).startsWith("default.") )
|
||
|
continue;
|
||
|
if (!KStandardDirs::exists(*it + *it2 + "/index.desktop") && !KStandardDirs::exists(*it + *it2 + "/index.theme"))
|
||
|
continue;
|
||
|
KIconTheme oink(*it2);
|
||
|
if (!oink.isValid()) continue;
|
||
|
|
||
13 years ago
|
if (!_theme_list->contains(*it2))
|
||
15 years ago
|
_theme_list->append(*it2);
|
||
|
}
|
||
|
}
|
||
|
return *_theme_list;
|
||
|
}
|
||
|
|
||
|
// static
|
||
|
void KIconTheme::reconfigure()
|
||
|
{
|
||
|
delete _theme;
|
||
|
_theme=0L;
|
||
|
delete _theme_list;
|
||
|
_theme_list=0L;
|
||
|
}
|
||
|
|
||
|
// static
|
||
15 years ago
|
TQString KIconTheme::defaultThemeName()
|
||
15 years ago
|
{
|
||
14 years ago
|
return TQString::tqfromLatin1("crystalsvg");
|
||
15 years ago
|
}
|
||
|
|
||
|
/*** KIconThemeDir ***/
|
||
|
|
||
15 years ago
|
KIconThemeDir::KIconThemeDir(const TQString& dir, const KConfigBase *config)
|
||
15 years ago
|
{
|
||
|
mbValid = false;
|
||
|
mDir = dir;
|
||
|
mSize = config->readNumEntry("Size");
|
||
|
mMinSize = 1; // just set the variables to something
|
||
|
mMaxSize = 50; // meaningful in case someone calls minSize or maxSize
|
||
|
mType = KIcon::Fixed;
|
||
|
|
||
|
if (mSize == 0)
|
||
|
return;
|
||
|
|
||
15 years ago
|
TQString tmp = config->readEntry("Context");
|
||
15 years ago
|
if (tmp == "Devices")
|
||
|
mContext = KIcon::Device;
|
||
|
else if (tmp == "MimeTypes")
|
||
|
mContext = KIcon::MimeType;
|
||
|
else if (tmp == "FileSystems")
|
||
|
mContext = KIcon::FileSystem;
|
||
|
else if (tmp == "Applications")
|
||
|
mContext = KIcon::Application;
|
||
|
else if (tmp == "Actions")
|
||
|
mContext = KIcon::Action;
|
||
|
else if (tmp == "Animations")
|
||
|
mContext = KIcon::Animation;
|
||
|
else if (tmp == "Categories")
|
||
|
mContext = KIcon::Category;
|
||
|
else if (tmp == "Emblems")
|
||
|
mContext = KIcon::Emblem;
|
||
|
else if (tmp == "Emotes")
|
||
|
mContext = KIcon::Emote;
|
||
|
else if (tmp == "International")
|
||
|
mContext = KIcon::International;
|
||
|
else if (tmp == "Places")
|
||
|
mContext = KIcon::Place;
|
||
14 years ago
|
else if (tmp == "Status")
|
||
|
mContext = KIcon::StatusIcon;
|
||
15 years ago
|
else {
|
||
|
kdDebug(264) << "Invalid Context= line for icon theme: " << mDir << "\n";
|
||
|
return;
|
||
|
}
|
||
|
tmp = config->readEntry("Type");
|
||
|
if (tmp == "Fixed")
|
||
|
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;
|
||
|
}
|
||
|
if (mType == KIcon::Scalable)
|
||
|
{
|
||
|
mMinSize = config->readNumEntry("MinSize", mSize);
|
||
|
mMaxSize = config->readNumEntry("MaxSize", mSize);
|
||
|
} else if (mType == KIcon::Threshold)
|
||
|
mThreshold = config->readNumEntry("Threshold", 2);
|
||
|
mbValid = true;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KIconThemeDir::iconPath(const TQString& name) const
|
||
15 years ago
|
{
|
||
|
if (!mbValid)
|
||
15 years ago
|
return TQString::null;
|
||
|
TQString file = mDir + "/" + name;
|
||
15 years ago
|
|
||
15 years ago
|
if (access(TQFile::encodeName(file), R_OK) == 0)
|
||
15 years ago
|
return file;
|
||
|
|
||
15 years ago
|
return TQString::null;
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQStringList KIconThemeDir::iconList() const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDir dir(mDir);
|
||
15 years ago
|
#ifdef HAVE_LIBART
|
||
15 years ago
|
TQStringList lst = dir.entryList("*.png;*.svg;*.svgz;*.xpm", TQDir::Files);
|
||
15 years ago
|
#else
|
||
15 years ago
|
TQStringList lst = dir.entryList("*.png;*.xpm", TQDir::Files);
|
||
15 years ago
|
#endif
|
||
15 years ago
|
TQStringList result;
|
||
|
TQStringList::ConstIterator it;
|
||
15 years ago
|
for (it=lst.begin(); it!=lst.end(); ++it)
|
||
|
result += mDir + "/" + *it;
|
||
|
return result;
|
||
|
}
|