More changes in MessageDelegate.

This commit is contained in:
Black Hat
2019-05-17 15:01:01 +08:00
parent cab82d7b8a
commit b7d8f70a5f
9 changed files with 168 additions and 103 deletions

View File

@@ -2,6 +2,8 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.0
import Spectral.Setting 0.1
Item {
property string hint: "H"
property string source: ""
@@ -35,7 +37,7 @@ Item {
visible: !realSource || image.status != Image.Ready
radius: height / 2
color: stringToColor(hint)
color: MPalette.accent
antialiasing: true
Label {
@@ -50,16 +52,16 @@ 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;
}
// 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;
// }
}