Update libqmatrixclient && put string to color inline.
This commit is contained in:
parent
5a46810016
commit
b7dc378c65
|
@ -1 +1 @@
|
|||
Subproject commit 7c7ce3d468af242364efb53e77ed12047b6a5382
|
||||
Subproject commit a81383549df4db8a487a847dca41900f3ab38c27
|
|
@ -6,6 +6,16 @@
|
|||
|
||||
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) {
|
||||
QRectF bounding_rect = boundingRect();
|
||||
|
||||
|
@ -69,9 +79,8 @@ void ImageItem::setPaintable(Paintable *paintable) {
|
|||
if (!paintable) return;
|
||||
disconnect(m_paintable);
|
||||
m_paintable = paintable;
|
||||
connect(m_paintable, &Paintable::paintableChanged, this, [=] {
|
||||
this->update();
|
||||
});
|
||||
connect(m_paintable, &Paintable::paintableChanged, this,
|
||||
[=] { this->update(); });
|
||||
emit paintableChanged();
|
||||
update();
|
||||
}
|
||||
|
@ -99,13 +108,3 @@ void ImageItem::setRound(bool value) {
|
|||
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;
|
||||
bool m_round = true;
|
||||
|
||||
QString stringtoColor(QString string);
|
||||
void paintHint(QPainter* painter, QRectF bounding_rect);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue