Improve Room Drawer

This fix the bug of it not getting the right data and improve the look
signically.
This commit is contained in:
Carl Schwan
2020-11-16 14:27:44 +01:00
parent 6db8354727
commit eba4d874df
2 changed files with 161 additions and 159 deletions

View File

@@ -19,16 +19,20 @@ import NeoChat.Setting 1.0
import org.kde.neochat 1.0 import org.kde.neochat 1.0
Kirigami.OverlayDrawer { Kirigami.OverlayDrawer {
id: roomDrawer
property var room property var room
id: roomDrawer
enabled: true enabled: true
edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge
padding: 0 topPadding: 0
leftPadding: 0
rightPadding: 0
width: 400
implicitWidth: 400
contentItem: ColumnLayout { contentItem: ColumnLayout {
implicitWidth: Kirigami.Units.gridUnit * 15 // TODO FIXME implicitWidth: Kirigami.Units.gridUnit * 20
Component { Component {
id: fullScreenImage id: fullScreenImage
@@ -36,38 +40,56 @@ Kirigami.OverlayDrawer {
FullScreenImage {} FullScreenImage {}
} }
ToolBar {
Layout.fillWidth: true
implicitHeight: infoLayout.implicitHeight
bottomPadding: Kirigami.Units.largeSpacing
contentItem: ColumnLayout {
id: infoLayout
Layout.fillWidth: true
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: Kirigami.Units.largeSpacing
spacing: 16 spacing: Kirigami.Units.largeSpacing
Kirigami.Avatar { Kirigami.Avatar {
Layout.preferredWidth: 72 Layout.preferredWidth: Kirigami.Units.gridUnit * 3.5
Layout.preferredHeight: 72 Layout.preferredHeight: Kirigami.Units.gridUnit * 3.5
name: room ? room.displayName : "No name" name: room ? room.displayName : i18n("No name")
source: room ? "image://mxc/" + room.avatarMediaId : null source: room ? "image://mxc/" + room.avatarMediaId : undefined
} }
ColumnLayout { ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 0
Label { Kirigami.Heading {
Layout.fillWidth: true Layout.fillWidth: true
level: 1
font.pixelSize: 18
font.bold: true font.bold: true
wrapMode: Label.Wrap wrapMode: Label.Wrap
text: room ? room.displayName : "No Name" text: room ? room.displayName : i18n("No name")
color: MPalette.foreground
} }
RowLayout {
Layout.fillWidth: true
Label { Label {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Label.Wrap wrapMode: Label.Wrap
text: room ? room.totalMemberCount + " Members" : "No Member Count" text: room ? i18np("%1 Member", "%1 Members", room.totalMemberCount) : i18n("No Member Count")
color: MPalette.lighter color: Kirigami.Theme.disabledTextColor
}
Button {
icon.name: 'settings-configure'
text: i18n("Room setting")
onClicked: {
roomSettingDialog.createObject(ApplicationWindow.overlay, {"room": room}).open()
roomDrawer.close();
}
}
} }
} }
} }
@@ -76,36 +98,25 @@ Kirigami.OverlayDrawer {
Layout.fillWidth: true Layout.fillWidth: true
} }
Control { Kirigami.FormLayout {
Layout.fillWidth: true Layout.fillWidth: true
contentItem: Kirigami.FormLayout {
Label { Label {
Kirigami.FormData.label: "Main Alias" Kirigami.FormData.label: i18n("Main Alias")
text: room && room.canonicalAlias ? room.canonicalAlias : "No Canonical Alias" text: room && room.canonicalAlias ? room.canonicalAlias :i18n("No Canonical Alias")
} }
Label { Label {
Kirigami.FormData.label: "Topic" Kirigami.FormData.label: i18n("Topic")
text: room && room.topic ? room.topic : "No Topic" text: room && room.topic ? room.topic : i18n("No Topic")
elide: Text.ElideRight
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
} }
background: AutoMouseArea {
onPrimaryClicked: roomSettingDialog.createObject(ApplicationWindow.overlay, {"room": room}).open()
}
}
Kirigami.Separator {
Layout.fillWidth: true
}
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 8 spacing: 8
Kirigami.Icon { Kirigami.Icon {
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
source: "user-others" source: "user-others"
} }
@@ -113,41 +124,37 @@ Kirigami.OverlayDrawer {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Label.Wrap wrapMode: Label.Wrap
text: room ? room.totalMemberCount + " Members" : "No Member Count" text: room ? i18np("%1 Member", "%1 Members", room.totalMemberCount) : i18n("No Member Count")
} }
ToolButton { ToolButton {
Layout.preferredWidth: Kirigami.Units.gridUnit
Layout.preferredHeight: Kirigami.Units.gridUnit
icon.name: "list-add-user" icon.name: "list-add-user"
text: i18n("Invite")
onClicked: inviteUserDialog.createObject(ApplicationWindow.overlay, {"room": room}).open() onClicked: inviteUserDialog.createObject(ApplicationWindow.overlay, {"room": room}).open()
} }
} }
}
}
AutoListView { ScrollView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
ListView {
id: userListView id: userListView
clip: true clip: true
headerPositioning: ListView.OverlayHeader
boundsBehavior: Flickable.DragOverBounds boundsBehavior: Flickable.DragOverBounds
model: UserListModel { model: UserListModel {
room: roomDrawer.room room: roomDrawer.room
} }
delegate: Item { delegate: Kirigami.AbstractListItem {
width: userListView.width width: userListView.width
height: 48 implicitHeight: Kirigami.Units.gridUnit * 2
RowLayout {
anchors.fill: parent
anchors.margins: 8
spacing: 12
contentItem: RowLayout {
Kirigami.Avatar { Kirigami.Avatar {
Layout.preferredWidth: height Layout.preferredWidth: height
Layout.fillHeight: true Layout.fillHeight: true
@@ -160,7 +167,6 @@ Kirigami.OverlayDrawer {
Layout.fillWidth: true Layout.fillWidth: true
text: name text: name
color: MPalette.foreground
textFormat: Text.PlainText textFormat: Text.PlainText
elide: Text.ElideRight elide: Text.ElideRight
wrapMode: Text.NoWrap wrapMode: Text.NoWrap
@@ -171,34 +177,31 @@ Kirigami.OverlayDrawer {
text: { text: {
if (perm == UserType.Owner) { if (perm == UserType.Owner) {
return "Owner" return i18n("Owner")
} }
if (perm == UserType.Admin) { if (perm == UserType.Admin) {
return "Admin" return i18n("Admin")
} }
if (perm == UserType.Moderator) { if (perm == UserType.Moderator) {
return "Mod" return i18n("Mod")
} }
if (perm == UserType.Muted) { if (perm == UserType.Muted) {
return "Muted" return i18n("Muted")
} }
return "" return ""
} }
color: perm == UserType.Muted ? MPalette.lighter : MPalette.accent color: perm == UserType.Muted ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
font.pixelSize: 12 font.pixelSize: 12
textFormat: Text.PlainText textFormat: Text.PlainText
wrapMode: Text.NoWrap wrapMode: Text.NoWrap
} }
} }
RippleEffect { action: Kirigami.Action {
anchors.fill: parent onTriggered: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": room, "user": user}).open()
}
onPrimaryClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": room, "user": user}).open()
} }
} }
ScrollBar.vertical: ScrollBar {}
} }
} }

