From 0d5eb93241f8732d06bc0d79cbf63a56ed103d1d Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Sat, 18 May 2024 13:46:06 -0500 Subject: [PATCH] Added Settings. Erase messages. Toggle external window. Signed-off-by: Armored Dragon --- .../armored-chat/armored_chat.js | 23 ++++++- .../armored-chat/armored_chat.qml | 65 ++++++++++++++++++- 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/scripts/communityScripts/armored-chat/armored_chat.js b/scripts/communityScripts/armored-chat/armored_chat.js index 40c4510409..27f40b3a15 100644 --- a/scripts/communityScripts/armored-chat/armored_chat.js +++ b/scripts/communityScripts/armored-chat/armored_chat.js @@ -129,12 +129,33 @@ } function fromQML(event) { - console.log(`New web event:\n${JSON.stringify(event)}`); + console.log(`New QML event:\n${JSON.stringify(event)}`); switch (event.type) { case "send_message": _sendMessage(event.message, event.channel); break; + case "setting_change": + settings[event.setting] = event.value; // Update local settings + _saveSettings(); // Save local settings + + switch (event.setting) { + case "external_window": + chat_overlay_window.presentationMode = event.value + ? Desktop.PresentationMode.NATIVE + : Desktop.PresentationMode.VIRTUAL; + break; + } + + break; + case "action": + switch (event.action) { + case "erase_history": + Settings.setValue("ArmoredChat-Messages", []); + break; + } + break; + case "initialized": // https://github.com/overte-org/overte/issues/824 chat_overlay_window.visible = app_is_visible; // The "visible" field in the Desktop.createWindow does not seem to work. Force set it to the initial state (false) diff --git a/scripts/communityScripts/armored-chat/armored_chat.qml b/scripts/communityScripts/armored-chat/armored_chat.qml index 29f43a4616..af3314cc99 100644 --- a/scripts/communityScripts/armored-chat/armored_chat.qml +++ b/scripts/communityScripts/armored-chat/armored_chat.qml @@ -26,9 +26,8 @@ Rectangle { // toScript({type: "initialized"}) // } - Column { + Item { anchors.fill: parent - spacing: 0 // Navigation Bar Rectangle { @@ -135,6 +134,7 @@ Rectangle { width: parent.width height: parent.height - 40 anchors.top: navigation_bar.bottom + visible: ["local", "domain"].includes(pageVal) ? true : false // Chat Message History @@ -180,7 +180,6 @@ Rectangle { height: 40 color: Qt.rgba(0.9,0.9,0.9,1) anchors.bottom: parent.bottom - visible: ["local", "domain"].includes(pageVal) ? true : false Row { width: parent.width @@ -224,6 +223,66 @@ Rectangle { } } + Item { + width: parent.width + height: parent.height - 40 + anchors.top: navigation_bar.bottom + visible: ["local", "domain"].includes(pageVal) ? false : true + + Column { + width: parent.width - 10 + height: parent.height - 10 + anchors.centerIn: parent + spacing: 0 + + Rectangle { + width: parent.width + height: 40 + color: "transparent" + + Text{ + text: "External window" + color: "white" + font.pointSize: 12 + anchors.verticalCenter: parent.verticalCenter + } + + CheckBox{ + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + onCheckedChanged: { + toScript({type: 'setting_change', setting: 'external_window', value: checked}) + } + } + } + + Rectangle { + width: parent.width + height: 40 + color: Qt.rgba(0.15,0.15,0.15,1); + + Text{ + text: "Erase chat history" + color: "white" + font.pointSize: 12 + anchors.verticalCenter: parent.verticalCenter + } + + Button { + anchors.right: parent.right + text: "Erase" + height: parent.height + anchors.verticalCenter: parent.verticalCenter + + onClicked: { + toScript({type: "action", action: "erase_history"}) + } + } + } + } + } + } Component {