10 #include <QReadLocker>
11 #include <QWriteLocker>
18 CPixmap::CPixmap(
const QPixmap &pixmap) : m_pixmap(pixmap), m_hasCachedPixmap(true) { this->fillByteArray(); }
24 if (
this == &other) {
return *
this; }
26 QReadLocker readLock(&other.m_lock);
27 auto tuple = std::make_tuple(other.m_pixmap, other.m_hasCachedPixmap, other.m_array);
30 QWriteLocker writeLock(&this->m_lock);
31 std::tie(m_pixmap, m_hasCachedPixmap, m_array) = tuple;
37 QWriteLocker lock(&this->m_lock);
38 if (this->m_hasCachedPixmap) {
return this->m_pixmap; }
42 this->m_hasCachedPixmap =
true;
43 if (this->m_array.isEmpty()) {
return this->m_pixmap; }
44 bool s = this->m_pixmap.loadFromData(this->m_array,
"PNG");
47 return this->m_pixmap;
52 QReadLocker lock(&this->m_lock);
53 if (this->m_hasCachedPixmap) {
return false; }
54 return (this->m_array.isEmpty() || this->m_array.isNull());
57 CPixmap::operator QPixmap()
const {
return pixmap(); }
67 void CPixmap::fillByteArray()
70 QBuffer buffer(&this->m_array);
71 buffer.open(QIODevice::WriteOnly);
72 this->m_pixmap.save(&buffer,
"PNG");
Pixmap which can be transferred via DBus.
bool isNull() const
With Pixmap?
const QPixmap & pixmap() const
Corresponding pixmap.
CPixmap()=default
Default constructor.
QString convertToQString(bool i18n=false) const
Cast as QString.
CPixmap & operator=(const CPixmap &other)
Copy assignment (because of mutex)
QPixmap toPixmap() const
Corresponding pixmap.
Mix of the most commonly used mixin classes.
Free functions in swift::misc.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.