Lazy load room drawer by putting it in a Loader
This commit is contained in:
@@ -26,217 +26,221 @@ Kirigami.OverlayDrawer {
|
|||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||||
contentItem: ColumnLayout {
|
contentItem: Loader {
|
||||||
id: columnLayout
|
active: roomDrawer.drawerOpen
|
||||||
spacing: 0
|
sourceComponent: ColumnLayout {
|
||||||
Kirigami.AbstractApplicationHeader {
|
id: columnLayout
|
||||||
Layout.fillWidth: true
|
anchors.fill: parent
|
||||||
topPadding: Kirigami.Units.smallSpacing / 2;
|
spacing: 0
|
||||||
bottomPadding: Kirigami.Units.smallSpacing / 2;
|
Kirigami.AbstractApplicationHeader {
|
||||||
rightPadding: Kirigami.Units.smallSpacing
|
Layout.fillWidth: true
|
||||||
leftPadding: Kirigami.Units.smallSpacing
|
topPadding: Kirigami.Units.smallSpacing / 2;
|
||||||
|
bottomPadding: Kirigami.Units.smallSpacing / 2;
|
||||||
|
rightPadding: Kirigami.Units.smallSpacing
|
||||||
|
leftPadding: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
ToolButton {
|
ToolButton {
|
||||||
icon.name: "list-add-user"
|
icon.name: "list-add-user"
|
||||||
text: i18n("Invite")
|
text: i18n("Invite")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
applicationWindow().pageStack.layers.push("qrc:/imports/NeoChat/Page/InviteUserPage.qml", {"room": room})
|
applicationWindow().pageStack.layers.push("qrc:/imports/NeoChat/Page/InviteUserPage.qml", {"room": room})
|
||||||
roomDrawer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Item {
|
|
||||||
// HACK otherwise rating item is not right aligned
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolButton {
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
icon.name: room && room.isFavourite ? "rating" : "rating-unrated"
|
|
||||||
checkable: true
|
|
||||||
checked: room && room.isFavourite
|
|
||||||
onClicked: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
|
|
||||||
ToolTip {
|
|
||||||
text: room && room.isFavourite ? i18n("Remove room from favorites") : i18n("Make room favorite")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ToolButton {
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
icon.name: 'settings-configure'
|
|
||||||
onClicked: {
|
|
||||||
roomSettingDialog.createObject(ApplicationWindow.overlay, {"room": room}).open()
|
|
||||||
if (!wideScreen) {
|
|
||||||
roomDrawer.close();
|
roomDrawer.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Item {
|
||||||
ToolTip {
|
// HACK otherwise rating item is not right aligned
|
||||||
text: i18n("Room settings")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Control {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
padding: Kirigami.Units.largeSpacing
|
|
||||||
contentItem: ColumnLayout {
|
|
||||||
id: infoLayout
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Kirigami.Heading {
|
|
||||||
text: i18n("Room information")
|
|
||||||
level: 3
|
|
||||||
}
|
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.margins: Kirigami.Units.largeSpacing
|
|
||||||
|
|
||||||
spacing: Kirigami.Units.largeSpacing
|
|
||||||
|
|
||||||
Kirigami.Avatar {
|
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 3.5
|
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 3.5
|
|
||||||
|
|
||||||
name: room ? room.name : i18n("No name")
|
|
||||||
source: room ? ("image://mxc/" + room.avatarMediaId) : ""
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
Kirigami.Heading {
|
|
||||||
Layout.maximumWidth: Kirigami.Units.gridUnit * 9
|
|
||||||
Layout.fillWidth: true
|
|
||||||
level: 1
|
|
||||||
font.bold: true
|
|
||||||
wrapMode: Label.Wrap
|
|
||||||
text: room ? room.displayName : i18n("No name")
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: room && room.canonicalAlias ? room.canonicalAlias : i18n("No Canonical Alias")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextEdit {
|
|
||||||
Layout.maximumWidth: Kirigami.Units.gridUnit * 13
|
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 13
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: room && room.topic ? room.topic.replace(replaceLinks, "<a href=\"$1\">$1</a>") : i18n("No Topic")
|
|
||||||
readonly property var replaceLinks: /\(https:\/\/[^ ]*\)/
|
|
||||||
textFormat: TextEdit.MarkdownText
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
selectByMouse: true
|
|
||||||
color: Kirigami.Theme.textColor
|
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
|
||||||
readOnly: true
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
acceptedButtons: Qt.NoButton
|
|
||||||
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Kirigami.ListSectionHeader {
|
|
||||||
label: i18n("Members")
|
|
||||||
activeFocusOnTab: false
|
|
||||||
Label {
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
text: room ? i18np("%1 Member", "%1 Members", room.totalMemberCount) : i18n("No Member Count")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollView {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: userListView
|
|
||||||
clip: true
|
|
||||||
headerPositioning: ListView.OverlayHeader
|
|
||||||
boundsBehavior: Flickable.DragOverBounds
|
|
||||||
activeFocusOnTab: true
|
|
||||||
|
|
||||||
header: Pane {
|
|
||||||
padding: Kirigami.Units.smallSpacing
|
|
||||||
implicitWidth: parent.width
|
|
||||||
z: 2
|
|
||||||
contentItem: Kirigami.SearchField {
|
|
||||||
id: userListSearchField
|
|
||||||
onTextChanged: sortedMessageEventModel.filterString = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
model: KSortFilterProxyModel {
|
|
||||||
id: sortedMessageEventModel
|
|
||||||
|
|
||||||
sourceModel: UserListModel {
|
|
||||||
room: roomDrawer.room
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sortRole: "perm"
|
ToolButton {
|
||||||
filterRole: "name"
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
icon.name: room && room.isFavourite ? "rating" : "rating-unrated"
|
||||||
|
checkable: true
|
||||||
delegate: Kirigami.AbstractListItem {
|
checked: room && room.isFavourite
|
||||||
width: userListView.width
|
onClicked: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
|
||||||
implicitHeight: Kirigami.Units.gridUnit * 2
|
ToolTip {
|
||||||
z: 1
|
text: room && room.isFavourite ? i18n("Remove room from favorites") : i18n("Make room favorite")
|
||||||
|
|
||||||
contentItem: RowLayout {
|
|
||||||
Kirigami.Avatar {
|
|
||||||
Layout.preferredWidth: height
|
|
||||||
Layout.fillHeight: true
|
|
||||||
visible: Config.showAvatarInTimeline
|
|
||||||
|
|
||||||
source: avatar ? ("image://mxc/" + avatar) : ""
|
|
||||||
name: name
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Label {
|
ToolButton {
|
||||||
Layout.fillWidth: true
|
Layout.alignment: Qt.AlignRight
|
||||||
|
icon.name: 'settings-configure'
|
||||||
text: name
|
onClicked: {
|
||||||
textFormat: Text.PlainText
|
roomSettingDialog.createObject(ApplicationWindow.overlay, {"room": room}).open()
|
||||||
elide: Text.ElideRight
|
if (!wideScreen) {
|
||||||
wrapMode: Text.NoWrap
|
roomDrawer.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Label {
|
|
||||||
visible: perm != UserType.Member
|
ToolTip {
|
||||||
|
text: i18n("Room settings")
|
||||||
text: {
|
}
|
||||||
if (perm == UserType.Owner) {
|
}
|
||||||
return i18n("Owner")
|
}
|
||||||
}
|
}
|
||||||
if (perm == UserType.Admin) {
|
|
||||||
return i18n("Admin")
|
Control {
|
||||||
}
|
Layout.fillWidth: true
|
||||||
if (perm == UserType.Moderator) {
|
padding: Kirigami.Units.largeSpacing
|
||||||
return i18n("Mod")
|
contentItem: ColumnLayout {
|
||||||
}
|
id: infoLayout
|
||||||
if (perm == UserType.Muted) {
|
Layout.fillWidth: true
|
||||||
return i18n("Muted")
|
Kirigami.Heading {
|
||||||
}
|
text: i18n("Room information")
|
||||||
return ""
|
level: 3
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.margins: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
Kirigami.Avatar {
|
||||||
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 3.5
|
||||||
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 3.5
|
||||||
|
|
||||||
|
name: room ? room.name : i18n("No name")
|
||||||
|
source: room ? ("image://mxc/" + room.avatarMediaId) : ""
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
Kirigami.Heading {
|
||||||
|
Layout.maximumWidth: Kirigami.Units.gridUnit * 9
|
||||||
|
Layout.fillWidth: true
|
||||||
|
level: 1
|
||||||
|
font.bold: true
|
||||||
|
wrapMode: Label.Wrap
|
||||||
|
text: room ? room.displayName : i18n("No name")
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: room && room.canonicalAlias ? room.canonicalAlias : i18n("No Canonical Alias")
|
||||||
}
|
}
|
||||||
color: Kirigami.Theme.disabledTextColor
|
|
||||||
font.pixelSize: 12
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
action: Kirigami.Action {
|
TextEdit {
|
||||||
onTriggered: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": room, "user": user, "displayName": name, "avatarMediaId": avatar}).open()
|
Layout.maximumWidth: Kirigami.Units.gridUnit * 13
|
||||||
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 13
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: room && room.topic ? room.topic.replace(replaceLinks, "<a href=\"$1\">$1</a>") : i18n("No Topic")
|
||||||
|
readonly property var replaceLinks: /\(https:\/\/[^ ]*\)/
|
||||||
|
textFormat: TextEdit.MarkdownText
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
selectByMouse: true
|
||||||
|
color: Kirigami.Theme.textColor
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
|
readOnly: true
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Kirigami.ListSectionHeader {
|
||||||
|
label: i18n("Members")
|
||||||
|
activeFocusOnTab: false
|
||||||
|
Label {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text: room ? i18np("%1 Member", "%1 Members", room.totalMemberCount) : i18n("No Member Count")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollView {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: userListView
|
||||||
|
clip: true
|
||||||
|
headerPositioning: ListView.OverlayHeader
|
||||||
|
boundsBehavior: Flickable.DragOverBounds
|
||||||
|
activeFocusOnTab: true
|
||||||
|
|
||||||
|
header: Pane {
|
||||||
|
padding: Kirigami.Units.smallSpacing
|
||||||
|
implicitWidth: parent.width
|
||||||
|
z: 2
|
||||||
|
contentItem: Kirigami.SearchField {
|
||||||
|
id: userListSearchField
|
||||||
|
onTextChanged: sortedMessageEventModel.filterString = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model: KSortFilterProxyModel {
|
||||||
|
id: sortedMessageEventModel
|
||||||
|
|
||||||
|
sourceModel: UserListModel {
|
||||||
|
room: roomDrawer.room
|
||||||
|
}
|
||||||
|
|
||||||
|
sortRole: "perm"
|
||||||
|
filterRole: "name"
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Kirigami.AbstractListItem {
|
||||||
|
width: userListView.width
|
||||||
|
implicitHeight: Kirigami.Units.gridUnit * 2
|
||||||
|
z: 1
|
||||||
|
|
||||||
|
contentItem: RowLayout {
|
||||||
|
Kirigami.Avatar {
|
||||||
|
Layout.preferredWidth: height
|
||||||
|
Layout.fillHeight: true
|
||||||
|
visible: Config.showAvatarInTimeline
|
||||||
|
|
||||||
|
source: avatar ? ("image://mxc/" + avatar) : ""
|
||||||
|
name: name
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
text: name
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
elide: Text.ElideRight
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
visible: perm != UserType.Member
|
||||||
|
|
||||||
|
text: {
|
||||||
|
if (perm == UserType.Owner) {
|
||||||
|
return i18n("Owner")
|
||||||
|
}
|
||||||
|
if (perm == UserType.Admin) {
|
||||||
|
return i18n("Admin")
|
||||||
|
}
|
||||||
|
if (perm == UserType.Moderator) {
|
||||||
|
return i18n("Mod")
|
||||||
|
}
|
||||||
|
if (perm == UserType.Muted) {
|
||||||
|
return i18n("Muted")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
color: Kirigami.Theme.disabledTextColor
|
||||||
|
font.pixelSize: 12
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
action: Kirigami.Action {
|
||||||
|
onTriggered: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": room, "user": user, "displayName": name, "avatarMediaId": avatar}).open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user