Warning, /network/neochat/src/qml/General.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2019-2020 Black Hat <bhat@encom.eu.org> 0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: GPL-3.0-only 0004 0005 import QtQuick 0006 import QtQuick.Controls as QQC2 0007 import QtQuick.Layouts 0008 import QtQuick.Window 0009 0010 import org.kde.kirigami as Kirigami 0011 import org.kde.kirigamiaddons.formcard as FormCard 0012 import org.kde.kirigamiaddons.labs.components as KirigamiComponents 0013 0014 import org.kde.neochat 0015 0016 FormCard.FormCardPage { 0017 id: root 0018 0019 property NeoChatRoom room 0020 required property NeoChatConnection connection 0021 0022 title: i18n("General") 0023 0024 FormCard.FormHeader { 0025 title: i18n("Room Information") 0026 } 0027 FormCard.FormCard { 0028 FormCard.AbstractFormDelegate { 0029 background: null 0030 contentItem: RowLayout { 0031 Item { 0032 Layout.fillWidth: true 0033 } 0034 KirigamiComponents.Avatar { 0035 id: avatar 0036 Layout.alignment: Qt.AlignRight 0037 name: room.name 0038 source: room.avatarMediaId ? ("image://mxc/" + room.avatarMediaId) : "" 0039 implicitWidth: Kirigami.Units.iconSizes.enormous 0040 implicitHeight: Kirigami.Units.iconSizes.enormous 0041 } 0042 QQC2.Button { 0043 Layout.alignment: Qt.AlignLeft 0044 enabled: room.canSendState("m.room.avatar") 0045 visible: enabled 0046 icon.name: "cloud-upload" 0047 text: i18n("Update avatar") 0048 display: QQC2.AbstractButton.IconOnly 0049 0050 onClicked: { 0051 const fileDialog = openFileDialog.createObject(QQC2.ApplicationWindow.overlay); 0052 fileDialog.chosen.connect(function (path) { 0053 if (!path) 0054 return; 0055 room.changeAvatar(path); 0056 }); 0057 fileDialog.open(); 0058 } 0059 0060 QQC2.ToolTip.text: text 0061 QQC2.ToolTip.visible: hovered 0062 } 0063 Item { 0064 Layout.fillWidth: true 0065 } 0066 } 0067 } 0068 FormCard.FormTextFieldDelegate { 0069 id: roomNameField 0070 label: i18n("Room name:") 0071 text: room.name 0072 readOnly: !room.canSendState("m.room.name") 0073 } 0074 FormCard.AbstractFormDelegate { 0075 id: roomTopicField 0076 background: Item {} 0077 contentItem: ColumnLayout { 0078 QQC2.Label { 0079 id: roomTopicLabel 0080 text: i18n("Room topic:") 0081 Layout.fillWidth: true 0082 } 0083 QQC2.TextArea { 0084 id: roomTopicTextArea 0085 Accessible.description: roomTopicLabel.text 0086 Layout.fillWidth: true 0087 wrapMode: TextEdit.Wrap 0088 text: room.topic 0089 readOnly: !room.canSendState("m.room.topic") 0090 onTextChanged: roomTopicField.text = text 0091 } 0092 } 0093 } 0094 FormCard.AbstractFormDelegate { 0095 visible: !roomNameField.readOnly || !roomTopicTextArea.readOnly 0096 background: Item {} 0097 contentItem: RowLayout { 0098 Item { 0099 Layout.fillWidth: true 0100 } 0101 QQC2.Button { 0102 Layout.bottomMargin: Kirigami.Units.smallSpacing 0103 Layout.topMargin: Kirigami.Units.smallSpacing 0104 enabled: room.name !== roomNameField.text || room.topic !== roomTopicField.text 0105 text: i18n("Save") 0106 onClicked: { 0107 if (room.name != roomNameField.text) { 0108 room.setName(roomNameField.text); 0109 } 0110 if (room.topic != roomTopicField.text) { 0111 room.setTopic(roomTopicField.text); 0112 } 0113 } 0114 } 0115 } 0116 } 0117 FormCard.FormTextDelegate { 0118 id: roomIdDelegate 0119 text: i18n("Room ID") 0120 description: room.id 0121 0122 contentItem.children: QQC2.Button { 0123 visible: roomIdDelegate.hovered 0124 text: i18n("Copy room ID to clipboard") 0125 icon.name: "edit-copy" 0126 display: QQC2.AbstractButton.IconOnly 0127 0128 onClicked: { 0129 Clipboard.saveText(room.id); 0130 } 0131 0132 QQC2.ToolTip.text: text 0133 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0134 QQC2.ToolTip.visible: hovered 0135 } 0136 } 0137 FormCard.FormTextDelegate { 0138 text: i18n("Room version") 0139 description: room.version 0140 0141 contentItem.children: QQC2.Button { 0142 visible: room.canSwitchVersions() 0143 enabled: room.version < room.maxRoomVersion 0144 text: i18n("Upgrade Room") 0145 icon.name: "arrow-up-double" 0146 0147 onClicked: { 0148 if (room.canSwitchVersions()) { 0149 roomUpgradeSheet.currentRoomVersion = room.version; 0150 roomUpgradeSheet.open(); 0151 } 0152 } 0153 0154 QQC2.ToolTip { 0155 text: text 0156 delay: Kirigami.Units.toolTipDelay 0157 } 0158 } 0159 } 0160 } 0161 0162 FormCard.FormHeader { 0163 title: i18n("Aliases") 0164 } 0165 FormCard.FormCard { 0166 FormCard.FormTextDelegate { 0167 visible: room.aliases.length <= 0 0168 text: i18n("No canonical alias set") 0169 } 0170 Repeater { 0171 id: altAliasRepeater 0172 model: room.aliases.slice().reverse() 0173 0174 delegate: FormCard.FormTextDelegate { 0175 text: modelData 0176 description: room.canonicalAlias.length > 0 && modelData === room.canonicalAlias ? "Canonical alias" : "" 0177 contentItem.children: [ 0178 QQC2.ToolButton { 0179 id: setCanonicalAliasButton 0180 visible: modelData !== room.canonicalAlias && room.canSendState("m.room.canonical_alias") 0181 text: i18n("Make this alias the room's canonical alias") 0182 icon.name: "checkmark" 0183 display: QQC2.AbstractButton.IconOnly 0184 0185 onClicked: { 0186 room.setCanonicalAlias(modelData); 0187 } 0188 QQC2.ToolTip { 0189 text: setCanonicalAliasButton.text 0190 delay: Kirigami.Units.toolTipDelay 0191 } 0192 }, 0193 QQC2.ToolButton { 0194 id: deleteButton 0195 visible: room.canSendState("m.room.canonical_alias") 0196 text: i18n("Delete alias") 0197 icon.name: "edit-delete-remove" 0198 display: QQC2.AbstractButton.IconOnly 0199 0200 onClicked: { 0201 room.unmapAlias(modelData); 0202 } 0203 QQC2.ToolTip { 0204 text: deleteButton.text 0205 delay: Kirigami.Units.toolTipDelay 0206 } 0207 } 0208 ] 0209 } 0210 } 0211 FormCard.AbstractFormDelegate { 0212 visible: room.canSendState("m.room.canonical_alias") 0213 0214 contentItem: RowLayout { 0215 Kirigami.ActionTextField { 0216 id: aliasAddField 0217 0218 Layout.fillWidth: true 0219 0220 placeholderText: i18n("#new_alias:server.org") 0221 0222 rightActions: Kirigami.Action { 0223 icon.name: "edit-clear" 0224 visible: aliasAddField.text.length > 0 0225 onTriggered: { 0226 aliasAddField.text = ""; 0227 } 0228 } 0229 0230 onAccepted: { 0231 room.mapAlias(aliasAddField.text); 0232 } 0233 } 0234 QQC2.Button { 0235 id: addButton 0236 0237 text: i18n("Add new alias") 0238 Accessible.name: text 0239 icon.name: "list-add" 0240 display: QQC2.AbstractButton.IconOnly 0241 enabled: aliasAddField.text.length > 0 0242 0243 onClicked: { 0244 room.mapAlias(aliasAddField.text); 0245 } 0246 0247 QQC2.ToolTip { 0248 text: addButton.text 0249 delay: Kirigami.Units.toolTipDelay 0250 } 0251 } 0252 } 0253 } 0254 } 0255 0256 FormCard.FormHeader { 0257 title: i18n("URL Previews") 0258 } 0259 FormCard.FormCard { 0260 FormCard.FormCheckDelegate { 0261 text: i18n("Enable URL previews by default for room members") 0262 checked: room.defaultUrlPreviewState 0263 visible: room.canSendState("org.matrix.room.preview_urls") 0264 onToggled: { 0265 room.defaultUrlPreviewState = checked; 0266 } 0267 } 0268 FormCard.FormCheckDelegate { 0269 text: i18n("Enable URL previews") 0270 // Most users won't see the above setting so tell them the default. 0271 description: room.defaultUrlPreviewState ? i18n("URL previews are enabled by default in this room") : i18n("URL previews are disabled by default in this room") 0272 checked: room.urlPreviewEnabled 0273 onToggled: { 0274 room.urlPreviewEnabled = checked; 0275 } 0276 } 0277 } 0278 FormCard.FormHeader { 0279 title: i18n("Official Parent Spaces") 0280 } 0281 FormCard.FormCard { 0282 Repeater { 0283 id: officalParentRepeater 0284 model: root.room.parentIds 0285 0286 delegate: FormCard.FormTextDelegate { 0287 id: officalParentDelegate 0288 required property string modelData 0289 property NeoChatRoom space: root.connection.room(modelData) 0290 text: { 0291 if (space) { 0292 return space.displayName; 0293 } else { 0294 return modelData; 0295 } 0296 } 0297 description: { 0298 if (space) { 0299 if (space.canonicalAlias.length > 0) { 0300 return space.canonicalAlias; 0301 } else { 0302 return modelData; 0303 } 0304 } else { 0305 return ""; 0306 } 0307 } 0308 0309 contentItem.children: RowLayout { 0310 QQC2.Label { 0311 visible: root.room.canonicalParent === officalParentDelegate.modelData 0312 text: i18n("Canonical") 0313 } 0314 QQC2.ToolButton { 0315 visible: root.room.canSendState("m.space.parent") && root.room.canonicalParent !== officalParentDelegate.modelData 0316 display: QQC2.AbstractButton.IconOnly 0317 action: Kirigami.Action { 0318 id: canonicalParentAction 0319 text: i18n("Make canonical parent") 0320 icon.name: "checkmark" 0321 onTriggered: root.room.canonicalParent = officalParentDelegate.modelData 0322 } 0323 QQC2.ToolTip { 0324 text: canonicalParentAction.text 0325 delay: Kirigami.Units.toolTipDelay 0326 } 0327 } 0328 QQC2.ToolButton { 0329 visible: officalParentDelegate?.space.canSendState("m.space.child") && root.room.canSendState("m.space.parent") 0330 display: QQC2.AbstractButton.IconOnly 0331 action: Kirigami.Action { 0332 id: removeParentAction 0333 text: i18n("Remove parent") 0334 icon.name: "edit-delete-remove" 0335 onTriggered: root.room.removeParent(officalParentDelegate.modelData) 0336 } 0337 QQC2.ToolTip { 0338 text: removeParentAction.text 0339 delay: Kirigami.Units.toolTipDelay 0340 } 0341 } 0342 } 0343 } 0344 } 0345 FormCard.FormTextDelegate { 0346 visible: officalParentRepeater.count <= 0 0347 text: i18n("This room has no official parent spaces.") 0348 } 0349 FormCard.FormButtonDelegate { 0350 visible: root.room.canSendState("m.space.parent") 0351 text: i18nc("@action:button", "Add new official parent") 0352 onClicked: selectParentDialog.createObject(applicationWindow().overlay).open() 0353 0354 Component { 0355 id: selectParentDialog 0356 SelectParentDialog { 0357 room: root.room 0358 } 0359 } 0360 } 0361 } 0362 0363 Kirigami.InlineMessage { 0364 Layout.maximumWidth: Kirigami.Units.gridUnit * 30 0365 Layout.alignment: Qt.AlignHCenter 0366 text: i18n("This room continues another conversation.") 0367 type: Kirigami.MessageType.Information 0368 visible: room.predecessorId && room.connection.room(room.predecessorId) 0369 actions: Kirigami.Action { 0370 text: i18n("See older messages…") 0371 onTriggered: { 0372 RoomManager.resolveResource(room.predecessorId); 0373 root.close(); 0374 } 0375 } 0376 } 0377 Kirigami.InlineMessage { 0378 Layout.maximumWidth: Kirigami.Units.gridUnit * 30 0379 Layout.alignment: Qt.AlignHCenter 0380 text: i18n("This room has been replaced.") 0381 type: Kirigami.MessageType.Information 0382 visible: room.successorId && room.connection.room(room.successorId) 0383 actions: Kirigami.Action { 0384 text: i18n("See new room…") 0385 onTriggered: { 0386 RoomManager.resolveResource(room.successorId); 0387 root.close(); 0388 } 0389 } 0390 } 0391 0392 property Component openFileDialog: Component { 0393 id: openFileDialog 0394 0395 OpenFileDialog { 0396 parentWindow: root.Window.window 0397 } 0398 } 0399 0400 property Kirigami.OverlaySheet roomUpgradeSheet: Kirigami.OverlaySheet { 0401 id: roomUpgradeSheet 0402 0403 property var currentRoomVersion 0404 0405 title: i18n("Upgrade the Room") 0406 Kirigami.FormLayout { 0407 QQC2.SpinBox { 0408 id: spinBox 0409 Kirigami.FormData.label: i18n("Select new version") 0410 from: room.version 0411 to: room.maxRoomVersion 0412 value: room.version 0413 } 0414 QQC2.Button { 0415 text: i18n("Confirm") 0416 onClicked: { 0417 room.switchVersion(spinBox.value); 0418 roomUpgradeSheet.close(); 0419 } 0420 } 0421 } 0422 } 0423 }