<commit_before>import QtQuick 2.6
import QtQuick.Controls.Material 2.0

Item {
    id: root
    height: picture.height
    width: height

    property string displayName
    property var peer

    Rectangle {
        id: picture
        visible: root.displayName
        readonly property var colors: [
            Material.Purple,
            Material.DeepPurple,
            Material.Blue,
            Material.LightBlue,
            Material.Cyan,
            Material.Teal,
            Material.LightGreen,
            Material.Lime,
            Material.Amber,
            Material.Orange,
            Material.DeepOrange,
            Material.Brown,
            Material.Grey,
            Material.BlueGrey,
        ]
        function getColor(username) {
            return colors[Qt.md5(username).charCodeAt(0) % colors.length]
        }

        color: {
            if (!peer) {
                return "white"
            }
            if (!peer.isValid()) {
                return "lightgray"
            }
            Material.color(getColor(root.peer.toString()))
        }
        anchors.fill: parent
        border.color: "black"
        border.width: 1

        Text {
            anchors.centerIn: parent
            font.pixelSize: parent.width * 0.8
            text: root.displayName[0]
            font.capitalization: Font.AllUppercase
        }
    }
}
<commit_msg>QmlClient/PeerPicture: Fix warning on empty displayName<commit_after>import QtQuick 2.6
import QtQuick.Controls.Material 2.0

Item {
    id: root
    height: picture.height
    width: height

    property string displayName
    property var peer

    Rectangle {
        id: picture
        visible: root.displayName
        readonly property var colors: [
            Material.Purple,
            Material.DeepPurple,
            Material.Blue,
            Material.LightBlue,
            Material.Cyan,
            Material.Teal,
            Material.LightGreen,
            Material.Lime,
            Material.Amber,
            Material.Orange,
            Material.DeepOrange,
            Material.Brown,
            Material.Grey,
            Material.BlueGrey,
        ]
        function getColor(username) {
            return colors[Qt.md5(username).charCodeAt(0) % colors.length]
        }

        color: {
            if (!peer) {
                return "white"
            }
            if (!peer.isValid()) {
                return "lightgray"
            }
            Material.color(getColor(root.peer.toString()))
        }
        anchors.fill: parent
        border.color: "black"
        border.width: 1

        Text {
            anchors.centerIn: parent
            font.pixelSize: parent.width * 0.8
            text: root.displayName ? root.displayName[0] : ""
            font.capitalization: Font.AllUppercase
        }
    }
}

{'fraction_non_alphanumeric': 0.0840365682137834, 'fraction_numerical': 0.007032348804500703, 'mean_word_length': 1.406937394247039, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1537602', 'n_tokens_mistral': 771, 'n_tokens_neox': 745, 'n_words': 152}