added emote loading

This commit is contained in:
fourtf
2017-01-13 18:59:11 +01:00
parent 0fbc40a52a
commit 4dbe2b0254
18 changed files with 402 additions and 181 deletions
+13 -13
View File
@@ -1,7 +1,7 @@
#ifndef LAZYLOADEDIMAGE_H
#define LAZYLOADEDIMAGE_H
#include <QImage>
#include <QPixmap>
#include <QString>
class LazyLoadedImage
@@ -10,19 +10,19 @@ public:
LazyLoadedImage(const QString &url, qreal scale = 1,
const QString &name = "", const QString &tooltip = "",
const QMargins &margin = QMargins(), bool isHat = false);
LazyLoadedImage(QImage *image, qreal scale = 1, const QString &name = "",
LazyLoadedImage(QPixmap *pixmap, qreal scale = 1, const QString &name = "",
const QString &tooltip = "",
const QMargins &margin = QMargins(), bool isHat = false);
const QImage *
image()
const QPixmap *
pixmap()
{
if (!m_isLoading) {
m_isLoading = true;
loadImage();
}
return m_image;
return m_pixmap;
}
qreal
@@ -67,27 +67,26 @@ public:
return m_ishat;
}
const long
int
width() const
{
if (m_image == NULL) {
if (m_pixmap == NULL) {
return 16;
}
return m_image->width();
return m_pixmap->width();
}
const long
int
height() const
{
if (m_image == NULL) {
if (m_pixmap == NULL) {
return 16;
}
return m_image->height();
return m_pixmap->height();
}
private:
QImage *m_image;
qreal m_scale;
QPixmap *m_pixmap;
QString m_url;
QString m_name;
@@ -95,6 +94,7 @@ private:
bool m_animated;
QMargins m_margin;
bool m_ishat;
qreal m_scale;
bool m_isLoading;