2020-12-11 20:29:46 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../components"
|
|
|
|
|
2021-02-17 16:31:59 +00:00
|
|
|
StatusIconTabButton {
|
2020-12-11 20:29:46 +00:00
|
|
|
property string communityId: ""
|
|
|
|
property string name: "channelName"
|
2021-02-22 18:53:47 +00:00
|
|
|
property int unviewedMessagesCount: 0
|
2021-02-10 20:37:17 +00:00
|
|
|
property string image
|
2020-12-11 20:29:46 +00:00
|
|
|
property bool hasMentions: false
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
id: communityButton
|
2021-02-17 16:31:59 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
iconSource: communityButton.image
|
|
|
|
anchors.topMargin: 0
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-02-17 16:31:59 +00:00
|
|
|
section: Constants.community
|
|
|
|
|
|
|
|
checked: chatsModel.communities.activeCommunity.active && chatsModel.communities.activeCommunity.id === communityId
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-02-17 16:31:59 +00:00
|
|
|
borderOnChecked: true
|
|
|
|
doNotHandleClick: true
|
|
|
|
onClicked: {
|
|
|
|
appMain.changeAppSection(Constants.chat)
|
|
|
|
chatsModel.communities.setActiveCommunity(communityId)
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 18:29:56 +00:00
|
|
|
StatusToolTip {
|
|
|
|
visible: communityButton.hovered
|
|
|
|
text: communityButton.name
|
|
|
|
delay: 50
|
2021-03-25 17:37:40 +00:00
|
|
|
orientation: "right"
|
|
|
|
x: communityButton.width + Style.current.padding
|
|
|
|
y: communityButton.height / 2 - height / 2 + 4
|
2021-02-17 18:29:56 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Rectangle {
|
2021-02-17 16:31:59 +00:00
|
|
|
id: chatBadge
|
|
|
|
visible: unviewedMessagesCount > 0
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.right
|
|
|
|
anchors.leftMargin: -17
|
|
|
|
anchors.topMargin: 1
|
|
|
|
radius: height / 2
|
|
|
|
color: Style.current.blue
|
|
|
|
border.color: Style.current.background
|
|
|
|
border.width: 2
|
|
|
|
width: unviewedMessagesCount < 10 ? 22 : messageCount.width + 14
|
2020-12-11 20:29:46 +00:00
|
|
|
height: 22
|
2021-02-17 16:31:59 +00:00
|
|
|
Text {
|
|
|
|
id: messageCount
|
2021-06-21 19:35:32 +00:00
|
|
|
font.pixelSize: chatsModel.messageView.unreadMessagesCount > 99 ? 10 : 12
|
2020-12-11 20:29:46 +00:00
|
|
|
color: Style.current.white
|
2021-02-17 16:31:59 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
text: unviewedMessagesCount > 99 ? "99+" : unviewedMessagesCount
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-29 19:31:18 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: function (mouse) {
|
|
|
|
if (mouse.button === Qt.RightButton) {
|
|
|
|
commnunityMenu.communityId = communityButton.communityId
|
|
|
|
commnunityMenu.popup()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
communityButton.clicked()
|
|
|
|
}
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|