Update libqmatrixclient && put string to color inline.
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user