2016-12-20 10:31:38 +00:00
|
|
|
#ifndef FGQCANVASFONTCACHE_H
|
|
|
|
#define FGQCANVASFONTCACHE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QFont>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QHash>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
|
|
|
|
class QNetworkAccessManager;
|
|
|
|
|
|
|
|
class FGQCanvasFontCache : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit FGQCanvasFontCache(QNetworkAccessManager* nam, QObject *parent = 0);
|
|
|
|
|
|
|
|
QFont fontForName(QByteArray name, bool* ok = nullptr);
|
|
|
|
|
|
|
|
static void initialise(QNetworkAccessManager* nam);
|
|
|
|
static FGQCanvasFontCache* instance();
|
|
|
|
|
2016-12-21 10:25:58 +00:00
|
|
|
void setHost(QString hostName, int portNumber);
|
2016-12-20 10:31:38 +00:00
|
|
|
signals:
|
|
|
|
void fontLoaded(QByteArray name);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onFontDownloadFinished();
|
|
|
|
void onFontDownloadError(QNetworkReply::NetworkError);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QNetworkAccessManager* m_downloader;
|
|
|
|
QHash<QByteArray, QFont> m_cache;
|
2016-12-21 10:25:58 +00:00
|
|
|
QString m_hostName;
|
|
|
|
int m_port;
|
2016-12-20 10:31:38 +00:00
|
|
|
|
|
|
|
void lookupFile(QByteArray name);
|
|
|
|
|
|
|
|
QList<QNetworkReply*> m_transfers;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FGQCANVASFONTCACHE_H
|