Move back to abstrastlistitem for room list

This commit is contained in:
Carl Schwan
2020-12-02 19:18:24 +01:00
parent 722fc15368
commit 9472d5e417

View File

@@ -91,11 +91,11 @@ Kirigami.ScrollablePage {
} }
} }
delegate: Kirigami.SwipeListItem { delegate: Kirigami.AbstractListItem {
id: roomListItem id: roomListItem
property bool itemVisible: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0 || Config.mergeRoomList property bool itemVisible: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0 || Config.mergeRoomList
visible: itemVisible visible: itemVisible
height: itemVisible ? implicitHeight : 0 height: itemVisible ? roomLayout.implicitHeight : 0
highlighted: roomManager.currentRoom && roomManager.currentRoom.name === name highlighted: roomManager.currentRoom && roomManager.currentRoom.name === name
focus: true focus: true
action: Kirigami.Action { action: Kirigami.Action {
@@ -110,90 +110,72 @@ Kirigami.ScrollablePage {
} }
} }
} }
actions: [
Kirigami.Action {
id: optionAction
text: i18n("Configure room") contentItem: RowLayout {
id: roomLayout
spacing: Kirigami.Units.largeSpacing
icon.name: "configure" Kirigami.Avatar {
onTriggered: roomListContextMenu.createObject(roomLayout, {"room": currentRoom}).popup(); id: roomAvatar
property int size: parent.height - Kirigami.Units.smallSpacing * 2;
Layout.minimumHeight: size
Layout.maximumHeight: size
Layout.minimumWidth: size
Layout.maximumWidth: size
source: avatar ? "image://mxc/" + avatar : ""
name: model.name || i18n("No Name")
} }
]
contentItem: Item {
id: listItem
focus: true
implicitHeight: roomLayout.implicitHeight
RowLayout {
id: roomLayout
anchors.fill: parent
spacing: Kirigami.Units.largeSpacing
Kirigami.Avatar { ColumnLayout {
id: roomAvatar id: roomitemcolumn
property int size: Kirigami.Units.gridUnit * 3 - Kirigami.Units.smallSpacing * 2; Layout.fillWidth: true
Layout.minimumHeight: size Layout.fillHeight: true
Layout.maximumHeight: size Layout.alignment: Qt.AlignHCenter
Layout.minimumWidth: size
Layout.maximumWidth: size
source: avatar ? "image://mxc/" + avatar : "" spacing: Kirigami.Units.smallSpacing
name: model.name || i18n("No Name")
Kirigami.Heading {
level: 3
Layout.fillWidth: true
Layout.fillHeight: true
text: name ?? ""
elide: Text.ElideRight
font.bold: unreadCount >= 0 || highlightCount > 0 || notificationCount > 0
wrapMode: Text.NoWrap
} }
ColumnLayout { QQC2.Label {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
spacing: Kirigami.Units.smallSpacing text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
visible: text.length >
Kirigami.Heading { elide: Text.ElideRight
level: 3 wrapMode: Text.NoWrap
Layout.fillWidth: true
Layout.fillHeight: true
text: name ?? ""
elide: Text.ElideRight
font.bold: unreadCount >= 0 || highlightCount > 0 || notificationCount > 0
wrapMode: Text.NoWrap
}
QQC2.Label {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
visible: text.length > 0
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
}
QQC2.Label {
text: notificationCount
visible: notificationCount > 0
padding: Kirigami.Units.smallSpacing
color: highlightCount > 0 ? "white" : Kirigami.Theme.textColor
Layout.minimumWidth: height
horizontalAlignment: Text.AlignHCenter
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.Button
color: highlightCount > 0 ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.backgroundColor
radius: height / 2
}
} }
} }
QQC2.Label {
MouseArea { text: notificationCount
acceptedButtons: Qt.LeftButton | Qt.RightButton visible: notificationCount > 0
anchors.fill: parent padding: Kirigami.Units.smallSpacing
onClicked: { color: highlightCount > 0 ? "white" : Kirigami.Theme.textColor
if (mouse.button == Qt.RightButton) { Layout.minimumWidth: height
roomListContextMenu.createObject(roomLayout, {"room": currentRoom}).popup() horizontalAlignment: Text.AlignHCenter
} else { background: Rectangle {
enterRoomAction.trigger(); Kirigami.Theme.colorSet: Kirigami.Theme.Button
listView.currentIndex = index; color: highlightCount > 0 ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.backgroundColor
} radius: height / 2
}
}
QQC2.Button {
visible: roomListItem.hovered || Kirigami.Settings.isMobile
Accessible.description: i18n("Configure room")
action: Kirigami.Action {
id: optionAction
icon.name: "configure"
onTriggered: roomListContextMenu.createObject(roomLayout, {"room": currentRoom}).popup();
} }
} }
} }