42 #include <private/qiconloader_p.h> 44 #include <private/qapplication_p.h> 45 #include <private/qicon_p.h> 46 #include <private/qguiplatformplugin_p.h> 48 #include <QtGui/QIconEnginePlugin> 49 #include <QtGui/QPixmapCache> 50 #include <QtGui/QIconEngine> 51 #include <QtGui/QStyleOption> 52 #include <QtCore/QList> 53 #include <QtCore/QHash> 54 #include <QtCore/QDir> 55 #include <QtCore/QSettings> 56 #include <QtGui/QPainter> 59 #include <private/qt_cocoa_helpers_mac_p.h> 63 #include <private/qt_x11_p.h> 66 #include <private/qstylehelper_p.h> 78 }
else if (
X11->desktopEnvironment ==
DE_KDE) {
79 return X11->desktopVersion >= 4
90 m_themeKey(1), m_supportsSvg(false), m_initialized(false)
106 #ifndef QT_NO_LIBRARY 112 #endif //QT_NO_LIBRARY 118 return iconLoaderInstance();
167 for (
int i = 0 ; i < iconDirs.
size() ; ++i) {
168 QDir iconDir(iconDirs[i]);
171 if (themeIndex.
exists()) {
177 #ifndef QT_NO_SETTINGS 178 if (themeIndex.
exists()) {
181 while (keyIterator.hasNext()) {
187 if (
int size = indexReader.value(key).toInt()) {
202 dirInfo.
threshold = indexReader.value(directoryKey +
206 dirInfo.
minSize = indexReader.value(directoryKey +
210 dirInfo.
maxSize = indexReader.value(directoryKey +
230 #endif //QT_NO_SETTINGS 243 visited << themeName;
245 QIconTheme theme = themeList.value(themeName);
251 themeList.insert(themeName, theme);
261 for (
int i = 0; i < subDirs.
size() ; ++i) {
264 QDir currentDir(contentDir + subdir);
265 if (currentDir.
exists(iconName + pngext)) {
267 iconEntry->
dir = dirInfo;
272 }
else if (m_supportsSvg &&
273 currentDir.
exists(iconName + svgext)) {
275 iconEntry->
dir = dirInfo;
277 entries.
append(iconEntry);
284 for (
int i = 0 ; i < parents.
size() ; ++i) {
289 entries = findIconHelper(parentTheme, iconName, visited);
302 return findIconHelper(themeName(), name, visited);
313 : m_iconName(iconName), m_key(0)
356 iconLoaderInstance()->ensureInitialized();
358 if (!(iconLoaderInstance()->themeKey() ==
m_key)) {
365 m_key = iconLoaderInstance()->themeKey();
373 #if defined(Q_WS_MAC) 386 return dir.
size == iconsize;
413 else if (iconsize > dir.
maxSize)
451 if (distance < minimalSize) {
453 closestMatch = entry;
477 return QSize(result, result);
489 if (basePixmap.isNull())
490 basePixmap.load(filename);
506 cachedPixmap =
qApp->style()->generatedIconPixmap(mode, basePixmap, &opt);
514 if (svgIcon.isNull())
515 svgIcon =
QIcon(filename);
518 return svgIcon.
pixmap(size, mode, state);
528 return entry->
pixmap(size, mode, state);
The QDir class provides access to directory structures and their contents.
The QPainter class performs low-level painting on widgets and other paint devices.
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
Uses the given painter to paint the icon with the required mode and state into the rectangle rect...
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
void clear()
Removes all items from the hash.
The QSettings class provides persistent platform-independent application settings.
virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the actual size of the icon the engine provides for the requested size, mode and state...
CGFloat qt_mac_get_scalefactor()
void setThemeName(const QString &themeName)
State
This enum describes the state for which a pixmap is intended to be used.
void setThemeSearchPath(const QStringList &searchPaths)
QIconLoaderEngine(const QString &iconName=QString())
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
QIconEngineV2 * clone() const
Returns a clone of this icon engine.
The QString class provides a Unicode character string.
bool read(QDataStream &in)
Reads icon engine contents from the QDataStream in.
QList< QIconDirInfo > keyList()
Q_DECL_CONSTEXPR T qAbs(const T &t)
static QStringList themeSearchPaths()
Returns the search paths for icon themes.
bool exists() const
Returns true if the directory exists; otherwise returns false.
static QPixmap * find(const QString &key)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
int width() const
Returns the width.
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
This struct represents arguments to virtual_hook() function when id parameter is QIconEngineV2::Avail...
static bool isEmpty(const char *str)
QList< QIconDirInfo > m_keyList
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
The QStyleOption class stores the parameters used by QStyle functions.
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
int size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
void prepend(const T &t)
Inserts value at the beginning of the list.
QSize size() const
Returns the size of the rectangle.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
virtual void virtual_hook(int id, void *data)
Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without br...
const T & at(int i) const
Returns the item at index position i in the list.
static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize)
The QStringList class provides a list of strings.
QList< QSize > sizes
image sizes that are available with specified mode and
static QString fallbackTheme()
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
T value(int i) const
Returns the value at index position i in the list.
void clear()
Removes all items from the list.
The QIconEngineV2 class provides an abstract base class for QIcon renderers.
bool write(QDataStream &out) const
Writes the contents of this engine to the QDataStream out.
QStringList themeSearchPaths() const
static QIconLoader * instance()
void virtual_hook(int id, void *data)
Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without br...
QPalette palette
the palette that should be used when painting the control
QThemeIconEntries m_entries
static const MacSpecialKey entries[NumEntries]
QString key() const
Returns a key that identifies this icon engine.
The QFile class provides an interface for reading from and writing to files.
QList< QIconLoaderEngineEntry * > QThemeIconEntries
QString themeName() const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int size() const
Returns the number of items in the list.
int height() const
Returns the height.
static int directorySizeDistance(const QIconDirInfo &dir, int iconsize)
The QRect class defines a rectangle in the plane using integer precision.
static int closestMatch(QRgb pixel, const QVector< QRgb > &clut)
QListIterator< QString > QStringListIterator
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the icon as a pixmap with the required size, mode, and state.
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
The QPixmap class is an off-screen image representation that can be used as a paint device...
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
T takeLast()
Removes the last item in the list and returns it.
QThemeIconEntries loadIcon(const QString &iconName) const
QHash< QString, QIconTheme > themeList
The QSize class defines the size of a two-dimensional object using integer point precision.
The QDataStream class provides serialization of binary data to a QIODevice.
QString path() const
Returns the path.
QIconEngineFactoryInterfaceV2_iid
QString filePath(const QString &fileName) const
Returns the path name of a file in the directory.
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
QIconLoaderEngineEntry * entryForSize(const QSize &size)
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the actual size of the icon the engine provides for the requested size, mode and state...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)=0
void setFileName(const QString &name)
Sets the name of the file.
QThemeIconEntries findIconHelper(const QString &themeName, const QString &iconName, QStringList &visited) const
The QIcon class provides scalable icons in different modes and states.