Add ignore user options in member context menues

This commit is contained in:
miruka
2021-04-14 12:11:33 -04:00
parent 678a56400a
commit dc0ed43f72
6 changed files with 132 additions and 22 deletions

View File

@@ -16,7 +16,9 @@ HTile {
backgroundColor: theme.chat.roomPane.listView.member.background
contentOpacity:
model.invited ? theme.chat.roomPane.listView.member.invitedOpacity : 1
model.invited || model.ignored ?
theme.chat.roomPane.listView.member.invitedOpacity :
1
contentItem: ContentRow {
tile: member
@@ -25,12 +27,12 @@ HTile {
id: avatar
clientUserId: chat.userId
userId: model.id
displayName: model.display_name
mxc: model.avatar_url
displayName: model.ignored ? "" : model.display_name
mxc: model.ignored ? "" : model.avatar_url
powerLevel: model.power_level
invited: model.invited
compact: member.compact
presence: model.presence
presence: model.ignored ? "offline" : model.presence
shiftMembershipIconPositionBy:
roomPane.width >= width + 8 * 3 ? -8 : -4
}
@@ -40,11 +42,17 @@ HTile {
spacing: theme.spacing
TitleLabel {
text: model.display_name || model.id
text:
model.ignored ?
model.id :
(model.display_name || model.id)
color:
member.colorName ?
utils.nameColor(
model.display_name || model.id.substring(1)
model.ignored ?
model.id :
(model.display_name || model.id.substring(1))
) :
theme.chat.roomPane.listView.member.name
@@ -54,7 +62,7 @@ HTile {
TitleRightInfoLabel {
id: lastActiveAt
tile: member
visible: presenceTimer.running
visible: ! model.ignored && presenceTimer.running
hideUnderWidth: 130
}
}
@@ -62,7 +70,10 @@ HTile {
SubtitleLabel {
tile: member
color: theme.chat.roomPane.listView.member.subtitle
text: utils.escapeHtml(model.status_msg.trim()) || model.id
text:
model.ignored ?
qsTr("Ignored") :
(utils.escapeHtml(model.status_msg.trim()) || model.id)
}
HoverHandler { id: nameHover }
@@ -72,7 +83,7 @@ HTile {
text:
model.id +
(
model.status_msg.trim() ?
! model.ignored && model.status_msg.trim() ?
" - " + model.status_msg.trim() :
""
)
@@ -80,12 +91,15 @@ HTile {
Timer {
id: presenceTimer
repeat: true
running:
! model.ignored &&
! model.currently_active &&
model.last_active_at > new Date(1)
repeat: true
interval:
new Date() - model.last_active_at < 60000 ? 10000 : 60000
triggeredOnStart: true
onTriggered: lastActiveAt.text = Qt.binding(() =>
utils.formatRelativeTime(new Date() - model.last_active_at)
@@ -101,6 +115,24 @@ HTile {
onTriggered: Clipboard.text = model.id
}
HMenuItemPopupSpawner {
icon.name: model.ignored ? "stop-ignore-user" : "ignore-user"
icon.color:
model.ignored ?
theme.colors.positiveBackground :
theme.colors.negativeBackground
text: model.ignored ? qsTr("Stop ignoring") : qsTr("Ignore")
popup: "Popups/IgnoreUserPopup.qml"
properties: ({
userId: chat.userId,
targetUserId: model.id,
targetDisplayName: model.display_name,
ignore: ! model.ignored
})
}
HMenuItemPopupSpawner {
property bool permissionToKick: false

View File

@@ -0,0 +1,65 @@
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
import "../Base/Buttons"
HFlickableColumnPopup {
id: root
property string userId
property string targetUserId
property string targetDisplayName
property bool ignore
function apply() {
py.callClientCoro(userId, "ignore_user", [targetUserId, ignore])
root.close()
}
page.footer: AutoDirectionLayout {
ApplyButton {
id: ignoreButton
icon.name: root.ignore ? "ignore-user" : "stop-ignore-user"
text: root.ignore ? qsTr("Ignore") : qsTr("Stop ignoring")
onClicked: root.apply()
}
CancelButton {
onClicked: root.close()
}
}
onOpened: ignoreButton.forceActiveFocus()
SummaryLabel {
readonly property string userText:
utils.coloredNameHtml(root.targetDisplayName, root.targetUserId)
textFormat: Text.StyledText
text:
root.ignore ?
qsTr("Ignore %1?").arg(userText) :
qsTr("Stop ignoring %1?").arg(userText)
}
DetailsLabel {
text:
root.ignore ? qsTr(
"You will no longer see their messages and invites.\n\n" +
"Their name, avatar and online status will also be hidden " +
"in room member lists."
) : qsTr(
"You will receive their messages and room invites again.\n\n" +
"Their names, avatar and online status will also become " +
"visible in room member lists.\n\n" +
"After restarting %1, any message or room invite they had " +
"sent while being ignored will become visible."
).arg(Qt.application.displayName)
}
}