make long topic collapsible

This commit is contained in:
Malte E 2022-03-02 10:02:01 +01:00
parent 22235defac
commit 02da8e445a

View File

@ -18,7 +18,7 @@ ApplicationWindow {
property var roomSettings property var roomSettings
minimumWidth: 340 minimumWidth: 340
minimumHeight: 340 minimumHeight: 450
width: 450 width: 450
height: 680 height: 680
palette: Nheko.colors palette: Nheko.colors
@ -41,11 +41,11 @@ ApplicationWindow {
anchors.fill: parent anchors.fill: parent
clip: true clip: true
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
contentWidth: contentLayout1.width contentWidth: roomSettingsDialog.width
contentHeight: contentLayout1.height contentHeight: contentLayout1.height
ColumnLayout { ColumnLayout {
id: contentLayout1 id: contentLayout1
width: flickable.width width: parent.width
spacing: Nheko.paddingMedium spacing: Nheko.paddingMedium
Avatar { Avatar {
@ -78,6 +78,7 @@ ApplicationWindow {
opacity: 0 opacity: 0
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
wrapMode: Text.Wrap // somehow still doesn't wrap wrapMode: Text.Wrap // somehow still doesn't wrap
Layout.fillWidth: true
} }
SequentialAnimation { SequentialAnimation {
@ -137,7 +138,12 @@ ApplicationWindow {
} }
TextArea { TextArea {
Layout.fillHeight: true id: roomTopic
property bool cut: implicitHeight > 100
property bool showMore
clip: true
height: cut && !showMore? 100 : implicitHeight
Layout.preferredHeight: height
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: Nheko.paddingLarge Layout.leftMargin: Nheko.paddingLarge
@ -148,7 +154,7 @@ ApplicationWindow {
textFormat: TextEdit.RichText textFormat: TextEdit.RichText
readOnly: true readOnly: true
background: null background: null
selectByMouse: true selectByMouse: !Settings.mobileMode
color: Nheko.colors.text color: Nheko.colors.text
horizontalAlignment: TextEdit.AlignHCenter horizontalAlignment: TextEdit.AlignHCenter
onLinkActivated: Nheko.openLink(link) onLinkActivated: Nheko.openLink(link)
@ -159,11 +165,20 @@ ApplicationWindow {
} }
} }
Item {
Layout.alignment: Qt.AlignHCenter
id: showMorePlaceholder
Layout.preferredHeight: showMoreButton.height
Layout.preferredWidth: showMoreButton.width
visible: roomTopic.cut
}
property point showMorePos: mapToGlobal(showMorePlaceholder.x,showMorePlaceholder.y)
GridLayout { GridLayout {
columns: 2 columns: 2
rowSpacing: Nheko.paddingMedium rowSpacing: Nheko.paddingMedium
Layout.margins: Nheko.paddingMedium Layout.margins: Nheko.paddingMedium
Layout.fillWidth: true
Label { Label {
text: qsTr("SETTINGS") text: qsTr("SETTINGS")
@ -186,6 +201,7 @@ ApplicationWindow {
roomSettings.changeNotifications(index); roomSettings.changeNotifications(index);
} }
Layout.fillWidth: true Layout.fillWidth: true
WheelHandler{} // suppress scrolling changing values
} }
Label { Label {
@ -210,6 +226,7 @@ ApplicationWindow {
roomSettings.changeAccessRules(index); roomSettings.changeAccessRules(index);
} }
Layout.fillWidth: true Layout.fillWidth: true
WheelHandler{} // suppress scrolling changing values
} }
Label { Label {
@ -303,7 +320,9 @@ ApplicationWindow {
Label { Label {
text: roomSettings.roomId text: roomSettings.roomId
font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 0.8) font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 0.8)
wrapMode: Text.WrapAnywhere
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
Layout.fillWidth: true
} }
Label { Label {
@ -319,6 +338,16 @@ ApplicationWindow {
} }
} }
} }
Button {
id: showMoreButton
x: contentLayout1.showMorePos.x
y: Math.min(contentLayout1.showMorePos.y-flickable.contentY,parent.height-height)
visible: roomTopic.cut
text: roomTopic.showMore? "show less" : "show more"
onClicked: {roomTopic.showMore = !roomTopic.showMore
console.log(flickable.visibleArea)
}
}
footer: DialogButtonBox { footer: DialogButtonBox {
standardButtons: DialogButtonBox.Ok standardButtons: DialogButtonBox.Ok
onAccepted: close() onAccepted: close()