kicontheme.h
00001 /* vi: ts=8 sts=4 sw=4 00002 * 00003 * This file is part of the KDE project, module kdecore. 00004 * Copyright (C) 2000 Geert Jansen <jansen@kde.org> 00005 * Antonio Larrosa <larrosa@kde.org> 00006 * 00007 * This is free software; it comes under the GNU Library General 00008 * Public License, version 2. See the file "COPYING.LIB" for the 00009 * exact licensing terms. 00010 * 00011 */ 00012 00013 #ifndef __KIconTheme_h_Included__ 00014 #define __KIconTheme_h_Included__ 00015 00016 #include <qstring.h> 00017 #include <qstringlist.h> 00018 #include <qptrlist.h> 00019 #include "kdelibs_export.h" 00020 00021 class KConfig; 00022 class KIconThemeDir; 00023 00024 class KIconThemePrivate; 00025 00026 class KIconPrivate; 00027 00035 class KDECORE_EXPORT KIcon 00036 { 00037 public: 00038 KIcon() { size = 0; } 00039 00043 bool isValid() const { return size != 0; } 00044 00048 enum Context { 00049 Any, 00050 Action, 00051 Application, 00052 Device, 00053 FileSystem, 00054 MimeType, 00055 Animation, 00056 Category, 00057 Emblem, 00058 Emote, 00059 International, 00060 Place, 00061 StatusIcon 00062 }; 00063 00067 enum Type { 00068 Fixed, 00069 Scalable, 00070 Threshold 00071 }; 00072 00076 enum MatchType { 00077 MatchExact, 00078 MatchBest 00079 00080 }; 00081 00082 // if you add a group here, make sure to change the config reading in 00083 // KIconLoader too 00087 enum Group { 00089 NoGroup=-1, 00091 Desktop=0, 00093 FirstGroup=0, 00095 Toolbar, 00097 MainToolbar, 00099 Small, 00101 Panel, 00103 LastGroup, 00105 User 00106 }; 00107 00111 enum StdSizes { 00113 SizeSmall=16, 00115 SizeSmallMedium=22, 00117 SizeMedium=32, 00119 SizeLarge=48, 00121 SizeHuge=64, 00123 SizeEnormous=128 00124 }; 00125 00129 enum States { DefaultState, 00130 ActiveState, 00131 DisabledState, 00132 LastState 00133 }; 00134 00140 enum Overlays { 00141 LockOverlay=0x100, 00142 ZipOverlay=0x200, 00143 LinkOverlay=0x400, 00144 HiddenOverlay=0x800, 00145 ShareOverlay=0x1000, 00146 OverlayMask = ~0xff 00147 }; 00148 00152 int size; 00153 00157 Context context; 00158 00162 Type type; 00163 00167 int threshold; 00168 00172 QString path; 00173 00174 private: 00175 KIconPrivate *d; 00176 }; 00177 00178 inline KIcon::Group& operator++(KIcon::Group& group) { group = static_cast<KIcon::Group>(group+1); return group; } 00179 inline KIcon::Group operator++(KIcon::Group& group,int) { KIcon::Group ret = group; ++group; return ret; } 00180 00186 class KDECORE_EXPORT KIconTheme 00187 { 00188 public: 00195 KIconTheme(const QString& name, const QString& appName=QString::null); 00196 ~KIconTheme(); 00197 00202 QString name() const { return mName; } 00203 00209 QString description() const { return mDesc; } 00210 00216 QString example() const; 00217 00222 QString screenshot() const; 00223 00228 QString linkOverlay() const; 00229 00234 QString zipOverlay() const; 00235 00240 QString lockOverlay() const; 00241 00247 QString shareOverlay () const; 00248 00253 QString dir() const { return mDir; } 00254 00259 QStringList inherits() const { return mInherits; } 00260 00265 bool isValid() const; 00266 00272 bool isHidden() const; 00273 00279 int depth() const { return mDepth; } 00280 00286 int defaultSize(KIcon::Group group) const; 00287 00293 QValueList<int> querySizes(KIcon::Group group) const; 00294 00301 QStringList queryIcons(int size, KIcon::Context context = KIcon::Any) const; 00302 00309 QStringList queryIconsByContext(int size, KIcon::Context context = KIcon::Any) const; 00310 00311 00322 KIcon iconPath(const QString& name, int size, KIcon::MatchType match) const; 00323 00328 bool hasContext( KIcon::Context context ) const; 00329 00334 static QStringList list(); 00335 00340 static QString current(); 00341 00345 static void reconfigure(); 00346 00352 static QString defaultThemeName(); 00353 00354 private: 00355 int mDefSize[8]; 00356 QValueList<int> mSizes[8]; 00357 00358 int mDepth; 00359 QString mDir, mName, mDesc; 00360 QStringList mInherits; 00361 QPtrList<KIconThemeDir> mDirs; 00362 KIconThemePrivate *d; 00363 00364 static QString *_theme; 00365 static QStringList *_theme_list; 00366 }; 00367 00368 #endif