Merge pull request #965 from maltee1/mobile_room_settings

Mobile room settings
This commit is contained in:
DeepBlueV7.X 2022-03-05 00:33:45 +00:00 committed by GitHub
commit d0623131e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,8 +17,10 @@ ApplicationWindow {
property var roomSettings property var roomSettings
minimumWidth: 450 minimumWidth: 340
minimumHeight: 680 minimumHeight: 450
width: 450
height: 680
palette: Nheko.colors palette: Nheko.colors
color: Nheko.colors.window color: Nheko.colors.window
modality: Qt.NonModal modality: Qt.NonModal
@ -29,15 +31,25 @@ ApplicationWindow {
sequence: StandardKey.Cancel sequence: StandardKey.Cancel
onActivated: roomSettingsDialog.close() onActivated: roomSettingsDialog.close()
} }
ScrollHelper {
flickable: flickable
anchors.fill: flickable
}
Flickable {
id: flickable
boundsBehavior: Flickable.StopAtBounds
anchors.fill: parent
clip: true
flickableDirection: Flickable.VerticalFlick
contentWidth: roomSettingsDialog.width
contentHeight: contentLayout1.height
ColumnLayout { ColumnLayout {
id: contentLayout1 id: contentLayout1
width: parent.width
anchors.fill: parent
anchors.margins: Nheko.paddingMedium
spacing: Nheko.paddingMedium spacing: Nheko.paddingMedium
Avatar { Avatar {
Layout.topMargin: Nheko.paddingMedium
url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/") url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
roomid: roomSettings.roomId roomid: roomSettings.roomId
displayName: roomSettings.roomName displayName: roomSettings.roomName
@ -65,6 +77,8 @@ ApplicationWindow {
visible: opacity > 0 visible: opacity > 0
opacity: 0 opacity: 0
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
wrapMode: Text.Wrap // somehow still doesn't wrap
Layout.fillWidth: true
} }
SequentialAnimation { SequentialAnimation {
@ -93,20 +107,21 @@ ApplicationWindow {
hideErrorAnimation.restart(); hideErrorAnimation.restart();
} }
} }
Label {
ColumnLayout {
Layout.alignment: Qt.AlignHCenter
MatrixText {
text: roomSettings.roomName text: roomSettings.roomName
Layout.alignment: Qt.AlignHCenter
font.pixelSize: fontMetrics.font.pixelSize * 2 font.pixelSize: fontMetrics.font.pixelSize * 2
Layout.fillWidth: true Layout.fillWidth: true
horizontalAlignment: TextEdit.AlignHCenter horizontalAlignment: TextEdit.AlignHCenter
color: Nheko.colors.text
wrapMode: Text.Wrap
textFormat: Text.RichText
} }
MatrixText { Label {
text: qsTr("%n member(s)", "", roomSettings.memberCount) text: qsTr("%n member(s)", "", roomSettings.memberCount)
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
color: Nheko.colors.text
TapHandler { TapHandler {
onSingleTapped: TimelineManager.openRoomMembers(Rooms.getRoomById(roomSettings.roomId)) onSingleTapped: TimelineManager.openRoomMembers(Rooms.getRoomById(roomSettings.roomId))
@ -119,8 +134,6 @@ ApplicationWindow {
} }
}
ImageButton { ImageButton {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
image: ":/icons/icons/ui/edit.svg" image: ":/icons/icons/ui/edit.svg"
@ -128,20 +141,24 @@ ApplicationWindow {
onClicked: roomSettings.openEditModal() onClicked: roomSettings.openEditModal()
} }
ScrollView { TextArea {
Layout.fillHeight: true id: roomTopic
property bool cut: implicitHeight > 100
property bool showMore
clip: true
Layout.maximumHeight: showMore? Number.POSITIVE_INFINITY : 100
Layout.preferredHeight: implicitHeight
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: Nheko.paddingLarge Layout.leftMargin: Nheko.paddingLarge
Layout.rightMargin: Nheko.paddingLarge Layout.rightMargin: Nheko.paddingLarge
TextArea {
text: TimelineManager.escapeEmoji(roomSettings.roomTopic) text: TimelineManager.escapeEmoji(roomSettings.roomTopic)
wrapMode: TextEdit.WordWrap wrapMode: TextEdit.WordWrap
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)
@ -152,25 +169,34 @@ ApplicationWindow {
} }
} }
Item {
Layout.alignment: Qt.AlignHCenter
id: showMorePlaceholder
Layout.preferredHeight: showMoreButton.height
Layout.preferredWidth: showMoreButton.width
visible: roomTopic.cut
} }
GridLayout { GridLayout {
columns: 2 columns: 2
rowSpacing: Nheko.paddingMedium rowSpacing: Nheko.paddingMedium
Layout.margins: Nheko.paddingMedium
Layout.fillWidth: true
MatrixText { Label {
text: qsTr("SETTINGS") text: qsTr("SETTINGS")
font.bold: true font.bold: true
color: Nheko.colors.text
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
MatrixText { Label {
text: qsTr("Notifications") text: qsTr("Notifications")
Layout.fillWidth: true Layout.fillWidth: true
color: Nheko.colors.text
} }
ComboBox { ComboBox {
@ -180,11 +206,13 @@ ApplicationWindow {
roomSettings.changeNotifications(index); roomSettings.changeNotifications(index);
} }
Layout.fillWidth: true Layout.fillWidth: true
WheelHandler{} // suppress scrolling changing values
} }
MatrixText { Label {
text: qsTr("Room access") text: qsTr("Room access")
Layout.fillWidth: true Layout.fillWidth: true
color: Nheko.colors.text
} }
ComboBox { ComboBox {
@ -204,10 +232,12 @@ ApplicationWindow {
roomSettings.changeAccessRules(index); roomSettings.changeAccessRules(index);
} }
Layout.fillWidth: true Layout.fillWidth: true
WheelHandler{} // suppress scrolling changing values
} }
MatrixText { Label {
text: qsTr("Encryption") text: qsTr("Encryption")
color: Nheko.colors.text
} }
ToggleButton { ToggleButton {
@ -243,8 +273,9 @@ ApplicationWindow {
buttons: Platform.MessageDialog.Ok | Platform.MessageDialog.Cancel buttons: Platform.MessageDialog.Ok | Platform.MessageDialog.Cancel
} }
MatrixText { Label {
text: qsTr("Sticker & Emote Settings") text: qsTr("Sticker & Emote Settings")
color: Nheko.colors.text
} }
Button { Button {
@ -254,8 +285,9 @@ ApplicationWindow {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
MatrixText { Label {
text: qsTr("Hidden events") text: qsTr("Hidden events")
color: Nheko.colors.text
} }
HiddenEventsDialog { HiddenEventsDialog {
@ -281,42 +313,78 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
} }
MatrixText { Label {
text: qsTr("INFO") text: qsTr("INFO")
font.bold: true font.bold: true
color: Nheko.colors.text
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
MatrixText { Label {
text: qsTr("Internal ID") text: qsTr("Internal ID")
color: Nheko.colors.text
} }
MatrixText { AbstractButton { // AbstractButton does not allow setting text color
Layout.alignment: Qt.AlignRight
Layout.fillWidth: true
Layout.preferredHeight: idLabel.height
Label { // TextEdit does not trigger onClicked
id: idLabel
text: roomSettings.roomId text: roomSettings.roomId
font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 0.8) font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 0.8)
Layout.alignment: Qt.AlignRight color: Nheko.colors.text
width: parent.width
horizontalAlignment: Text.AlignRight
wrapMode: Text.WrapAnywhere
ToolTip.text: qsTr("Copied to clipboard")
ToolTip.visible: toolTipTimer.running
}
TextEdit{ // label does not allow selection
id: textEdit
visible: false
text: roomSettings.roomId
}
onClicked: {
textEdit.selectAll()
textEdit.copy()
toolTipTimer.start()
}
Timer {
id: toolTipTimer
}
} }
MatrixText { Label {
text: qsTr("Room Version") text: qsTr("Room Version")
color: Nheko.colors.text
} }
MatrixText { Label {
text: roomSettings.roomVersion text: roomSettings.roomVersion
font.pixelSize: fontMetrics.font.pixelSize font.pixelSize: fontMetrics.font.pixelSize
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
color: Nheko.colors.text
} }
} }
}
DialogButtonBox { }
Layout.fillWidth: true Button {
id: showMoreButton
anchors.horizontalCenter: flickable.horizontalCenter
y: Math.min(showMorePlaceholder.y+contentLayout1.y-flickable.contentY,flickable.height-height)
visible: roomTopic.cut
text: roomTopic.showMore? "show less" : "show more"
onClicked: {roomTopic.showMore = !roomTopic.showMore
console.log(flickable.visibleArea)
}
}
footer: DialogButtonBox {
standardButtons: DialogButtonBox.Ok standardButtons: DialogButtonBox.Ok
onAccepted: close() onAccepted: close()
} }
}
} }