Prepare to add priorize and depriorize options.

This commit is contained in:
Black Hat 2018-07-22 12:09:15 +08:00
parent 7837c2d75e
commit d6a7f8ad8b
4 changed files with 40 additions and 8 deletions

View File

@ -39,7 +39,7 @@ Page {
Layout.fillWidth: true
Layout.fillHeight: true
currentRoom: roomListForm.currentIndex != -1 ? roomListModel.roomAt(roomListForm.currentIndex) : null
currentRoom: roomListForm.currentRoom
}
}
}

View File

@ -46,7 +46,7 @@ Item {
spacing: 16
ImageStatus {
Layout.preferredWidth: parent.height
Layout.preferredWidth: height
Layout.fillHeight: true
source: currentRoom && currentRoom.avatarUrl != "" ? "image://mxc/" + currentRoom.avatarUrl : null
displayText: currentRoom ? currentRoom.displayName : ""
@ -86,7 +86,7 @@ Item {
displayMarginBeginning: 40
displayMarginEnd: 40
verticalLayoutDirection: ListView.BottomToTop
maximumFlickVelocity: 1024
maximumFlickVelocity: 2048
spacing: 8
model: MessageEventModel{

View File

@ -11,7 +11,8 @@ import "qrc:/qml/component"
Item {
property alias listModel: roomListProxyModel.sourceModel
property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex)
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".
ColumnLayout {
@ -124,7 +125,7 @@ Item {
opacity: 0.2
}
highlightMoveDuration: 250
maximumFlickVelocity: 1024
maximumFlickVelocity: 2048
currentIndex: -1
@ -134,6 +135,10 @@ Item {
width: parent.width
height: 80
onClicked: listView.currentIndex = index
onPressAndHold: {
roomListMenu.roomIndex = index
roomListMenu.popup()
}
ToolTip.visible: mini && hovered
ToolTip.text: name
@ -196,6 +201,36 @@ 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: "Priorize"
onTriggered: {
roomListMenu.room.removeTag("m.lowpriority")
roomListMenu.room.addTag("m.favourite")
}
}
MenuItem {
text: "Depriorize"
onTriggered: {
console.log("Index:" + roomListMenu.roomIndex)
console.log("Proxy:" + roomListMenu.roomProxyIndex)
console.log("Room:" + roomListMenu.room.displayName)
roomListMenu.room.removeTag("m.favourite")
roomListMenu.room.addTag("m.lowpriority")
}
}
MenuItem {
text: "Direct Chat"
onTriggered: saveDialog.open()
}
}
}
}
}

View File

@ -28,9 +28,6 @@ ApplicationWindow {
Settings.Settings {
id: setting
property alias windowWidth: window.width
property alias windowHeight: window.height
property alias homeserver: matriqueController.homeserver
property alias userID: matriqueController.userID
property alias token: matriqueController.token