View File

@@ -15,7 +15,6 @@ import NeoChat.Component 1.0
import NeoChat.Panel 1.0 import NeoChat.Panel 1.0
import NeoChat.Dialog 1.0 import NeoChat.Dialog 1.0
import NeoChat.Page 1.0 import NeoChat.Page 1.0
import NeoChat.Page 1.0
Kirigami.ApplicationWindow { Kirigami.ApplicationWindow {
id: root id: root
@@ -24,7 +23,7 @@ Kirigami.ApplicationWindow {
/** /**
* Manage opening and close rooms * Manage opening and close rooms
*/ */
Item { QtObject {
id: roomManager id: roomManager
property var currentRoom: null property var currentRoom: null
@@ -43,18 +42,12 @@ Kirigami.ApplicationWindow {
pageStack.push(roomPage, { 'currentRoom': room, }); pageStack.push(roomPage, { 'currentRoom': room, });
currentRoom = room; currentRoom = room;
} }
Component {
id: roomPage
RoomPage {}
}
} }
contextDrawer: RoomDrawer { contextDrawer: RoomDrawer {
id: contextDrawer id: contextDrawer
enabled: root.currentRoomm !== null enabled: roomManager.hasOpenRoom
room: root.currentRoom room: roomManager.currentRoom
handleVisible: enabled && (pageStack.currentItem instanceof RoomPage) handleVisible: enabled && (pageStack.currentItem instanceof RoomPage)
} }
@@ -130,4 +123,10 @@ Kirigami.ApplicationWindow {
connection: Controller.activeConnection connection: Controller.activeConnection
} }
Component {
id: roomPage
RoomPage {}
}
} }