feat(StatusChatListItem): add `highlighted` property

Similar to other controls and components, chat list items can be in a
`highlighted` state, for example when popup menus are active.

Closes #178
This commit is contained in:
Pascal Precht 2021-06-23 12:13:35 +02:00 committed by Michał Cieślak
parent d389196f9e
commit 7d39fee193
1 changed files with 7 additions and 3 deletions

View File

@ -18,6 +18,7 @@ Rectangle {
color: Theme.palette.miscColor5 color: Theme.palette.miscColor5
} }
property int type: StatusChatListItem.Type.PublicChat property int type: StatusChatListItem.Type.PublicChat
property bool highlighted: false
property bool selected: false property bool selected: false
signal clicked(var mouse) signal clicked(var mouse)
@ -39,7 +40,7 @@ Rectangle {
if (selected) { if (selected) {
return Theme.palette.statusChatListItem.selectedBackgroundColor return Theme.palette.statusChatListItem.selectedBackgroundColor
} }
return sensor.containsMouse ? Theme.palette.statusChatListItem.hoverBackgroundColor : Theme.palette.baseColor4 return sensor.containsMouse || highlighted ? Theme.palette.statusChatListItem.hoverBackgroundColor : Theme.palette.baseColor4
} }
MouseArea { MouseArea {
@ -47,6 +48,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true hoverEnabled: true
onClicked: statusChatListItem.clicked(mouse) onClicked: statusChatListItem.clicked(mouse)
@ -101,12 +103,13 @@ Rectangle {
width: 14 width: 14
visible: statusChatListItem.type !== StatusChatListItem.Type.OneToOneChat visible: statusChatListItem.type !== StatusChatListItem.Type.OneToOneChat
opacity: { opacity: {
if (statusChatListItem.muted && !sensor.containsMouse) { if (statusChatListItem.muted && !sensor.containsMouse && !statusChatListItem.highlighted) {
return 0.4 return 0.4
} }
return statusChatListItem.hasMention || return statusChatListItem.hasMention ||
statusChatListItem.hasUnreadMessages || statusChatListItem.hasUnreadMessages ||
statusChatListItem.selected || statusChatListItem.selected ||
statusChatListItem.highlighted ||
statusBadge.visible || statusBadge.visible ||
sensor.containsMouse ? 1.0 : 0.7 sensor.containsMouse ? 1.0 : 0.7
} }
@ -136,12 +139,13 @@ Rectangle {
text: statusChatListItem.name text: statusChatListItem.name
color: { color: {
if (statusChatListItem.muted && !sensor.containsMouse) { if (statusChatListItem.muted && !sensor.containsMouse && !statusChatListItem.highlighted) {
return Theme.palette.directColor5 return Theme.palette.directColor5
} }
return statusChatListItem.hasMention || return statusChatListItem.hasMention ||
statusChatListItem.hasUnreadMessages || statusChatListItem.hasUnreadMessages ||
statusChatListItem.selected || statusChatListItem.selected ||
statusChatListItem.highlighted ||
sensor.containsMouse || sensor.containsMouse ||
statusBadge.visible ? Theme.palette.directColor1 : Theme.palette.directColor4 statusBadge.visible ? Theme.palette.directColor1 : Theme.palette.directColor4
} }