File indexing completed on 2024-04-21 04:05:21

0001 /*
0002     This file is part of the KDE games library
0003     SPDX-FileCopyrightText: 2008 Andreas Pakulat <apaku@gmx.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef CARDCACHE_P_H
0009 #define CARDCACHE_P_H
0010 
0011 #include <KImageCache>
0012 
0013 #include <QThread>
0014 #include <QString>
0015 #include <QStringList>
0016 #include <QSize>
0017 #include "cardcache.h"
0018 
0019 class QMutex;
0020 class QSvgRenderer;
0021 class LoadThread;
0022 
0023 class KCardCachePrivate : public QObject
0024 {
0025     Q_OBJECT
0026 public:
0027     KImageCache *cache;
0028     QMutex *cacheMutex;
0029     QMutex *rendererMutex;
0030     LoadThread *loadThread;
0031     QSize size;
0032     QString deckName;
0033     QSvgRenderer *svgRenderer;
0034 
0035     QSvgRenderer *renderer();
0036     QPixmap renderSvg(const QString &element);
0037     void ensureNonNullPixmap(QPixmap &pix);
0038 public Q_SLOTS:
0039     void submitRendering(const QString &key, const QPixmap &pixmap);
0040 };
0041 
0042 class LoadThread : public QThread
0043 {
0044     Q_OBJECT
0045 Q_SIGNALS:
0046     void renderingDone(const QString &key, const QPixmap &pixmap);
0047 public:
0048     explicit LoadThread(KCardCachePrivate *d);
0049     ~LoadThread() override;
0050     void setSize(const QSize &s);
0051     void setDeckName(const QString &frontTheme);
0052     void setElementsToLoad(const QStringList &elements);
0053     void run() override;
0054     void kill();
0055 private:
0056     KCardCachePrivate *d;
0057     QString frontTheme;
0058     QSize size;
0059     bool doKill;
0060     QMutex *killMutex;
0061     QStringList elementsToRender;
0062 };
0063 
0064 #endif