Room settings: add room ID text area + copy button

The only way to see a room's ID previously was to right click a room in
the left pane, copy option, and paste it somewhere.
This commit is contained in:
miruka 2021-04-09 11:36:43 -04:00
parent 1d29e47818
commit bcb9ffcf9d
2 changed files with 29 additions and 1 deletions

View File

@ -16,9 +16,11 @@ HButton {
toolTip.label.wrapMode: HLabel.NoWrap toolTip.label.wrapMode: HLabel.NoWrap
onClicked: { onClicked: {
const oldPosition = textControl.cursorPosition
textControl.selectAll() textControl.selectAll()
textControl.copy() textControl.copy()
textControl.deselect() textControl.deselect()
textControl.cursorPosition = oldPosition
toolTip.text = qsTr("Copied!") toolTip.text = qsTr("Copied!")
toolTip.instantShow(2000) toolTip.instantShow(2000)

View File

@ -17,7 +17,8 @@ HFlickableColumnPage {
encryptCheckBox.changed || requireInviteCheckbox.changed || encryptCheckBox.changed || requireInviteCheckbox.changed ||
forbidGuestsCheckBox.changed forbidGuestsCheckBox.changed
readonly property Item keybindFocusItem: nameField.item readonly property Item keybindFocusItem:
nameField.item.enabled ? nameField.item : copyIdButton
function save() { function save() {
if (saveFutureId) py.cancelCoro(saveFutureId) if (saveFutureId) py.cancelCoro(saveFutureId)
@ -99,6 +100,31 @@ HFlickableColumnPage {
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
} }
HLabeledItem {
label.text: qsTr("Room ID:")
Layout.fillWidth: true
HRowLayout {
width: parent.width
HTextArea {
id: idAreaItem
wrapMode: HLabel.WrapAnywhere
readOnly: true
radius: 0
text: chat.roomId
Layout.fillWidth: true
Layout.fillHeight: true
}
FieldCopyButton {
id: copyIdButton
textControl: idAreaItem
}
}
}
HLabeledItem { HLabeledItem {
id: nameField id: nameField
label.text: qsTr("Name:") label.text: qsTr("Name:")