Highlighting and cleanup for MemberDelegate

This commit is contained in:
miruka 2019-07-12 18:15:06 -04:00
parent cc937b38c4
commit 338986f022
5 changed files with 35 additions and 34 deletions

View File

@ -5,35 +5,42 @@ import QtQuick 2.7
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "../../Base" import "../../Base"
MouseArea { HHighlightRectangle {
id: memberDelegate id: memberDelegate
width: memberList.width width: memberList.width
height: childrenRect.height height: childrenRect.height
property var memberInfo: users.find(model.userId) property var memberInfo: users.find(model.userId)
HRowLayout { Row {
width: parent.width width: parent.width - leftPadding * 2
spacing: memberList.spacing padding: roomSidePane.currentSpacing / 2
leftPadding: roomSidePane.currentSpacing
rightPadding: 0
HUserAvatar { HRowLayout {
id: avatar width: parent.width
userId: model.userId spacing: roomSidePane.currentSpacing
}
HColumnLayout { HUserAvatar {
Layout.fillWidth: true id: avatar
Layout.maximumWidth: userId: model.userId
parent.width - parent.totalSpacing - avatar.width }
HLabel { HColumnLayout {
id: memberName Layout.fillWidth: true
text: memberInfo.displayName || model.userId Layout.maximumWidth:
elide: Text.ElideRight parent.width - parent.totalSpacing - avatar.width
maximumLineCount: 1
verticalAlignment: Qt.AlignVCenter
Layout.maximumWidth: parent.width HLabel {
id: memberName
text: memberInfo.displayName || model.userId
elide: Text.ElideRight
maximumLineCount: 1
verticalAlignment: Qt.AlignVCenter
Layout.maximumWidth: parent.width
}
} }
} }
} }

View File

@ -8,19 +8,9 @@ import "../../Base"
import "../../utils.js" as Utils import "../../utils.js" as Utils
HColumnLayout { HColumnLayout {
property bool collapsed: false
property int normalSpacing: collapsed ? 0 : 8
Behavior on normalSpacing { HNumberAnimation {} }
HListView { HListView {
id: memberList id: memberList
bottomMargin: currentSpacing
spacing: normalSpacing
topMargin: normalSpacing
bottomMargin: normalSpacing
Layout.leftMargin: normalSpacing
Layout.rightMargin: normalSpacing
model: HListModel { model: HListModel {
sourceModel: chatPage.roomInfo.members sourceModel: chatPage.roomInfo.members

View File

@ -11,8 +11,12 @@ HRectangle {
property bool collapsed: false property bool collapsed: false
property var activeView: null property var activeView: null
property int normalSpacing: 8
readonly property int currentSpacing: collapsed ? 0 : normalSpacing
Behavior on normalSpacing { HNumberAnimation {} }
MembersView { MembersView {
anchors.fill: parent anchors.fill: parent
collapsed: parent.collapsed
} }
} }

View File

@ -18,7 +18,7 @@ HHighlightRectangle {
} }
Row { Row {
width: parent.width - sidePane.currentSpacing * 2 width: parent.width - leftPadding * 2
padding: sidePane.currentSpacing / 2 padding: sidePane.currentSpacing / 2
leftPadding: sidePane.currentSpacing leftPadding: sidePane.currentSpacing
rightPadding: 0 rightPadding: 0

View File

@ -11,9 +11,9 @@ HRectangle {
// Avoid artifacts when collapsed // Avoid artifacts when collapsed
clip: true clip: true
property int normalSpacing: 8
property int currentSpacing: collapsed ? 0 : normalSpacing
property bool collapsed: false property bool collapsed: false
property int normalSpacing: 8
readonly property int currentSpacing: collapsed ? 0 : normalSpacing
HColumnLayout { HColumnLayout {
anchors.fill: parent anchors.fill: parent