Improve appearance of room listing
This ports the room list delegates to Kirigami.BasicListItem leading/trailing for a more consistent appearance with other applications, and adjusts how their context menus look and behave
This commit is contained in:
committed by
Nicolas Fella
parent
a3e1e1d0a4
commit
07f637c854
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1)
|
|||||||
|
|
||||||
project(Neochat)
|
project(Neochat)
|
||||||
|
|
||||||
set(KF5_MIN_VERSION "5.76.0")
|
set(KF5_MIN_VERSION "5.77.0")
|
||||||
set(QT_MIN_VERSION "5.15.0")
|
set(QT_MIN_VERSION "5.15.0")
|
||||||
|
|
||||||
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
|
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
|
||||||
|
|||||||
@@ -16,17 +16,13 @@ Menu {
|
|||||||
property var room
|
property var room
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: i18n("Favourite")
|
text: room.isFavourite ? i18n("Remove from Favourites") : i18n("Add to Favourites")
|
||||||
checkable: true
|
|
||||||
checked: room.isFavourite
|
|
||||||
|
|
||||||
onTriggered: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
|
onTriggered: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: i18n("Deprioritize")
|
text: room.isLowPriority ? i18n("Reprioritize") : i18n("Deprioritize")
|
||||||
checkable: true
|
|
||||||
checked: room.isLowPriority
|
|
||||||
|
|
||||||
onTriggered: room.isLowPriority ? room.removeTag("m.lowpriority") : room.addTag("m.lowpriority", 1.0)
|
onTriggered: room.isLowPriority ? room.removeTag("m.lowpriority") : room.addTag("m.lowpriority", 1.0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,12 +88,11 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: Kirigami.AbstractListItem {
|
delegate: Kirigami.BasicListItem {
|
||||||
id: roomListItem
|
id: roomListItem
|
||||||
property bool itemVisible: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0 || Config.mergeRoomList
|
visible: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0 || Config.mergeRoomList
|
||||||
visible: itemVisible
|
|
||||||
highlighted: roomManager.currentRoom && roomManager.currentRoom.displayName === displayName
|
|
||||||
focus: true
|
focus: true
|
||||||
|
icon: undefined
|
||||||
action: Kirigami.Action {
|
action: Kirigami.Action {
|
||||||
id: enterRoomAction
|
id: enterRoomAction
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
@@ -107,68 +106,22 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label: name ?? ""
|
||||||
contentItem: RowLayout {
|
subtitle: {
|
||||||
id: roomLayout
|
let txt = (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
|
||||||
spacing: Kirigami.Units.largeSpacing
|
if (txt.length) {
|
||||||
width: listView.width
|
return txt
|
||||||
|
|
||||||
TapHandler {
|
|
||||||
acceptedButtons: Qt.RightButton
|
|
||||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
|
||||||
onTapped: roomListContextMenu.createObject(roomLayout, {"room": currentRoom}).popup()
|
|
||||||
}
|
}
|
||||||
|
return " "
|
||||||
|
}
|
||||||
|
|
||||||
TapHandler {
|
leading: Kirigami.Avatar {
|
||||||
onTapped: enterRoomAction.trigger()
|
source: avatar ? "image://mxc/" + avatar : ""
|
||||||
onLongPressed: roomListContextMenu.createObject(roomLayout, {"room": currentRoom}).popup()
|
name: model.name || i18n("No Name")
|
||||||
}
|
implicitWidth: height
|
||||||
|
}
|
||||||
|
|
||||||
Kirigami.Avatar {
|
trailing: RowLayout {
|
||||||
id: roomAvatar
|
|
||||||
property int size: Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing
|
|
||||||
Layout.minimumHeight: size
|
|
||||||
Layout.maximumHeight: size
|
|
||||||
Layout.minimumWidth: size
|
|
||||||
Layout.maximumWidth: size
|
|
||||||
|
|
||||||
source: avatar ? ("image://mxc/" + avatar) : ""
|
|
||||||
name: model.name || i18n("No Name")
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: roomitemcolumn
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
Layout.minimumHeight: Kirigami.Units.gridUnit * 2
|
|
||||||
Layout.maximumHeight: Kirigami.Units.gridUnit * 2
|
|
||||||
Layout.topMargin: Kirigami.Units.smallSpacing
|
|
||||||
Layout.bottomMargin: Kirigami.Units.smallSpacing
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
|
|
||||||
spacing: Kirigami.Units.smallSpacing
|
|
||||||
|
|
||||||
QQC2.Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
text: displayName ?? ""
|
|
||||||
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
|
|
||||||
color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.7)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
text: notificationCount
|
text: notificationCount
|
||||||
visible: notificationCount > 0
|
visible: notificationCount > 0
|
||||||
@@ -182,6 +135,26 @@ Kirigami.ScrollablePage {
|
|||||||
radius: height / 2
|
radius: height / 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QQC2.Button {
|
||||||
|
id: configButton
|
||||||
|
visible: roomListItem.hovered || Kirigami.Settings.isMobile
|
||||||
|
Accessible.name: i18n("Configure room")
|
||||||
|
|
||||||
|
action: Kirigami.Action {
|
||||||
|
id: optionAction
|
||||||
|
icon.name: "configure"
|
||||||
|
onTriggered: {
|
||||||
|
const menu = roomListContextMenu.createObject(page, {"room": currentRoom})
|
||||||
|
configButton.visible = true
|
||||||
|
configButton.down = true
|
||||||
|
menu.closed.connect(function() {
|
||||||
|
configButton.down = undefined
|
||||||
|
configButton.visible = Qt.binding(function() { return roomListItem.hovered || Kirigami.Settings.isMobile })
|
||||||
|
})
|
||||||
|
menu.popup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
|
|||||||
Reference in New Issue
Block a user