Remove context menu Loader && disable highlight resize animation for

ListView(#6).
square-messages
Black Hat 2018-08-05 04:14:45 +08:00
parent e0158daf07
commit 085601f650
2 changed files with 34 additions and 41 deletions

View File

@ -24,10 +24,7 @@ Item {
MouseArea {
anchors.fill: parent
onPressAndHold: {
menuLoader.sourceComponent = menuComponent
menuLoader.item.popup()
}
onPressAndHold: menuComponent.createObject(this)
Component {
id: menuComponent
@ -57,14 +54,12 @@ Item {
text: "Redact"
onTriggered: currentRoom.redactEvent(eventId)
}
Component.onCompleted: popup()
}
}
}
Loader {
id: menuLoader
}
Loader {
id: delegateLoader

View File

@ -112,7 +112,6 @@ Item {
]
}
ListView {
id: listView
width: parent.width
@ -125,6 +124,7 @@ Item {
opacity: 0.2
}
highlightMoveDuration: 250
highlightResizeDuration: 0
currentIndex: -1
@ -135,16 +135,13 @@ Item {
delegate: ItemDelegate {
width: parent.width
height: 80
onClicked: listView.currentIndex = index
onPressAndHold: {
roomListMenu.roomIndex = index
roomListMenu.popup()
}
onPressed: listView.currentIndex = index
onPressAndHold: menuComponent.createObject(this)
ToolTip.visible: mini && hovered
ToolTip.text: name
contentItem: RowLayout {
contentItem: RowLayout {
anchors.fill: parent
anchors.margins: 16
spacing: 16
@ -184,6 +181,33 @@ Item {
}
}
}
Component {
id: menuComponent
Menu {
id: roomListMenu
MenuItem {
text: "Favourite"
checkable: true
checked: currentRoom.isFavourite
onTriggered: currentRoom.isFavourite ? currentRoom.removeTag("m.favourite") : currentRoom.addTag("m.favourite", "1")
}
MenuItem {
text: "Deprioritize"
checkable: true
checked: currentRoom.isLowPriority
onTriggered: currentRoom.isLowPriority ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", "1")
}
MenuSeparator {}
MenuItem {
text: "Leave Room"
onTriggered: matriqueController.forgetRoom(currentRoom.id)
}
Component.onCompleted: popup()
}
}
}
section.property: "category"
@ -202,32 +226,6 @@ Item {
color: Material.theme == Material.Light ? "#dbdbdb" : "#363636"
}
}
Menu {
property int roomIndex: -1
readonly property int roomProxyIndex: roomListProxyModel.mapToSource(roomIndex)
readonly property var room: roomProxyIndex != -1 ? listModel.roomAt(roomProxyIndex) : null
id: roomListMenu
MenuItem {
text: "Favourite"
checkable: true
checked: roomListMenu.room && roomListMenu.room.isFavourite
onTriggered: roomListMenu.room.isFavourite ? roomListMenu.room.removeTag("m.favourite") : roomListMenu.room.addTag("m.favourite", "1")
}
MenuItem {
text: "Deprioritize"
checkable: true
checked: roomListMenu.room && roomListMenu.room.isLowPriority
onTriggered: roomListMenu.room.isLowPriority ? roomListMenu.room.removeTag("m.lowpriority") : roomListMenu.room.addTag("m.lowpriority", "1")
}
MenuSeparator {}
MenuItem {
text: "Leave Room"
onTriggered: matriqueController.forgetRoom(roomListMenu.room.id)
}
}
}
}
}