From 173943f1bef575944d42c840c9a2c51cd89f46a4 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Fri, 22 Oct 2021 01:34:35 +0200 Subject: [PATCH] refactor: replace StatusIdenticon with StatusSmartIdenticon closes #3882 --- .../AppLayouts/Chat/controls/UserDelegate.qml | 22 +++++---- .../controls/activityCenter/ChannelBadge.qml | 25 ++++++---- .../Chat/panels/BadgeContentPanel.qml | 23 +++++---- .../Chat/views/ActivityCenterGroupRequest.qml | 14 +++--- .../Profile/popups/MutedChatsModal.qml | 24 +++++++--- ui/app/AppMain.qml | 29 ++++++++---- ui/shared/status/StatusIdenticon.qml | 47 ------------------- ui/shared/status/StatusNotification.qml | 28 ++++++++--- 8 files changed, 110 insertions(+), 102 deletions(-) delete mode 100644 ui/shared/status/StatusIdenticon.qml diff --git a/ui/app/AppLayouts/Chat/controls/UserDelegate.qml b/ui/app/AppLayouts/Chat/controls/UserDelegate.qml index 93c029de6a..249489a2f3 100644 --- a/ui/app/AppLayouts/Chat/controls/UserDelegate.qml +++ b/ui/app/AppLayouts/Chat/controls/UserDelegate.qml @@ -2,12 +2,12 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import "../../../../shared" import "../../../../shared/panels" -import "../../../../shared/status" import utils 1.0 import StatusQ.Components 0.1 import StatusQ.Core.Theme 0.1 +import StatusQ.Core 0.1 Item { id: wrapper @@ -53,17 +53,23 @@ Item { } } - StatusIdenticon { + StatusSmartIdenticon { id: contactImage - height: 28 - width: 28 - chatId: wrapper.publicKey - chatName: wrapper.name - chatType: Constants.chatTypeOneToOne - identicon: wrapper.profileImage || wrapper.identicon anchors.left: parent.left anchors.leftMargin: Style.current.padding anchors.verticalCenter: parent.verticalCenter + image: StatusImageSettings { + width: 28 + height: 28 + source: wrapper.profileImage || wrapper.identicon + isIdenticon: true + } + icon: StatusIconSettings { + width: 28 + height: 28 + letterSize: 15 + } + name: wrapper.name } StyledText { diff --git a/ui/app/AppLayouts/Chat/controls/activityCenter/ChannelBadge.qml b/ui/app/AppLayouts/Chat/controls/activityCenter/ChannelBadge.qml index 04dcaa0722..1887efe159 100644 --- a/ui/app/AppLayouts/Chat/controls/activityCenter/ChannelBadge.qml +++ b/ui/app/AppLayouts/Chat/controls/activityCenter/ChannelBadge.qml @@ -6,7 +6,9 @@ import Qt.labs.platform 1.1 import utils 1.0 import "../../../../../shared" import "../../../../../shared/panels" -import "../../../../../shared/status" + +import StatusQ.Components 0.1 +import StatusQ.Core 0.1 Item { id: channelBadge @@ -28,18 +30,23 @@ Item { anchors.verticalCenter:parent.verticalCenter } - StatusIdenticon { + StatusSmartIdenticon { id: contactImage - height: 16 - width: 16 - chatId: chatId - chatName: name - chatType: realChatType - identicon: profileImage || identicon anchors.left: channelIcon.right anchors.leftMargin: 4 anchors.verticalCenter: parent.verticalCenter - letterSize: 11 + image: StatusImageSettings { + width: 16 + height: 16 + source: profileImage || identicon + isIdenticon: true + } + icon: StatusIconSettings { + width: 16 + height: 16 + letterSize: 11 + } + name: channelBadge.name } StyledText { diff --git a/ui/app/AppLayouts/Chat/panels/BadgeContentPanel.qml b/ui/app/AppLayouts/Chat/panels/BadgeContentPanel.qml index ac49160655..8531e4c250 100644 --- a/ui/app/AppLayouts/Chat/panels/BadgeContentPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/BadgeContentPanel.qml @@ -5,9 +5,9 @@ import utils 1.0 import "../../../../shared" import "../../../../shared/panels" import "../../../../shared/controls" -import "../../../../shared/status" import StatusQ.Components 0.1 as StatusQ +import StatusQ.Core 0.1 Item { id: wrapper @@ -180,18 +180,23 @@ Item { anchors.verticalCenter:parent.verticalCenter } - StatusIdenticon { + StatusQ.StatusSmartIdenticon { id: contactImage - height: 16 - width: 16 - chatId: wrapper.chatId - chatName: wrapper.name - chatType: wrapper.realChatType - identicon: wrapper.profileImage || wrapper.identicon anchors.left: channelIcon.right anchors.leftMargin: 4 anchors.verticalCenter: parent.verticalCenter - letterSize: 11 + image: StatusImageSettings { + width: 16 + height: 16 + source: wrapper.profileImage || wrapper.identicon + isIdenticon: true + } + icon: StatusIconSettings { + width: 16 + height: 16 + letterSize: 11 + } + name: wrapper.name } StyledText { diff --git a/ui/app/AppLayouts/Chat/views/ActivityCenterGroupRequest.qml b/ui/app/AppLayouts/Chat/views/ActivityCenterGroupRequest.qml index dd80e6f11b..cbd7ca1ef8 100644 --- a/ui/app/AppLayouts/Chat/views/ActivityCenterGroupRequest.qml +++ b/ui/app/AppLayouts/Chat/views/ActivityCenterGroupRequest.qml @@ -3,7 +3,6 @@ import QtGraphicalEffects 1.13 import utils 1.0 import "../../../../shared" -import "../../../../shared/status" import "../../../../shared/popups" import "../../../../shared/controls" import "../../../../shared/panels" @@ -11,6 +10,9 @@ import "../../../../shared/panels" import "../controls" import "../panels" +import StatusQ.Components 0.1 +import StatusQ.Core.Theme 0.1 + Item { id: root width: parent.width @@ -42,17 +44,13 @@ Item { anchors.topMargin: dateGroupLbl.visible ? 4 : 0 color: model.read ? Style.current.transparent : Utils.setColorAlpha(Style.current.blue, 0.1) - StatusIdenticon { + StatusSmartIdenticon { id: channelIdenticon - height: 40 - width: 40 - chatId: model.chatId - chatName: model.name - chatType: Constants.chatTypePrivateGroupChat - identicon: "" anchors.left: parent.left anchors.leftMargin: Style.current.padding anchors.verticalCenter: parent.verticalCenter + name: model.name + icon.color: Theme.palette.miscColor5 } Item { diff --git a/ui/app/AppLayouts/Profile/popups/MutedChatsModal.qml b/ui/app/AppLayouts/Profile/popups/MutedChatsModal.qml index 346dc7ff3f..d950e711a4 100644 --- a/ui/app/AppLayouts/Profile/popups/MutedChatsModal.qml +++ b/ui/app/AppLayouts/Profile/popups/MutedChatsModal.qml @@ -6,11 +6,13 @@ import QtQuick.Layouts 1.13 import utils 1.0 import StatusQ.Controls 0.1 +import StatusQ.Components 0.1 +import StatusQ.Core.Theme 0.1 +import StatusQ.Core 0.1 import "../../../../shared" import "../../../../shared/popups" import "../../../../shared/panels" -import "../../../../shared/status" // TODO: replace with StatusModal ModalPopup { @@ -39,16 +41,24 @@ ModalPopup { radius: Style.current.radius color: isHovered ? Style.current.backgroundHover : Style.current.transparent - StatusIdenticon { + StatusSmartIdenticon { id: contactImage - height: 40 - width: 40 - chatName: model.name - chatType: model.chatType - identicon: model.identicon anchors.left: parent.left anchors.leftMargin: Style.current.smallPadding anchors.verticalCenter: parent.verticalCenter + image: StatusImageSettings { + width: 40 + height: 40 + source: model.identicon + isIdenticon: true + } + icon: StatusIconSettings { + width: 40 + height: 40 + letterSize: 15 + color: Theme.palette.miscColor5 + } + name: model.name } StyledText { diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index 54139aae24..a9a70c32c8 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -21,9 +21,11 @@ import Qt.labs.platform 1.1 import Qt.labs.settings 1.0 import StatusQ.Core.Theme 0.1 +import StatusQ.Components 0.1 import StatusQ.Controls 0.1 import StatusQ.Layout 0.1 import StatusQ.Popups 0.1 +import StatusQ.Core 0.1 Item { @@ -737,8 +739,22 @@ Item { } Component { - id: statusIdenticonComponent - StatusIdenticon {} + id: statusSmartIdenticonComponent + StatusSmartIdenticon { + property string imageSource: "" + image: StatusImageSettings { + width: channelPicker.imageWidth + height: channelPicker.imageHeight + source: imageSource + isIdenticon: true + } + icon: StatusIconSettings { + width: channelPicker.imageWidth + height: channelPicker.imageHeight + letterSize: 15 + color: Theme.palette.miscColor5 + } + } } StatusInputListPopup { @@ -754,12 +770,9 @@ Item { return modelData.name } getImageComponent: function (parent, modelData) { - return statusIdenticonComponent.createObject(parent, { - width: channelPicker.imageWidth, - height: channelPicker.imageHeight, - chatName: modelData.name, - chatType: modelData.chatType, - identicon: modelData.identicon + return statusSmartIdenticonComponent.createObject(parent, { + imageSource: modelData.identicon, + name: modelData.name }); } onClicked: function (index) { diff --git a/ui/shared/status/StatusIdenticon.qml b/ui/shared/status/StatusIdenticon.qml deleted file mode 100644 index ecadb586bb..0000000000 --- a/ui/shared/status/StatusIdenticon.qml +++ /dev/null @@ -1,47 +0,0 @@ -import QtQuick 2.13 - -import utils 1.0 - -import StatusQ.Components 0.1 - -import "../../shared" - -Item { - id: root - - property string chatId - property string chatName - property int chatType - property string identicon - property int letterSize: 15 - - width: 40 - height: 40 - - Loader { - sourceComponent: root.chatType == Constants.chatTypeOneToOne || !!root.identicon ? imageIdenticon : letterIdenticon - anchors.fill: parent - } - - Component { - id: letterIdenticon - - StatusLetterIdenticon { - name: root.chatName - width: parent.width - height: parent.height - letterSize: root.letterSize - } - } - - Component { - id: imageIdenticon - - StatusImageIdenticon { - source: root.identicon - width: parent.width - height: parent.height - } - } -} - diff --git a/ui/shared/status/StatusNotification.qml b/ui/shared/status/StatusNotification.qml index 5656acfef2..987247a70a 100644 --- a/ui/shared/status/StatusNotification.qml +++ b/ui/shared/status/StatusNotification.qml @@ -6,6 +6,10 @@ import utils 1.0 import "../../shared" import "../../shared/panels" +import StatusQ.Components 0.1 +import StatusQ.Core.Theme 0.1 +import StatusQ.Core 0.1 + Rectangle { id: root property string chatId: "" @@ -33,12 +37,24 @@ Rectangle { Component { id: userOrChannelIdenticon - StatusIdenticon { - height: 40 - width: 40 - chatName: root.name - chatType: root.chatType - identicon: root.identicon + StatusSmartIdenticon { + id: contactImage + anchors.left: parent.left + anchors.leftMargin: Style.current.smallPadding + anchors.verticalCenter: parent.verticalCenter + image: StatusImageSettings { + width: 40 + height: 40 + source: root.identicon + isIdenticon: true + } + icon: StatusIconSettings { + width: 40 + height: 40 + letterSize: 15 + color: Theme.palette.miscColor5 + } + name: root.name } }