Support resizing right drawer

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan
2021-10-21 22:54:48 +02:00
parent 6afeaf1619
commit 6c3ae87340
3 changed files with 89 additions and 54 deletions

View File

@@ -18,6 +18,46 @@ Kirigami.OverlayDrawer {
id: roomDrawer id: roomDrawer
readonly property var room: RoomManager.currentRoom readonly property var room: RoomManager.currentRoom
width: modal ? undefined : actualWidth
readonly property int minWidth: Kirigami.Units.gridUnit * 15
readonly property int maxWidth: Kirigami.Units.gridUnit * 25
readonly property int defaultWidth: Kirigami.Units.gridUnit * 20
property int actualWidth: {
if (Config.roomDrawerWidth === -1) {
return Kirigami.Units.gridUnit * 20;
} else {
return Config.roomDrawerWidth
}
}
MouseArea {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: undefined
width: 2
z: 500
cursorShape: !Kirigami.Settings.isMobile ? Qt.SplitHCursor : undefined
enabled: true
visible: true
onPressed: _lastX = mapToGlobal(mouseX, mouseY).x
onReleased: {
Config.roomDrawerWidth = roomDrawer.actualWidth;
Config.save();
}
property real _lastX: -1
onPositionChanged: {
if (_lastX === -1) {
return;
}
if (Qt.application.layoutDirection === Qt.RightToLeft) {
roomDrawer.actualWidth = Math.min(roomDrawer.maxWidth, Math.max(roomDrawer.minWidth, Config.roomDrawerWidth - _lastX + mapToGlobal(mouseX, mouseY).x))
} else {
roomDrawer.actualWidth = Math.min(roomDrawer.maxWidth, Math.max(roomDrawer.minWidth, Config.roomDrawerWidth + _lastX - mapToGlobal(mouseX, mouseY).x))
}
}
}
enabled: true enabled: true
edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge
@@ -30,7 +70,6 @@ Kirigami.OverlayDrawer {
active: roomDrawer.drawerOpen active: roomDrawer.drawerOpen
sourceComponent: ColumnLayout { sourceComponent: ColumnLayout {
id: columnLayout id: columnLayout
anchors.fill: parent
spacing: 0 spacing: 0
Kirigami.AbstractApplicationHeader { Kirigami.AbstractApplicationHeader {
Layout.fillWidth: true Layout.fillWidth: true
@@ -78,67 +117,61 @@ Kirigami.OverlayDrawer {
} }
} }
Control { ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
padding: Kirigami.Units.largeSpacing Layout.margins: Kirigami.Units.largeSpacing
contentItem: ColumnLayout { Kirigami.Heading {
id: infoLayout text: i18n("Room information")
level: 3
}
RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Kirigami.Heading { Layout.margins: Kirigami.Units.largeSpacing
text: i18n("Room information")
level: 3 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) : ""
} }
RowLayout {
ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: Kirigami.Units.largeSpacing Layout.alignment: Qt.AlignVCenter
spacing: 0
spacing: Kirigami.Units.largeSpacing Kirigami.Heading {
Layout.maximumWidth: Kirigami.Units.gridUnit * 9
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 level: 1
spacing: 0 font.bold: true
wrapMode: Label.Wrap
Kirigami.Heading { text: room ? room.displayName : i18n("No name")
Layout.maximumWidth: Kirigami.Units.gridUnit * 9 }
Layout.fillWidth: true Label {
level: 1 Layout.fillWidth: true
font.bold: true text: room && room.canonicalAlias ? room.canonicalAlias : i18n("No Canonical Alias")
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 { TextEdit {
Layout.maximumWidth: Kirigami.Units.gridUnit * 13 Layout.fillWidth: true
Layout.preferredWidth: Kirigami.Units.gridUnit * 13 text: room && room.topic ? room.topic.replace(replaceLinks, "<a href=\"$1\">$1</a>") : i18n("No Topic")
Layout.fillWidth: true readonly property var replaceLinks: /\(https:\/\/[^ ]*\)/
text: room && room.topic ? room.topic.replace(replaceLinks, "<a href=\"$1\">$1</a>") : i18n("No Topic") textFormat: TextEdit.MarkdownText
readonly property var replaceLinks: /\(https:\/\/[^ ]*\)/ wrapMode: Text.WordWrap
textFormat: TextEdit.MarkdownText selectByMouse: true
wrapMode: Text.WordWrap color: Kirigami.Theme.textColor
selectByMouse: true onLinkActivated: Qt.openUrlExternally(link)
color: Kirigami.Theme.textColor readOnly: true
onLinkActivated: Qt.openUrlExternally(link) MouseArea {
readOnly: true anchors.fill: parent
MouseArea { acceptedButtons: Qt.NoButton
anchors.fill: parent cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
}
} }
} }
} }

View File

@@ -151,7 +151,6 @@ Kirigami.ApplicationWindow {
contextDrawer: RoomDrawer { contextDrawer: RoomDrawer {
id: contextDrawer id: contextDrawer
contentItem.implicitWidth: columnWidth
edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge
modal: !root.wideScreen || !enabled modal: !root.wideScreen || !enabled
onEnabledChanged: drawerOpen = enabled && !modal onEnabledChanged: drawerOpen = enabled && !modal

View File

@@ -48,6 +48,9 @@
<entry name="RoomListPageWidth" type="int"> <entry name="RoomListPageWidth" type="int">
<default>-1</default> <default>-1</default>
</entry> </entry>
<entry name="RoomDrawerWidth" type="int">
<default>-1</default>
</entry>
</group> </group>
<group name="Timeline"> <group name="Timeline">
<entry name="ShowAvatarInTimeline" type="bool"> <entry name="ShowAvatarInTimeline" type="bool">