diff --git a/sandbox/controls/ListItems.qml b/sandbox/controls/ListItems.qml index 0de9e62e..0a0516ba 100644 --- a/sandbox/controls/ListItems.qml +++ b/sandbox/controls/ListItems.qml @@ -393,7 +393,6 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I ListElement {colorId: 28; segmentLength: 3} } ringSettings.distinctiveColors: Theme.palette.identiconRingColors - ringSettings.totalRingUnits: 25 } StatusMemberListItem { diff --git a/sandbox/demoapp/StatusAppCommunityView.qml b/sandbox/demoapp/StatusAppCommunityView.qml index 7991b4ec..d4f537cf 100644 --- a/sandbox/demoapp/StatusAppCommunityView.qml +++ b/sandbox/demoapp/StatusAppCommunityView.qml @@ -268,7 +268,6 @@ StatusAppThreePanelLayout { isOnline: model.isOnline ringSettings.ringSpecModel: model.ringSpecModel ringSettings.distinctiveColors: Theme.palette.identiconRingColors - ringSettings.totalRingUnits: model.totalRingUnits } } } diff --git a/sandbox/demoapp/data/Models.qml b/sandbox/demoapp/data/Models.qml index a4506e34..63828103 100644 --- a/sandbox/demoapp/data/Models.qml +++ b/sandbox/demoapp/data/Models.qml @@ -903,7 +903,6 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I source: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAlklEQVR4nOzW0QmDQBAG4SSkl7SUQlJGCrElq9F3QdjjVhh/5nv3cFhY9vUIYQiNITSG0BhCExPynn1gWf9bx498P7/ nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC" isIdenticon: true - totalRingUnits: 25 ringSpecModel: [ ListElement {colorId: 13; segmentLength: 5}, ListElement {colorId: 31; segmentLength: 5}, ListElement {colorId: 10; segmentLength: 1}, @@ -932,7 +931,6 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I source: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAiElEQVR4nOzXUQpAQBRGYWQvLNAyLJDV8C5qpiGnv/M9al5Ot27X0IUwhMYQGkNoDKGJCRlLH67bftx9X+ap/+P9VcxEDK ExhKZ4a9Uq3TZviZmIITSG0DRvlqcbqVbrlouZiCE0htD4h0hjCI0hNN5aNIbQGKKPxEzEEBpDaAyhMYTmDAAA//+gYCErzmCpCQAAAABJRU5ErkJggg==" isIdenticon: true - totalRingUnits: 25 ringSpecModel: [ ListElement {colorId: 11; segmentLength: 1}, ListElement {colorId: 23; segmentLength: 5}, ListElement {colorId: 23; segmentLength: 5}, @@ -950,7 +948,6 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I isOnline: false source: "" isIdenticon: false - totalRingUnits: 25 ringSpecModel: [ ListElement {colorId: 0; segmentLength: 1}, ListElement {colorId: 28; segmentLength: 1}, ListElement {colorId: 31; segmentLength: 1}, diff --git a/src/StatusQ/Components/StatusChatListItem.qml b/src/StatusQ/Components/StatusChatListItem.qml index b27a232c..f6ed56fe 100644 --- a/src/StatusQ/Components/StatusChatListItem.qml +++ b/src/StatusQ/Components/StatusChatListItem.qml @@ -30,6 +30,7 @@ Rectangle { color: Theme.palette.miscColor5 letterSize: emoji ? 14 : 15 emoji: "" + charactersLen: 1 } property int type: StatusChatListItem.Type.PublicChat property bool highlighted: false diff --git a/src/StatusQ/Components/StatusLetterIdenticon.qml b/src/StatusQ/Components/StatusLetterIdenticon.qml index 26a0ae74..6531cf2a 100644 --- a/src/StatusQ/Components/StatusLetterIdenticon.qml +++ b/src/StatusQ/Components/StatusLetterIdenticon.qml @@ -4,13 +4,13 @@ import StatusQ.Core.Theme 0.1 import StatusQ.Core.Utils 0.1 Rectangle { - id: statusLetterIdenticon + id: root property alias identiconText: identiconText property string name property string emoji property int letterSize: 21 - property int charCount: 1 + property int charactersLen: 1 color: Theme.palette.miscColor5 width: 40 @@ -19,6 +19,17 @@ Rectangle { StatusBaseText { id: identiconText + + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + anchors.alignWhenCentered: false + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + font.weight: Font.Bold + font.pixelSize: root.letterSize + color: Qt.rgba(255, 255, 255, 0.7) + text: { if (emoji) { if(Utils.isHtml(emoji)) @@ -26,20 +37,12 @@ Rectangle { else return Emoji.parse(emoji) } - return (((statusLetterIdenticon.name.charAt(0) === "#") - || (statusLetterIdenticon.name.charAt(0) === "@") ? - statusLetterIdenticon.name.charAt(1) : statusLetterIdenticon.name.charAt(0)).toUpperCase() - + ((charCount === 2) ? statusLetterIdenticon.name.charAt(1) : "")) + + const shift = (root.name.charAt(0) === "#") || + (root.name.charAt(0) === "@") + + return root.name.substring(shift, shift + charactersLen).toUpperCase() } - font.weight: Font.Bold - font.pixelSize: statusLetterIdenticon.letterSize - color: Qt.rgba(255, 255, 255, 0.7) - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - anchors.alignWhenCentered: false - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter } } - diff --git a/src/StatusQ/Components/StatusListItem.qml b/src/StatusQ/Components/StatusListItem.qml index c87ea40b..78a6b458 100644 --- a/src/StatusQ/Components/StatusListItem.qml +++ b/src/StatusQ/Components/StatusListItem.qml @@ -32,6 +32,7 @@ Rectangle { rotation: 0 isLetterIdenticon: false letterSize: 21 + charactersLen: 1 color: isLetterIdenticon ? background.color : type === StatusListItem.Type.Danger ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1 background: StatusIconBackgroundSettings { @@ -54,9 +55,9 @@ Rectangle { isIdenticon: false } property StatusIdenticonRingSettings ringSettings: StatusIdenticonRingSettings { - totalRingUnits: 1 initalAngleRad: 0 ringPxSize: 1.5 + distinctiveColors: Theme.palette.identiconRingColors } property alias sensor: sensor diff --git a/src/StatusQ/Components/StatusSmartIdenticon.qml b/src/StatusQ/Components/StatusSmartIdenticon.qml index c915f048..a3b7557c 100644 --- a/src/StatusQ/Components/StatusSmartIdenticon.qml +++ b/src/StatusQ/Components/StatusSmartIdenticon.qml @@ -7,7 +7,6 @@ Loader { id: statusSmartIdenticon property string name: "" - property int charCount: 1 property int dZ: 100 // Badge color properties must be set if badgeItem.visible = true @@ -16,6 +15,7 @@ Loader { property StatusIconSettings icon: StatusIconSettings { width: 40 height: 40 + charactersLen: 1 } property StatusImageSettings image: StatusImageSettings { @@ -24,9 +24,9 @@ Loader { } property StatusIdenticonRingSettings ringSettings: StatusIdenticonRingSettings { - totalRingUnits: 1 initalAngleRad: 0 ringPxSize: 1.5 + distinctiveColors: Theme.palette.identiconRingColors } sourceComponent: statusSmartIdenticon.icon.isLetterIdenticon ? letterIdenticon : @@ -86,7 +86,8 @@ Loader { name: statusSmartIdenticon.name emoji: statusSmartIdenticon.icon.emoji letterSize: statusSmartIdenticon.icon.letterSize - charCount: statusSmartIdenticon.charCount + identiconText.color: statusSmartIdenticon.icon.textColor + charactersLen: statusSmartIdenticon.icon.charactersLen } } diff --git a/src/StatusQ/Controls/StatusIdenticonRing.qml b/src/StatusQ/Controls/StatusIdenticonRing.qml index 7dace66b..3da4e874 100644 --- a/src/StatusQ/Controls/StatusIdenticonRing.qml +++ b/src/StatusQ/Controls/StatusIdenticonRing.qml @@ -22,7 +22,6 @@ import StatusQ.Core 0.1 StatusIdenticonRing { anchors.fill: parent settings: StatusIdenticonRingSettings { - totalRingUnits: 25 initalAngleRad: 0 ringPxSize: 1.5 ringSpecModel: [ ListElement {colorId: 0; segmentLength: 1}, @@ -52,55 +51,80 @@ import StatusQ.Core 0.1 For a list of components available see StatusQ. */ Item { - id: identiconRing + id: root /*! \qmlproperty StatusIdenticonRingSettings StatusIdenticonRing::settings This property holds a set of settings for building the ring. */ property StatusIdenticonRingSettings settings: StatusIdenticonRingSettings { - totalRingUnits: 1 initalAngleRad: 0 ringPxSize: 1.5 } - /*! - \qmlproperty real StatusIdenticonRing::segmentRadLen - This property holds the total ring line length in radians. It depends on totalRingUnits value of settings object. - */ - readonly property real segmentRadLen: 2 * Math.PI / settings.totalRingUnits - visible: settings.ringSpecModel !== undefined - Canvas { - function printArcSegment(context, xPos, yPos, radius, color, startAngle, arcAngleLen, lineWidth) { - context.beginPath() - context.arc(xPos, yPos, radius, startAngle, startAngle + arcAngleLen, false/*anticlockwise*/) - context.strokeStyle = color - context.lineWidth = lineWidth - context.stroke() - } - + Loader { anchors.fill: parent - onPaint: { - const context = getContext("2d") - const radius = (height - settings.ringPxSize) / 2 - const xPos = width / 2 - const yPos = height / 2 - let arcPos = settings.initalAngleRad - context.reset() - if(settings.ringSpecModel) { - for (let i=0; i