refactor: Remove StatusLetterIdenticon from ui/shared/status and use existing one from StatusQ

closes #3845
This commit is contained in:
Khushboo Mehta 2021-10-18 17:36:02 +02:00 committed by Iuri Matias
parent e853eaa3ec
commit d8c388c9b8
6 changed files with 13 additions and 164 deletions

View File

@ -7,6 +7,8 @@ import "../../../../shared/panels"
import "../../../../shared/controls" import "../../../../shared/controls"
import "../../../../shared/status" import "../../../../shared/status"
import StatusQ.Components 0.1 as StatusQ
Item { Item {
id: wrapper id: wrapper
@ -89,11 +91,11 @@ Item {
Component { Component {
id: letterIdenticon id: letterIdenticon
StatusLetterIdenticon { StatusQ.StatusLetterIdenticon {
width: 16 width: 16
height: 16 height: 16
letterSize: 12 letterSize: 12
chatName: communityBadge.communityName name: communityBadge.communityName
color: communityBadge.iconColor color: communityBadge.iconColor
} }
} }

View File

@ -3,6 +3,9 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import utils 1.0 import utils 1.0
import StatusQ.Components 0.1 as StatusQ
import "../../../../shared" import "../../../../shared"
import "../../../../shared/views" import "../../../../shared/views"
import "../../../../shared/popups" import "../../../../shared/popups"
@ -67,14 +70,13 @@ ModalPopup {
width: parent.width width: parent.width
StatusLetterIdenticon { StatusQ.StatusLetterIdenticon {
id: letterIdenticon id: letterIdenticon
width: 36 width: 36
height: 36 height: 36
anchors.top: parent.top anchors.top: parent.top
color: popup.channel.color color: popup.channel.color
chatId: popup.channel.id name: popup.channel.name
chatName: popup.channel.name
} }
StyledTextEdit { StyledTextEdit {

View File

@ -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
}
}

View File

@ -1,8 +1,10 @@
import QtQuick 2.13 import QtQuick 2.13
import utils 1.0 import utils 1.0
import StatusQ.Components 0.1
import "../../shared" import "../../shared"
import "../../shared/status"
Item { Item {
id: root id: root
@ -25,8 +27,7 @@ Item {
id: letterIdenticon id: letterIdenticon
StatusLetterIdenticon { StatusLetterIdenticon {
chatId: root.chatId name: root.chatName
chatName: root.chatName
width: parent.width width: parent.width
height: parent.height height: parent.height
letterSize: root.letterSize letterSize: root.letterSize

View File

@ -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
}
}

View File

@ -9,7 +9,6 @@ StatusGifPopup 1.0 StatusGifPopup.qml
StatusGifColumn 1.0 StatusGifColumn.qml StatusGifColumn 1.0 StatusGifColumn.qml
StatusIconButton 1.0 StatusIconButton.qml StatusIconButton 1.0 StatusIconButton.qml
StatusImageIdenticon 1.0 StatusImageIdenticon.qml StatusImageIdenticon 1.0 StatusImageIdenticon.qml
StatusLetterIdenticon 1.0 StatusLetterIdenticon.qml
StatusRadioButton 1.0 StatusRadioButton.qml StatusRadioButton 1.0 StatusRadioButton.qml
StatusRoundButton 1.0 StatusRoundButton.qml StatusRoundButton 1.0 StatusRoundButton.qml
StatusSectionHeadline 1.0 StatusSectionHeadline.qml StatusSectionHeadline 1.0 StatusSectionHeadline.qml