From d8c388c9b8fc3ad01c40800f3a27983bdea14006 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Mon, 18 Oct 2021 17:36:02 +0200 Subject: [PATCH] refactor: Remove StatusLetterIdenticon from ui/shared/status and use existing one from StatusQ closes #3845 --- .../Chat/components/BadgeContent.qml | 6 +- .../Chat/components/GroupInfoPopup.qml | 8 +- ui/shared/status/StatusIconTabButton.qml | 118 ------------------ ui/shared/status/StatusIdenticon.qml | 7 +- ui/shared/status/StatusLetterIdenticon.qml | 37 ------ ui/shared/status/qmldir | 1 - 6 files changed, 13 insertions(+), 164 deletions(-) delete mode 100644 ui/shared/status/StatusIconTabButton.qml delete mode 100644 ui/shared/status/StatusLetterIdenticon.qml diff --git a/ui/app/AppLayouts/Chat/components/BadgeContent.qml b/ui/app/AppLayouts/Chat/components/BadgeContent.qml index 40c010eb0c..276f1ea299 100644 --- a/ui/app/AppLayouts/Chat/components/BadgeContent.qml +++ b/ui/app/AppLayouts/Chat/components/BadgeContent.qml @@ -7,6 +7,8 @@ import "../../../../shared/panels" import "../../../../shared/controls" import "../../../../shared/status" +import StatusQ.Components 0.1 as StatusQ + Item { id: wrapper @@ -89,11 +91,11 @@ Item { Component { id: letterIdenticon - StatusLetterIdenticon { + StatusQ.StatusLetterIdenticon { width: 16 height: 16 letterSize: 12 - chatName: communityBadge.communityName + name: communityBadge.communityName color: communityBadge.iconColor } } diff --git a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml index 47981fa69e..69ff0fccf4 100644 --- a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml +++ b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml @@ -3,6 +3,9 @@ import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 import utils 1.0 + +import StatusQ.Components 0.1 as StatusQ + import "../../../../shared" import "../../../../shared/views" import "../../../../shared/popups" @@ -67,14 +70,13 @@ ModalPopup { width: parent.width - StatusLetterIdenticon { + StatusQ.StatusLetterIdenticon { id: letterIdenticon width: 36 height: 36 anchors.top: parent.top color: popup.channel.color - chatId: popup.channel.id - chatName: popup.channel.name + name: popup.channel.name } StyledTextEdit { diff --git a/ui/shared/status/StatusIconTabButton.qml b/ui/shared/status/StatusIconTabButton.qml deleted file mode 100644 index 72deac50d3..0000000000 --- a/ui/shared/status/StatusIconTabButton.qml +++ /dev/null @@ -1,118 +0,0 @@ -import QtQuick 2.13 -import QtQuick.Controls 2.13 -import QtGraphicalEffects 1.13 - -import utils 1.0 -import "../../shared" -import "../../shared/panels" -import "../../shared/status" - -TabButton { - id: control - visible: enabled - width: 40 - height: enabled ? 40 : 0 - anchors.horizontalCenter: parent.horizontalCenter - property color iconColor: Style.current.secondaryText - property color disabledColor: iconColor - property int iconRotation: 0 - property string iconSource - property string section - property int sectionIndex: Utils.getAppSectionIndex(section) - property bool doNotHandleClick: false - property bool borderOnChecked: false - property bool useLetterIdenticon: false - property string name: "" - - onClicked: { - if (doNotHandleClick) { - return - } - - chatsModel.communities.activeCommunity.active = false - appMain.changeAppSection(section) - } - - checked: sLayout.currentIndex === sectionIndex - - icon.height: 24 - icon.width: 24 - icon.color: { - if (!enabled) { - return control.disabledColor - } - return (hovered || checked) ? Style.current.blue : control.iconColor - } - - onIconChanged: { - if (iconSource) { - icon.source = iconSource - return - } - - icon.source = icon.name ? Style.svg(icon.name) : "" - } - - contentItem: Item { - anchors.fill: parent - - Loader { - active: true - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - sourceComponent: useLetterIdenticon ? letterIdenticon : - !!iconSource ? imageIcon : defaultIcon - } - - Component { - id: defaultIcon - SVGImage { - id: iconImg - source: control.icon.source - height: control.icon.height - width: control.icon.width - fillMode: Image.PreserveAspectFit - rotation: control.iconRotation - ColorOverlay { - anchors.fill: iconImg - source: iconImg - color: control.icon.color - antialiasing: true - smooth: true - } - } - } - - Component { - id: imageIcon - RoundedImage { - source: iconSource - noMouseArea: true - } - } - - Component { - id: letterIdenticon - StatusLetterIdenticon { - width: 26 - height: 26 - letterSize: 15 - chatName: control.name - color: control.iconColor - } - } - } - - background: Rectangle { - color: hovered || (borderOnChecked && checked) ? Style.current.tabButtonBg : "transparent" - border.color: Style.current.primary - border.width: borderOnChecked && checked ? 1 : 0 - radius: control.width / 2 - } - - MouseArea { - cursorShape: Qt.PointingHandCursor - anchors.fill: parent - onPressed: mouse.accepted = false - } -} diff --git a/ui/shared/status/StatusIdenticon.qml b/ui/shared/status/StatusIdenticon.qml index 613f7cd47a..ecadb586bb 100644 --- a/ui/shared/status/StatusIdenticon.qml +++ b/ui/shared/status/StatusIdenticon.qml @@ -1,8 +1,10 @@ import QtQuick 2.13 import utils 1.0 + +import StatusQ.Components 0.1 + import "../../shared" -import "../../shared/status" Item { id: root @@ -25,8 +27,7 @@ Item { id: letterIdenticon StatusLetterIdenticon { - chatId: root.chatId - chatName: root.chatName + name: root.chatName width: parent.width height: parent.height letterSize: root.letterSize diff --git a/ui/shared/status/StatusLetterIdenticon.qml b/ui/shared/status/StatusLetterIdenticon.qml deleted file mode 100644 index d0021fcb89..0000000000 --- a/ui/shared/status/StatusLetterIdenticon.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.13 - -import utils 1.0 -import "../../shared" -import "../../shared/panels" - -Rectangle { - id: root - - property string chatId - property string chatName - property int letterSize: 15 - - width: 40 - height: 40 - radius: width / 2 - - color: { - const color = chatsModel.channelView.getChannelColor(chatId) - if (!color) { - return Style.current.orange - } - return color - } - - StyledText { - text: (root.chatName.charAt(0) == "#" ? root.chatName.charAt(1) : root.chatName.charAt(0)).toUpperCase() - opacity: 0.7 - font.weight: Font.Bold - font.pixelSize: root.letterSize - color: "white" - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: -1 - anchors.bottomMargin: -2 - } -} diff --git a/ui/shared/status/qmldir b/ui/shared/status/qmldir index f5677f5ac0..f685d0653b 100644 --- a/ui/shared/status/qmldir +++ b/ui/shared/status/qmldir @@ -9,7 +9,6 @@ StatusGifPopup 1.0 StatusGifPopup.qml StatusGifColumn 1.0 StatusGifColumn.qml StatusIconButton 1.0 StatusIconButton.qml StatusImageIdenticon 1.0 StatusImageIdenticon.qml -StatusLetterIdenticon 1.0 StatusLetterIdenticon.qml StatusRadioButton 1.0 StatusRadioButton.qml StatusRoundButton 1.0 StatusRoundButton.qml StatusSectionHeadline 1.0 StatusSectionHeadline.qml