Add a mobile oriented context menu for the room list

It works similarly as in the timeline with a bottom based drawer on
mobile and a normal context menu on desktop

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan
2021-12-12 17:27:14 +01:00
parent 738270f513
commit 6e1c07047e
2 changed files with 139 additions and 39 deletions

View File

@@ -237,12 +237,22 @@ Kirigami.ScrollablePage {
bold: unreadCount > 0
label: name ?? ""
subtitle: {
let txt = (lastEvent.length === 0 ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm, " ")
const txt = (lastEvent.length === 0 ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm, " ")
if (txt.length) {
return txt
}
return " "
}
onPressAndHold: {
const menu = roomListContextMenu.createObject(page, {"room": currentRoom})
configButton.visible = true
configButton.down = true
menu.closed.connect(function() {
configButton.down = undefined
configButton.visible = Qt.binding(function() { return roomListItem.hovered || Kirigami.Settings.isMobile })
})
menu.open()
}
leading: Kirigami.Avatar {
source: avatar ? "image://mxc/" + avatar : ""
@@ -269,7 +279,7 @@ Kirigami.ScrollablePage {
}
QQC2.Button {
id: configButton
visible: roomListItem.hovered || Kirigami.Settings.isMobile
visible: roomListItem.hovered
Accessible.name: i18n("Configure room")
action: Kirigami.Action {
@@ -283,7 +293,7 @@ Kirigami.ScrollablePage {
configButton.down = undefined
configButton.visible = Qt.binding(function() { return roomListItem.hovered || Kirigami.Settings.isMobile })
})
menu.popup()
menu.open()
}
}
}