Make the whole right sidebar scrollable

The sidebar grew a lot and now contains some tools. This makes the space
left for the room members very small. Particuliary on mobile.

So make the whole sidebar contained inside the ScrollView

This also refactor a few things (e.g. use a plain ToolBar for the header)
This commit is contained in:
Carl Schwan
2023-06-28 14:11:07 +02:00
committed by Tobias Fella
parent 213aaf3ac4
commit b1c42c3d3d
3 changed files with 157 additions and 162 deletions

View File

@@ -48,7 +48,7 @@ ColumnLayout {
room: room, room: room,
user: room.getUser(room.directChatRemoteUser.id), user: room.getUser(room.directChatRemoteUser.id),
}) })
popup.closed.connect(function() { popup.closed.connect(() => {
userListItem.highlighted = false userListItem.highlighted = false
}) })
if (roomDrawer.modal) { if (roomDrawer.modal) {
@@ -61,7 +61,6 @@ ColumnLayout {
Kirigami.Heading { Kirigami.Heading {
Layout.fillWidth: true Layout.fillWidth: true
level: 1
type: Kirigami.Heading.Type.Primary type: Kirigami.Heading.Type.Primary
wrapMode: QQC2.Label.Wrap wrapMode: QQC2.Label.Wrap
text: room.displayName text: room.displayName

View File

@@ -11,7 +11,9 @@ import org.kde.neochat 1.0
ColumnLayout { ColumnLayout {
id: root id: root
Layout.fillWidth: true Layout.fillWidth: true
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing Layout.leftMargin: Kirigami.Units.largeSpacing
@@ -30,8 +32,11 @@ ColumnLayout {
width: Kirigami.Units.gridUnit width: Kirigami.Units.gridUnit
height: Kirigami.Units.gridUnit height: Kirigami.Units.gridUnit
anchors.bottom: parent.bottom
anchors.right: parent.right anchors {
bottom: parent.bottom
right: parent.right
}
radius: Math.round(width / 2) radius: Math.round(width / 2)
@@ -49,12 +54,12 @@ ColumnLayout {
Kirigami.Heading { Kirigami.Heading {
Layout.fillWidth: true Layout.fillWidth: true
level: 1
type: Kirigami.Heading.Type.Primary type: Kirigami.Heading.Type.Primary
wrapMode: QQC2.Label.Wrap wrapMode: QQC2.Label.Wrap
text: room ? room.displayName : i18n("No name") text: room ? room.displayName : i18n("No name")
textFormat: Text.PlainText textFormat: Text.PlainText
} }
Kirigami.SelectableLabel { Kirigami.SelectableLabel {
Layout.fillWidth: true Layout.fillWidth: true
textFormat: TextEdit.PlainText textFormat: TextEdit.PlainText
@@ -63,36 +68,15 @@ ColumnLayout {
} }
} }
QQC2.ScrollView { Kirigami.SelectableLabel {
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumHeight: Math.min(topicText.contentHeight, Kirigami.Units.gridUnit * 15)
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
QQC2.TextArea {
id: topicText
padding: 0
text: room && room.topic ? room.topic.replace(replaceLinks, "<a href=\"$1\">$1</a>") : i18n("No Topic") text: room && room.topic ? room.topic.replace(replaceLinks, "<a href=\"$1\">$1</a>") : i18n("No Topic")
readonly property var replaceLinks: /(http[s]?:\/\/[^ \r\n]*)/g readonly property var replaceLinks: /(http[s]?:\/\/[^ \r\n]*)/g
textFormat: TextEdit.MarkdownText textFormat: TextEdit.MarkdownText
wrapMode: Text.Wrap wrapMode: Text.Wrap
selectByMouse: true
color: Kirigami.Theme.textColor
selectedTextColor: Kirigami.Theme.highlightedTextColor
selectionColor: Kirigami.Theme.highlightColor
onLinkActivated: UrlHelper.openUrl(link) onLinkActivated: UrlHelper.openUrl(link)
readOnly: true
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
}
background: Item {}
} }
} }
}

View File

@@ -71,26 +71,24 @@ Kirigami.OverlayDrawer {
contentItem: Loader { contentItem: Loader {
id: loader id: loader
active: roomDrawer.drawerOpen active: roomDrawer.drawerOpen
sourceComponent: ColumnLayout { sourceComponent: ColumnLayout {
id: columnLayout readonly property string userSearchText: userListView.headerItem.userListSearchField.text
property alias userSearchText: userListSearchField.text
property alias highlightedUser: userListView.currentIndex property alias highlightedUser: userListView.currentIndex
spacing: Kirigami.Units.largeSpacing
Kirigami.AbstractApplicationHeader { spacing: 0
QQC2.ToolBar {
Layout.fillWidth: true Layout.fillWidth: true
topPadding: Kirigami.Units.smallSpacing / 2;
bottomPadding: Kirigami.Units.smallSpacing / 2;
rightPadding: Kirigami.Units.largeSpacing
leftPadding: Kirigami.Units.largeSpacing
RowLayout { Layout.preferredHeight: pageStack.globalToolBar.preferredHeight
anchors.fill: parent
contentItem: RowLayout {
Kirigami.Heading { Kirigami.Heading {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Room information") text: i18n("Room information")
level: 1
} }
QQC2.ToolButton { QQC2.ToolButton {
id: settingsButton id: settingsButton
@@ -99,16 +97,36 @@ Kirigami.OverlayDrawer {
display: QQC2.AbstractButton.IconOnly display: QQC2.AbstractButton.IconOnly
onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") }) onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") })
QQC2.ToolTip {
text: settingsButton.text QQC2.ToolTip.text: text
} QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
} }
} }
} }
QQC2.ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
ListView {
id: userListView
header: ColumnLayout {
id: columnLayout
property alias userListSearchField: userListSearchField
spacing: Kirigami.Units.largeSpacing
width: userListView.width
Loader { Loader {
active: true active: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.smallSpacing
sourceComponent: room.isDirectChat() ? directChatDrawerHeader : groupChatDrawerHeader sourceComponent: room.isDirectChat() ? directChatDrawerHeader : groupChatDrawerHeader
} }
@@ -143,6 +161,15 @@ Kirigami.OverlayDrawer {
}) })
} }
} }
Kirigami.BasicListItem {
id: favouriteButton
icon: room && room.isFavourite ? "rating" : "rating-unrated"
text: room && room.isFavourite ? i18n("Remove room from favorites") : i18n("Make room favorite")
onClicked: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
}
Kirigami.BasicListItem { Kirigami.BasicListItem {
id: locationsButton id: locationsButton
@@ -155,14 +182,6 @@ Kirigami.OverlayDrawer {
title: i18nc("Locations on a map", "Locations") title: i18nc("Locations on a map", "Locations")
}) })
} }
Kirigami.BasicListItem {
id: favouriteButton
icon: room && room.isFavourite ? "rating" : "rating-unrated"
text: room && room.isFavourite ? i18n("Remove room from favorites") : i18n("Make room favorite")
onClicked: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
}
Kirigami.ListSectionHeader { Kirigami.ListSectionHeader {
label: i18n("Members") label: i18n("Members")
@@ -216,21 +235,9 @@ Kirigami.OverlayDrawer {
onAccepted: sortedMessageEventModel.filterString = text; onAccepted: sortedMessageEventModel.filterString = text;
} }
}
QQC2.ScrollView { KSortFilterProxyModel {
Layout.fillWidth: true
Layout.fillHeight: true
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
ListView {
id: userListView
clip: true
activeFocusOnTab: true
visible: !room.isDirectChat()
model: KSortFilterProxyModel {
id: sortedMessageEventModel id: sortedMessageEventModel
sourceModel: UserListModel { sourceModel: UserListModel {
@@ -243,6 +250,11 @@ Kirigami.OverlayDrawer {
filterCaseSensitivity: Qt.CaseInsensitive filterCaseSensitivity: Qt.CaseInsensitive
} }
model: room.isDirectChat() ? 0 : sortedMessageEventModel
clip: true
activeFocusOnTab: true
delegate: Kirigami.BasicListItem { delegate: Kirigami.BasicListItem {
id: userListItem id: userListItem