Remove binding between RoomListForm and RoomForm and reformat code.

This commit allows user to do a series of operations(via press and hold)
on a room without entering the room in RoomForm.
Fixes #14.
This commit is contained in:
Black Hat
2018-08-07 00:17:58 +08:00
parent 9c7defba16
commit f8c89886d2
5 changed files with 26 additions and 19 deletions

View File

@@ -10,7 +10,7 @@ import "qrc:/js/md.js" as Markdown
Item {
id: item
property var currentRoom
property var currentRoom: null
Pane {
anchors.fill: parent

View File

@@ -14,6 +14,7 @@ Item {
readonly property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex)
readonly property var currentRoom: currentIndex != -1 ? listModel.roomAt(currentIndex) : null
readonly property bool mini: setting.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
signal enterRoom()
ColumnLayout {
anchors.fill: parent
@@ -37,7 +38,7 @@ Item {
bottomPadding: 0
anchors.verticalCenter: parent.verticalCenter
background: Item {
background: Item {
Row {
anchors.fill: parent
@@ -137,6 +138,7 @@ Item {
width: parent.width
height: 80
onPressed: listView.currentIndex = index
onClicked: enterRoom()
onPressAndHold: menuComponent.createObject(this)
ToolTip.visible: mini && hovered
@@ -208,6 +210,10 @@ Item {
onTriggered: currentRoom.isLowPriority ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", "1")
}
MenuSeparator {}
MenuItem {
text: "Mark as Read"
onTriggered: currentRoom.markAllMessagesAsRead()
}
MenuItem {
text: "Leave Room"
onTriggered: matriqueController.forgetRoom(currentRoom.id)