Remove context menu Loader && disable highlight resize animation for

ListView(#6).
This commit is contained in:
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 { MouseArea {
anchors.fill: parent anchors.fill: parent
onPressAndHold: { onPressAndHold: menuComponent.createObject(this)
menuLoader.sourceComponent = menuComponent
menuLoader.item.popup()
}
Component { Component {
id: menuComponent id: menuComponent
@ -57,14 +54,12 @@ Item {
text: "Redact" text: "Redact"
onTriggered: currentRoom.redactEvent(eventId) onTriggered: currentRoom.redactEvent(eventId)
} }
Component.onCompleted: popup()
} }
} }
} }
Loader {
id: menuLoader
}
Loader { Loader {
id: delegateLoader id: delegateLoader

View File

@ -112,7 +112,6 @@ Item {
] ]
} }
ListView { ListView {
id: listView id: listView
width: parent.width width: parent.width
@ -125,6 +124,7 @@ Item {
opacity: 0.2 opacity: 0.2
} }
highlightMoveDuration: 250 highlightMoveDuration: 250
highlightResizeDuration: 0
currentIndex: -1 currentIndex: -1
@ -135,16 +135,13 @@ Item {
delegate: ItemDelegate { delegate: ItemDelegate {
width: parent.width width: parent.width
height: 80 height: 80
onClicked: listView.currentIndex = index onPressed: listView.currentIndex = index
onPressAndHold: { onPressAndHold: menuComponent.createObject(this)
roomListMenu.roomIndex = index
roomListMenu.popup()
}
ToolTip.visible: mini && hovered ToolTip.visible: mini && hovered
ToolTip.text: name ToolTip.text: name
contentItem: RowLayout { contentItem: RowLayout {
anchors.fill: parent anchors.fill: parent
anchors.margins: 16 anchors.margins: 16
spacing: 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" section.property: "category"
@ -202,32 +226,6 @@ Item {
color: Material.theme == Material.Light ? "#dbdbdb" : "#363636" 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)
}
}
} }
} }
} }