Add room context menu with Leave/Decline invite
This commit is contained in:
5
src/qml/Base/HMenu.qml
Normal file
5
src/qml/Base/HMenu.qml
Normal file
@@ -0,0 +1,5 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
|
||||
Menu {
|
||||
}
|
5
src/qml/Base/HMenuItem.qml
Normal file
5
src/qml/Base/HMenuItem.qml
Normal file
@@ -0,0 +1,5 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
|
||||
MenuItem {
|
||||
}
|
@@ -20,6 +20,8 @@ HButton {
|
||||
readonly property alias rightInfo: rightInfo
|
||||
readonly property alias subtitle: subtitle
|
||||
|
||||
property HMenu contextMenu: HMenu {}
|
||||
|
||||
property Item image
|
||||
|
||||
property Item details: HColumnLayout {
|
||||
@@ -75,14 +77,6 @@ HButton {
|
||||
|
||||
onActivated: view.currentIndex = model.index
|
||||
|
||||
onClicked: {
|
||||
view.highlightRangeMode = ListView.NoHighlightRange
|
||||
view.highlightMoveDuration = 0
|
||||
activated()
|
||||
view.highlightRangeMode = ListView.ApplyRange
|
||||
view.highlightMoveDuration = theme.animationDuration
|
||||
}
|
||||
|
||||
|
||||
Timer {
|
||||
interval: 100
|
||||
@@ -91,4 +85,25 @@ HButton {
|
||||
// Component.onCompleted won't work for this
|
||||
onTriggered: if (shouldBeCurrent) view.currentIndex = model.index
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped: {
|
||||
view.highlightRangeMode = ListView.NoHighlightRange
|
||||
view.highlightMoveDuration = 0
|
||||
activated()
|
||||
view.highlightRangeMode = ListView.ApplyRange
|
||||
view.highlightMoveDuration = theme.animationDuration
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: if (contextMenu.count > 0) contextMenu.popup()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onLongPressed: if (contextMenu.count > 0) contextMenu.popup()
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,9 @@ HTileDelegate {
|
||||
Behavior on opacity { HNumberAnimation {} }
|
||||
|
||||
|
||||
readonly property bool invited:
|
||||
model.data.inviter_id && ! model.data.left
|
||||
|
||||
readonly property var eventDate:
|
||||
model.data.last_event ? model.data.last_event.date : null
|
||||
|
||||
@@ -38,9 +41,7 @@ HTileDelegate {
|
||||
svgName: "invite-received"
|
||||
|
||||
visible: Layout.maximumWidth > 0
|
||||
Layout.maximumWidth:
|
||||
model.data.inviter_id && ! model.data.left ?
|
||||
implicitWidth : 0
|
||||
Layout.maximumWidth: invited ? implicitWidth : 0
|
||||
|
||||
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
||||
}
|
||||
@@ -74,4 +75,13 @@ HTileDelegate {
|
||||
ev.sender_name, ev.sender_id
|
||||
) + ": " + ev.inline_content
|
||||
}
|
||||
|
||||
contextMenu: HMenu {
|
||||
HMenuItem {
|
||||
text: invited ? qsTr("&Decline invite") : qsTr("&Leave")
|
||||
onTriggered: py.callClientCoro(
|
||||
model.user_id, "room_leave", [model.data.room_id]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user