More user color.

This commit is contained in:
Black Hat
2019-09-30 01:09:38 -07:00
parent 0461c46a1a
commit 4d46390186
3 changed files with 22 additions and 27 deletions

View File

@@ -7,6 +7,7 @@ import Spectral.Setting 0.1
Item { Item {
property string hint: "H" property string hint: "H"
property string source: "" property string source: ""
property color color: MPalette.accent
readonly property url realSource: source ? "image://mxc/" + source : "" readonly property url realSource: source ? "image://mxc/" + source : ""
id: root id: root
@@ -38,7 +39,7 @@ Item {
visible: !realSource || image.status != Image.Ready visible: !realSource || image.status != Image.Ready
radius: height / 2 radius: height / 2
color: MPalette.accent color: root.color
antialiasing: true antialiasing: true
Label { Label {
@@ -47,22 +48,9 @@ Item {
color: "white" color: "white"
text: hint[0].toUpperCase() text: hint[0].toUpperCase()
font.pixelSize: root.width / 2 font.pixelSize: root.width / 2
font.weight: Font.Light font.weight: Font.Medium
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
} }
// 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;
// }
} }

View File

@@ -29,6 +29,7 @@ Control {
hint: author.displayName hint: author.displayName
source: author.avatarMediaId source: author.avatarMediaId
color: Qt.darker(author.color, 1.1)
} }
Label { Label {

View File

@@ -61,7 +61,7 @@ Control {
background: Rectangle { background: Rectangle {
radius: height / 2 radius: height / 2
color: replyUser ? replyUser.color : MPalette.accent color: replyUser ? Qt.darker(replyUser.color, 1.1) : MPalette.accent
} }
contentItem: RowLayout { contentItem: RowLayout {
@@ -135,22 +135,22 @@ Control {
readonly property bool highlighted: autoCompleteListView.currentIndex === index readonly property bool highlighted: autoCompleteListView.currentIndex === index
height: 36 height: 36
padding: 8 padding: 6
background: Rectangle { background: Rectangle {
visible: !isEmoji visible: !isEmoji
color: highlighted ? Material.accent : "transparent" color: highlighted ? border.color : "transparent"
border.color: Material.accent border.color: isEmoji ? Material.accent : modelData.color
border.width: 2 border.width: 2
radius: height / 2 radius: height / 2
} }
contentItem: Row { contentItem: RowLayout {
spacing: 4 spacing: 6
Text { Text {
width: 20 width: 24
height: 20 height: 24
visible: isEmoji visible: isEmoji
text: autoCompleteText text: autoCompleteText
font.pixelSize: 24 font.pixelSize: 24
@@ -158,18 +158,24 @@ Control {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
Avatar { Avatar {
width: 20 Layout.preferredWidth: 24
height: 20 Layout.preferredHeight: 24
visible: !isEmoji visible: !isEmoji
source: modelData.avatarMediaId || null source: modelData.avatarMediaId || null
color: modelData.color ? Qt.darker(modelData.color, 1.1) : MPalette.accent
} }
Label { Label {
height: parent.height Layout.fillHeight: true
visible: !isEmoji visible: !isEmoji
text: autoCompleteText text: autoCompleteText
color: highlighted ? "white" : Material.accent color: highlighted ? "white" : MPalette.foreground
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
rightPadding: 8
} }
} }