Update libqmatrixclient && put string to color inline.
This commit is contained in:
Submodule include/libqmatrixclient updated: 7c7ce3d468...a81383549d
@@ -6,6 +6,16 @@
|
|||||||
|
|
||||||
ImageItem::ImageItem(QQuickItem *parent) : QQuickPaintedItem(parent) {}
|
ImageItem::ImageItem(QQuickItem *parent) : QQuickPaintedItem(parent) {}
|
||||||
|
|
||||||
|
inline QString stringtoColor(QString string) {
|
||||||
|
int hash = 0;
|
||||||
|
for (int i = 0; i < string.length(); i++)
|
||||||
|
hash = string.at(i).unicode() + ((hash << 5) - hash);
|
||||||
|
QString colour = "#";
|
||||||
|
for (int j = 0; j < 3; j++)
|
||||||
|
colour += ("00" + QString::number((hash >> (j * 8)) & 0xFF, 16)).right(2);
|
||||||
|
return colour;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageItem::paint(QPainter *painter) {
|
void ImageItem::paint(QPainter *painter) {
|
||||||
QRectF bounding_rect = boundingRect();
|
QRectF bounding_rect = boundingRect();
|
||||||
|
|
||||||
@@ -69,9 +79,8 @@ void ImageItem::setPaintable(Paintable *paintable) {
|
|||||||
if (!paintable) return;
|
if (!paintable) return;
|
||||||
disconnect(m_paintable);
|
disconnect(m_paintable);
|
||||||
m_paintable = paintable;
|
m_paintable = paintable;
|
||||||
connect(m_paintable, &Paintable::paintableChanged, this, [=] {
|
connect(m_paintable, &Paintable::paintableChanged, this,
|
||||||
this->update();
|
[=] { this->update(); });
|
||||||
});
|
|
||||||
emit paintableChanged();
|
emit paintableChanged();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -99,13 +108,3 @@ void ImageItem::setRound(bool value) {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ImageItem::stringtoColor(QString string) {
|
|
||||||
int hash = 0;
|
|
||||||
for (int i = 0; i < string.length(); i++)
|
|
||||||
hash = string.at(i).unicode() + ((hash << 5) - hash);
|
|
||||||
QString colour = "#";
|
|
||||||
for (int j = 0; j < 3; j++)
|
|
||||||
colour += ("00" + QString::number((hash >> (j * 8)) & 0xFF, 16)).right(2);
|
|
||||||
return colour;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class ImageItem : public QQuickPaintedItem {
|
|||||||
QString m_color;
|
QString m_color;
|
||||||
bool m_round = true;
|
bool m_round = true;
|
||||||
|
|
||||||
QString stringtoColor(QString string);
|
|
||||||
void paintHint(QPainter* painter, QRectF bounding_rect);
|
void paintHint(QPainter* painter, QRectF bounding_rect);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user