Redesign room list
Use KirigamiAddons.Delegated.RoundedItemDelegate
This commit is contained in:
@@ -7,13 +7,14 @@ import QtQuick.Layouts 1.15
|
||||
import QtQml.Models 2.15
|
||||
|
||||
import org.kde.kirigami 2.15 as Kirigami
|
||||
import org.kde.kirigamiaddons.delegates 1.0 as Delegates
|
||||
import org.kde.kitemmodels 1.0
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
import './' as RoomList
|
||||
|
||||
Kirigami.BasicListItem {
|
||||
Delegates.RoundedItemDelegate {
|
||||
id: root
|
||||
|
||||
required property int index
|
||||
@@ -29,23 +30,9 @@ Kirigami.BasicListItem {
|
||||
|
||||
readonly property bool hasNotifications: notificationCount > 0
|
||||
|
||||
topPadding: Kirigami.Units.largeSpacing
|
||||
bottomPadding: Kirigami.Units.largeSpacing
|
||||
height: visible ? implicitHeight : 0
|
||||
|
||||
visible: root.categoryVisible || root.filterText.length > 0 || Config.mergeRoomList
|
||||
highlighted: ListView.view.currentIndex === index
|
||||
focus: true
|
||||
icon: undefined
|
||||
@BASICLISTITEM_BOLD@: root.hasNotifications
|
||||
|
||||
label: root.displayName
|
||||
labelItem.textFormat: Text.PlainText
|
||||
|
||||
subtitle: root.subtitleText
|
||||
subtitleItem {
|
||||
textFormat: Text.PlainText
|
||||
visible: !Config.compactRoomList
|
||||
}
|
||||
|
||||
onClicked: RoomManager.enterRoom(root.currentRoom)
|
||||
onPressAndHold: createRoomListContextMenu()
|
||||
@@ -59,18 +46,54 @@ Kirigami.BasicListItem {
|
||||
onTapped: createRoomListContextMenu()
|
||||
}
|
||||
|
||||
leading: Kirigami.Avatar {
|
||||
source: root.avatar ? "image://mxc/" + root.avatar : ""
|
||||
name: root.displayName
|
||||
implicitWidth: visible ? height : 0
|
||||
visible: Config.showAvatarInRoomDrawer
|
||||
sourceSize {
|
||||
width: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing * 2
|
||||
height: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing * 2
|
||||
}
|
||||
}
|
||||
contentItem: RowLayout {
|
||||
Kirigami.Avatar {
|
||||
source: root.avatar ? "image://mxc/" + root.avatar : ""
|
||||
name: root.displayName
|
||||
implicitWidth: visible ? height : 0
|
||||
implicitHeight: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
|
||||
visible: Config.showAvatarInRoomDrawer
|
||||
sourceSize {
|
||||
width: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
|
||||
height: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
|
||||
}
|
||||
|
||||
Layout.topMargin: Kirigami.Units.largeSpacing / 2
|
||||
Layout.bottomMargin: Kirigami.Units.largeSpacing / 2
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
QQC2.Label {
|
||||
id: label
|
||||
|
||||
text: root.displayName
|
||||
elide: Text.ElideRight
|
||||
font.weight: root.hasNotifications ? Font.Bold : Font.Normal
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: subtitle.visible ? Qt.AlignLeft | Qt.AlignBottom : Qt.AlignLeft | Qt.AlignVCenter
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
id: subtitle
|
||||
|
||||
text: root.subtitleText
|
||||
elide: Text.ElideRight
|
||||
font: Kirigami.Theme.smallFont
|
||||
opacity: root.hasNotifications ? 0.9 : 0.7
|
||||
visible: !Config.compactRoomList
|
||||
textFormat: Text.PlainText
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: visible ? Qt.AlignLeft | Qt.AlignTop : Qt.AlignLeft | Qt.AlignVCenter
|
||||
}
|
||||
}
|
||||
|
||||
trailing: RowLayout {
|
||||
Kirigami.Icon {
|
||||
source: "notifications-disabled"
|
||||
enabled: false
|
||||
@@ -80,10 +103,12 @@ Kirigami.BasicListItem {
|
||||
Accessible.name: i18n("Muted room")
|
||||
Layout.rightMargin: Kirigami.Units.smallSpacing
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
id: notificationCountLabel
|
||||
text: notificationCount
|
||||
visible: hasNotifications
|
||||
|
||||
text: root.notificationCount
|
||||
visible: root.hasNotifications
|
||||
color: Kirigami.Theme.textColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
background: Rectangle {
|
||||
@@ -103,6 +128,7 @@ Kirigami.BasicListItem {
|
||||
text: notificationCountLabel.text
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
id: configButton
|
||||
visible: root.hovered && !Kirigami.Settings.isMobile && !Config.compactRoomList
|
||||
|
||||
@@ -7,6 +7,7 @@ import QtQuick.Controls 2.15 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kirigami 2.20 as Kirigami
|
||||
import org.kde.kirigamiaddons.delegates 1.0 as Delegates
|
||||
|
||||
import '.'
|
||||
import org.kde.neochat 1.0
|
||||
@@ -15,12 +16,8 @@ QQC2.Control {
|
||||
id: root
|
||||
|
||||
readonly property real pinnedWidth: Kirigami.Units.gridUnit * 6
|
||||
readonly property int buttonDisplayMode: Kirigami.NavigationTabButton.IconOnly
|
||||
property bool drawerEnabled: true
|
||||
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
||||
Kirigami.Theme.inherit: false
|
||||
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
topPadding: 0
|
||||
@@ -28,12 +25,6 @@ QQC2.Control {
|
||||
|
||||
property string selectedSpaceId
|
||||
|
||||
background: Rectangle {
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
Kirigami.Theme.inherit: false
|
||||
}
|
||||
|
||||
contentItem: Loader {
|
||||
id: sidebarColumn
|
||||
active: root.drawerEnabled
|
||||
@@ -56,17 +47,23 @@ QQC2.Control {
|
||||
width: scrollView.width
|
||||
spacing: 0
|
||||
|
||||
Kirigami.NavigationTabButton {
|
||||
AvatarTabButton {
|
||||
id: allRoomButton
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width
|
||||
display: Kirigami.NavigationTabButton.IconOnly
|
||||
Layout.preferredHeight: width - Kirigami.Units.smallSpacing
|
||||
Layout.maximumHeight: width - Kirigami.Units.smallSpacing
|
||||
Layout.topMargin: Kirigami.Units.smallSpacing
|
||||
|
||||
text: i18n("All Rooms")
|
||||
icon.name: "globe"
|
||||
checked: true
|
||||
source: "globe"
|
||||
|
||||
contentItem: Kirigami.Icon {
|
||||
source: "globe"
|
||||
}
|
||||
|
||||
checked: root.selectedSpaceId === ""
|
||||
onClicked: root.selectedSpaceId = ""
|
||||
QQC2.ToolTip.visible: hovered
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
}
|
||||
|
||||
Repeater {
|
||||
@@ -79,23 +76,23 @@ QQC2.Control {
|
||||
Component.onCompleted: root.enabled = count > 0
|
||||
|
||||
delegate: AvatarTabButton {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width
|
||||
display: Kirigami.NavigationTabButton.IconOnly
|
||||
text: model.displayName
|
||||
source: model.avatar ? ("image://mxc/" + model.avatar) : ""
|
||||
name: model.displayName
|
||||
onClicked: root.selectedSpaceId = model.id
|
||||
QQC2.ToolTip.visible: hovered
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
onPressAndHold: root.createContextMenu(model.currentRoom)
|
||||
id: spaceDelegate
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
acceptedDevices: PointerDevice.Mouse
|
||||
onTapped: root.createContextMenu(model.currentRoom)
|
||||
}
|
||||
required property string displayName
|
||||
required property string avatar
|
||||
required property string roomId
|
||||
required property var currentRoom
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width - Kirigami.Units.smallSpacing
|
||||
Layout.maximumHeight: width - Kirigami.Units.smallSpacing
|
||||
|
||||
text: displayName
|
||||
source: avatar ? ("image://mxc/" + avatar) : ""
|
||||
|
||||
onClicked: root.selectedSpaceId = roomId
|
||||
checked: root.selectedSpaceId === roomId
|
||||
onContextMenuRequested: root.createContextMenu(currentRoom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user