Add ImageItem.
This commit is contained in:
@@ -142,12 +142,24 @@ Item {
|
||||
|
||||
spacing: 12
|
||||
|
||||
ImageStatus {
|
||||
// ImageStatus {
|
||||
// Layout.preferredWidth: height
|
||||
// Layout.fillHeight: true
|
||||
|
||||
// source: avatar ? "image://mxc/" + avatar : ""
|
||||
// displayText: name
|
||||
// }
|
||||
|
||||
ImageItem {
|
||||
id: imageItem
|
||||
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
source: avatar ? "image://mxc/" + avatar : ""
|
||||
displayText: name
|
||||
hint: name || "No Name"
|
||||
defaultColor: stringToColor(name || "No Name")
|
||||
|
||||
image: avatar
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
@@ -212,4 +224,17 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stringToColor(str) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
var colour = '#';
|
||||
for (var j = 0; j < 3; j++) {
|
||||
var value = (hash >> (j * 8)) & 0xFF;
|
||||
colour += ('00' + value.toString(16)).substr(-2);
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user