blob: 97300ee3c938c4ab9bba4a7af95b7500b394977f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <QtDebug>
#include <QCryptographicHash>
#include "skin/pixmapsource.h"
#include "util/assert.h"
PixmapSource::PixmapSource()
: m_eType(SVG) {
}
PixmapSource::PixmapSource(const QString& filepath)
: m_path(filepath) {
if (m_path.endsWith(".svg", Qt::CaseInsensitive)) {
m_eType = SVG;
} else {
m_eType = BITMAP;
}
}
const QByteArray& PixmapSource::getSvgSourceData() const {
return m_svgSourceData;
}
const QString& PixmapSource::getPath() const {
return m_path;
}
bool PixmapSource::isEmpty() const {
return m_path.isEmpty() && m_svgSourceData.isEmpty() ;
}
bool PixmapSource::isSVG() const {
return m_eType == SVG;
}
bool PixmapSource::isBitmap() const {
return m_eType == BITMAP;
}
void PixmapSource::setSVG(const QByteArray& content) {
m_svgSourceData = content;
m_eType = SVG;
}
QString PixmapSource::getId() const {
if (m_svgSourceData.isEmpty()) {
DEBUG_ASSERT(!m_path.isEmpty());
return m_path;
}
return QCryptographicHash::hash(m_svgSourceData, QCryptographicHash::Sha1).toHex();
}
|