2021-05-27 14:41:14 +02:00
|
|
|
import QtQuick 2.14
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: statusChatInfoButton
|
|
|
|
|
2021-08-25 16:14:37 +03:00
|
|
|
implicitWidth: identicon.width +
|
|
|
|
Math.max(
|
|
|
|
statusChatInfoButtonTitle.anchors.leftMargin + statusChatInfoButtonTitle.implicitWidth,
|
|
|
|
statusChatInfoButtonTitle.anchors.leftMargin + statusChatInfoButtonSubTitle.implicitWidth
|
|
|
|
) + 8
|
2021-05-27 14:41:14 +02:00
|
|
|
implicitHeight: 48
|
|
|
|
|
|
|
|
property string title: ""
|
|
|
|
property string subTitle: ""
|
|
|
|
property bool muted: false
|
|
|
|
property int pinnedMessagesCount: 0
|
2021-10-20 16:35:54 +02:00
|
|
|
property StatusImageSettings image: StatusImageSettings {
|
|
|
|
width: 36
|
|
|
|
height: 36
|
|
|
|
}
|
|
|
|
property StatusIconSettings icon: StatusIconSettings {
|
|
|
|
width: 36
|
|
|
|
height: 36
|
2022-04-01 13:51:58 +02:00
|
|
|
charactersLen: 2
|
2021-10-20 16:35:54 +02:00
|
|
|
}
|
2022-04-01 13:51:58 +02:00
|
|
|
property alias ringSettings: identicon.ringSettings
|
|
|
|
|
2021-05-27 14:41:14 +02:00
|
|
|
property int type: StatusChatInfoButton.Type.PublicChat
|
|
|
|
property alias tooltip: statusToolTip
|
2021-07-06 11:22:41 +02:00
|
|
|
property alias sensor: sensor
|
2021-05-27 14:41:14 +02:00
|
|
|
|
|
|
|
signal clicked(var mouse)
|
|
|
|
signal pinnedMessagesCountClicked(var mouse)
|
|
|
|
signal unmute()
|
2021-10-05 12:56:31 +02:00
|
|
|
signal linkActivated(string link)
|
2021-05-27 14:41:14 +02:00
|
|
|
|
|
|
|
enum Type {
|
2021-06-23 14:12:33 +02:00
|
|
|
Unknown0, // 0
|
|
|
|
OneToOneChat, // 1
|
|
|
|
PublicChat, // 2
|
|
|
|
GroupChat, // 3
|
|
|
|
Unknown1, // 4
|
|
|
|
Unknown2, // 5
|
|
|
|
CommunityChat // 6
|
2021-05-27 14:41:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
radius: 8
|
2021-07-06 11:22:41 +02:00
|
|
|
color: sensor.enabled && sensor.containsMouse ? Theme.palette.baseColor2 : "transparent"
|
2021-05-27 14:41:14 +02:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: sensor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
2021-07-06 11:22:41 +02:00
|
|
|
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
2021-05-27 14:41:14 +02:00
|
|
|
|
|
|
|
onClicked: statusChatInfoButton.clicked(mouse)
|
|
|
|
|
2021-10-20 16:35:54 +02:00
|
|
|
StatusSmartIdenticon {
|
2021-05-27 14:41:14 +02:00
|
|
|
id: identicon
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-10-20 16:35:54 +02:00
|
|
|
image: statusChatInfoButton.image
|
|
|
|
icon: statusChatInfoButton.icon
|
|
|
|
name: statusChatInfoButton.title
|
2021-05-27 14:41:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: statusChatInfoButtonTitle
|
|
|
|
anchors.top: identicon.top
|
2021-07-06 11:26:01 +02:00
|
|
|
anchors.topMargin: statusChatInfoButtonSubTitle.visible ? 0 : 8
|
2021-05-27 14:41:14 +02:00
|
|
|
anchors.left: identicon.right
|
|
|
|
anchors.leftMargin: 8
|
2021-08-19 19:48:00 +02:00
|
|
|
|
2021-08-25 16:14:37 +03:00
|
|
|
width: Math.min(parent.width - anchors.leftMargin
|
|
|
|
- identicon.width - identicon.anchors.leftMargin,
|
|
|
|
implicitWidth)
|
2021-05-27 14:41:14 +02:00
|
|
|
height: chatName.height
|
|
|
|
|
2021-08-25 16:14:37 +03:00
|
|
|
implicitWidth: statusIcon.width + chatName.anchors.leftMargin + chatName.implicitWidth
|
|
|
|
+ mutedDelta
|
|
|
|
|
|
|
|
property real mutedDelta: mutedIcon.visible ? mutedIcon.width + 8 : 0
|
|
|
|
|
2021-05-27 14:41:14 +02:00
|
|
|
StatusIcon {
|
|
|
|
id: statusIcon
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -2
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
|
|
|
visible: statusChatInfoButton.type !== StatusChatInfoButton.Type.OneToOneChat
|
|
|
|
width: visible ? 14 : 0
|
|
|
|
color: statusChatInfoButton.muted ? Theme.palette.baseColor1 : Theme.palette.directColor1
|
|
|
|
icon: {
|
|
|
|
switch (statusChatInfoButton.type) {
|
2021-08-25 16:14:37 +03:00
|
|
|
case StatusChatInfoButton.Type.PublicCat:
|
|
|
|
return "tiny/public-chat"
|
|
|
|
break;
|
|
|
|
case StatusChatInfoButton.Type.GroupChat:
|
|
|
|
return "tiny/group"
|
|
|
|
break;
|
|
|
|
case StatusChatInfoButton.Type.CommunityChat:
|
|
|
|
return "tiny/channel"
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return "tiny/public-chat"
|
2021-05-27 14:41:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: chatName
|
2022-07-20 11:12:05 -04:00
|
|
|
objectName: "statusChatInfoButtonNameText"
|
2021-05-27 14:41:14 +02:00
|
|
|
|
|
|
|
anchors.left: statusIcon.visible ? statusIcon.right : parent.left
|
|
|
|
anchors.leftMargin: statusIcon.visible ? 1 : 0
|
|
|
|
anchors.top: parent.top
|
2021-08-19 19:48:00 +02:00
|
|
|
|
2021-08-25 16:14:37 +03:00
|
|
|
elide: Text.ElideRight
|
|
|
|
width: Math.min(implicitWidth, parent.width
|
|
|
|
- statusIcon.width
|
|
|
|
- statusChatInfoButtonTitle.mutedDelta)
|
|
|
|
|
2021-07-06 11:29:08 +02:00
|
|
|
text: statusChatInfoButton.type === StatusChatInfoButton.Type.PublicChat &&
|
2021-08-25 16:14:37 +03:00
|
|
|
!statusChatInfoButton.title.startsWith("#") ?
|
|
|
|
"#" + statusChatInfoButton.title :
|
|
|
|
statusChatInfoButton.title
|
2021-05-27 14:41:14 +02:00
|
|
|
color: statusChatInfoButton.muted ? Theme.palette.directColor5 : Theme.palette.directColor1
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Medium
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIcon {
|
2021-10-19 14:36:00 +03:00
|
|
|
objectName: "mutedIcon"
|
2021-05-27 14:41:14 +02:00
|
|
|
id: mutedIcon
|
|
|
|
anchors.left: chatName.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.top: chatName.top
|
|
|
|
anchors.topMargin: -2
|
|
|
|
width: 13
|
2021-06-09 10:06:35 +02:00
|
|
|
icon: "tiny/muted"
|
2021-05-27 14:41:14 +02:00
|
|
|
color: mutedIconSensor.containsMouse ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
visible: statusChatInfoButton.muted
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mutedIconSensor
|
|
|
|
hoverEnabled: true
|
2021-08-25 16:14:37 +03:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-05-27 14:41:14 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: statusChatInfoButton.unmute()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
id: statusToolTip
|
|
|
|
text: "Unmute"
|
|
|
|
visible: mutedIconSensor.containsMouse
|
|
|
|
orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
y: parent.height + 12
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: statusChatInfoButtonSubTitle
|
|
|
|
anchors.left: statusChatInfoButtonTitle.left
|
|
|
|
anchors.top: statusChatInfoButtonTitle.bottom
|
2021-07-21 13:12:09 +02:00
|
|
|
visible: !!statusChatInfoButton.subTitle || statusChatInfoButton.pinnedMessagesCount > 0
|
2021-07-06 11:26:01 +02:00
|
|
|
height: visible ? chatType.height : 0
|
2021-08-25 16:14:37 +03:00
|
|
|
width: Math.min(parent.width - statusChatInfoButtonTitle.anchors.leftMargin
|
|
|
|
- identicon.width - identicon.anchors.leftMargin - 8,
|
|
|
|
implicitWidth)
|
|
|
|
|
|
|
|
implicitWidth: chatType.implicitWidth + pinIconDelta + 8
|
|
|
|
|
|
|
|
|
|
|
|
property real pinIconDelta: pinIcon.visible ? pinIcon.width + pinIcon.anchors.leftMargin
|
|
|
|
+ divider.width + divider.anchors.leftMargin
|
|
|
|
: 0
|
2021-05-27 14:41:14 +02:00
|
|
|
|
2021-09-29 21:22:23 +02:00
|
|
|
StatusSelectableText {
|
2021-05-27 14:41:14 +02:00
|
|
|
id: chatType
|
|
|
|
text: statusChatInfoButton.subTitle
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 12
|
2021-08-25 16:14:37 +03:00
|
|
|
width: Math.min(parent.width - (pinIcon.visible ? divider.width + divider.anchors.leftMargin + pinIcon.width + pinIcon.anchors.leftMargin : 0),
|
|
|
|
implicitWidth)
|
2021-10-05 12:56:31 +02:00
|
|
|
onLinkActivated: statusChatInfoButton.linkActivated(link)
|
2021-05-27 14:41:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: divider
|
|
|
|
height: 12
|
|
|
|
width: 1
|
|
|
|
color: Theme.palette.directColor7
|
|
|
|
anchors.left: chatType.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter: chatType.verticalCenter
|
2021-07-21 13:12:09 +02:00
|
|
|
visible: !!chatType.text && pinIcon.visible
|
2021-05-27 14:41:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
id: pinIcon
|
|
|
|
|
2021-07-21 13:12:09 +02:00
|
|
|
anchors.left: divider.visible ? divider.right : parent.left
|
2021-05-27 14:41:14 +02:00
|
|
|
anchors.leftMargin: -2
|
|
|
|
anchors.verticalCenter: chatType.verticalCenter
|
|
|
|
height: 14
|
|
|
|
visible: statusChatInfoButton.pinnedMessagesCount > 0
|
|
|
|
icon: "pin"
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.left: pinIcon.right
|
|
|
|
anchors.leftMargin: -6
|
|
|
|
anchors.verticalCenter: pinIcon.verticalCenter
|
|
|
|
|
|
|
|
width: 14
|
|
|
|
text: statusChatInfoButton.pinnedMessagesCount
|
|
|
|
font.pixelSize: 12
|
|
|
|
font.underline: pinCountSensor.containsMouse
|
|
|
|
visible: pinIcon.visible
|
|
|
|
color: pinCountSensor.containsMouse ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
|
|
|
|
MouseArea {
|
2021-10-19 16:57:27 +03:00
|
|
|
objectName: "pinMessagesCounterSensor"
|
2021-05-27 14:41:14 +02:00
|
|
|
id: pinCountSensor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
2021-08-25 16:14:37 +03:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-05-27 14:41:14 +02:00
|
|
|
onClicked: statusChatInfoButton.pinnedMessagesCountClicked(mouse)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|