2015-12-10 05:06:13 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
2019-12-29 23:21:34 +00:00
|
|
|
** Copyright (C) 2016-2020 Ivailo Monev
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
2019-06-03 13:38:02 +00:00
|
|
|
** This file is part of the QtGui module of the Katie Toolkit.
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2019-12-29 23:21:34 +00:00
|
|
|
**
|
2015-12-10 05:06:13 +02:00
|
|
|
** GNU Lesser General Public License Usage
|
2019-12-29 23:21:34 +00:00
|
|
|
** This file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QDESKTOPICON_P_H
|
|
|
|
#define QDESKTOPICON_P_H
|
|
|
|
|
|
|
|
#ifndef QT_NO_ICON
|
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
2019-06-03 13:38:02 +00:00
|
|
|
// This file is not part of the Katie API. It exists purely as an
|
2015-12-10 05:06:13 +02:00
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
//
|
|
|
|
// We mean it.
|
|
|
|
//
|
|
|
|
|
2019-05-30 00:42:33 +00:00
|
|
|
#include <QtCore/QHash>
|
2015-12-10 05:06:13 +02:00
|
|
|
#include <QtGui/QIcon>
|
|
|
|
#include <QtGui/QIconEngine>
|
|
|
|
#include <QtGui/QPixmapCache>
|
2019-07-16 11:25:23 +00:00
|
|
|
#include "qicon_p.h"
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
class QIconLoader;
|
|
|
|
|
|
|
|
struct QIconDirInfo
|
|
|
|
{
|
|
|
|
enum Type { Fixed, Scalable, Threshold };
|
|
|
|
QIconDirInfo(const QString &_path = QString()) :
|
|
|
|
path(_path),
|
|
|
|
size(0),
|
|
|
|
maxSize(0),
|
|
|
|
minSize(0),
|
|
|
|
threshold(0),
|
|
|
|
type(Threshold) {}
|
|
|
|
QString path;
|
|
|
|
short size;
|
|
|
|
short maxSize;
|
|
|
|
short minSize;
|
|
|
|
short threshold;
|
2019-05-31 19:09:50 +00:00
|
|
|
Type type;
|
2015-12-10 05:06:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class QIconLoaderEngineEntry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~QIconLoaderEngineEntry() {}
|
|
|
|
virtual QPixmap pixmap(const QSize &size,
|
|
|
|
QIcon::Mode mode,
|
|
|
|
QIcon::State state) = 0;
|
|
|
|
QString filename;
|
|
|
|
QIconDirInfo dir;
|
|
|
|
static int count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScalableEntry : public QIconLoaderEngineEntry
|
|
|
|
{
|
|
|
|
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
|
|
|
QIcon svgIcon;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PixmapEntry : public QIconLoaderEngineEntry
|
|
|
|
{
|
|
|
|
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
|
|
|
QPixmap basePixmap;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList<QIconLoaderEngineEntry*> QThemeIconEntries;
|
|
|
|
|
2016-06-25 14:33:40 +00:00
|
|
|
class QIconLoaderEngine : public QIconEngine
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
QIconLoaderEngine(const QString& iconName = QString());
|
|
|
|
~QIconLoaderEngine();
|
|
|
|
|
|
|
|
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
|
|
|
|
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
|
|
|
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
2020-02-07 00:37:31 +00:00
|
|
|
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) const;
|
|
|
|
QString iconName() const;
|
2016-06-25 14:33:40 +00:00
|
|
|
QIconEngine *clone() const;
|
2015-12-10 05:06:13 +02:00
|
|
|
bool read(QDataStream &in);
|
|
|
|
bool write(QDataStream &out) const;
|
2020-02-06 22:20:42 +00:00
|
|
|
QString key() const;
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void ensureLoaded();
|
|
|
|
QIconLoaderEngineEntry *entryForSize(const QSize &size);
|
|
|
|
QIconLoaderEngine(const QIconLoaderEngine &other);
|
|
|
|
QThemeIconEntries m_entries;
|
|
|
|
QString m_iconName;
|
|
|
|
uint m_key;
|
|
|
|
|
|
|
|
friend class QIconLoader;
|
|
|
|
};
|
|
|
|
|
|
|
|
class QIconTheme
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QIconTheme(const QString &name);
|
|
|
|
QIconTheme() : m_valid(false) {}
|
|
|
|
QStringList parents() { return m_parents; }
|
|
|
|
QList <QIconDirInfo> keyList() { return m_keyList; }
|
|
|
|
QString contentDir() { return m_contentDir; }
|
|
|
|
bool isValid() { return m_valid; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_contentDir;
|
|
|
|
QList <QIconDirInfo> m_keyList;
|
|
|
|
QStringList m_parents;
|
|
|
|
bool m_valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
class QIconLoader : public QObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QIconLoader();
|
|
|
|
QThemeIconEntries loadIcon(const QString &iconName) const;
|
|
|
|
uint themeKey() const { return m_themeKey; }
|
|
|
|
|
|
|
|
QString themeName() const { return m_userTheme.isEmpty() ? m_systemTheme : m_userTheme; }
|
|
|
|
void setThemeName(const QString &themeName);
|
2019-07-17 17:45:44 +00:00
|
|
|
QIconTheme theme() const { return themeList.value(themeName()); }
|
2015-12-10 05:06:13 +02:00
|
|
|
void setThemeSearchPath(const QStringList &searchPaths);
|
|
|
|
QStringList themeSearchPaths() const;
|
|
|
|
QIconDirInfo dirInfo(int dirindex);
|
|
|
|
static QIconLoader *instance();
|
|
|
|
void updateSystemTheme();
|
|
|
|
void invalidateKey() { m_themeKey++; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
QThemeIconEntries findIconHelper(const QString &themeName,
|
|
|
|
const QString &iconName,
|
|
|
|
QStringList &visited) const;
|
|
|
|
uint m_themeKey;
|
|
|
|
bool m_supportsSvg;
|
|
|
|
|
2019-05-31 19:09:50 +00:00
|
|
|
QString m_userTheme;
|
|
|
|
QString m_systemTheme;
|
2015-12-10 05:06:13 +02:00
|
|
|
mutable QStringList m_iconDirs;
|
|
|
|
mutable QHash <QString, QIconTheme> themeList;
|
|
|
|
};
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
#endif // QDESKTOPICON_P_H
|
|
|
|
|
|
|
|
#endif //QT_NO_ICON
|