From f2935bff1e1817ff7dc27de6ef428ebe405599de Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 22 May 2017 15:56:26 -0400 Subject: Commit my WIP on the new icon cache/loading systems for Lumina. --- src-qt5/core/libLumina/LIconCache.h | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src-qt5/core/libLumina/LIconCache.h (limited to 'src-qt5/core/libLumina/LIconCache.h') diff --git a/src-qt5/core/libLumina/LIconCache.h b/src-qt5/core/libLumina/LIconCache.h new file mode 100644 index 00000000..08726399 --- /dev/null +++ b/src-qt5/core/libLumina/LIconCache.h @@ -0,0 +1,56 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is a simple class for loading/serving icon files +// from the icon theme or local filesystem +//=========================================== +#include +#include +#include +#include +#include +#include +#include + +//Data structure for saving the icon/information internally +struct icon_data{ + QString fullpath; + QDateTime lastread; + QList pendingLabels; + QList pendingButtons; + QIcon icon; + QIcon thumbnail; +}; + +class LIconCache : public QObject{ + Q_OBJECT +public: + LIconCache(QObject *parent = 0); + ~LIconCache(); + //Icon Checks + bool exists(QString icon); + bool isLoaded(QString icon); + QString findFile(QString icon); //find the full path of a given file/name (searching the current Icon theme) + + void loadIcon(QAbstractButton *button, QString icon, bool noThumb = false); + void loadIcon(QLabel *label, QString icon, bool noThumb = false); + +private: + QHash HASH; + QFileSystemWatcher *WATCHER; + + icon_data createData(QString icon); + QStringList getChildIconDirs(QString path); //recursive function to find directories with icons in them + + static void ReadFile(LIconCache *obj, QString id, QString path); + +private slots: + void IconLoaded(QString id, QDateTime sync, QByteArray *data); + +signals: + void InternalIconLoaded(QString, QDateTime, QByteArray*); //INTERNAL SIGNAL - DO NOT USE in other classes/objects + void IconAvailable(QString); //way for classes to listen/reload icons as they change +}; -- cgit