From 48c690a2df7c45957839d658e7c94f5392150360 Mon Sep 17 00:00:00 2001 From: armored-dragon Date: Wed, 18 Dec 2024 17:38:52 -0600 Subject: [PATCH] Broke out templates into their own files. --- scripts/system/domainChat/domainChat.qml | 218 +----------------- .../qml_widgets/TemplateChatMessage.qml | 161 +++++++++++++ .../qml_widgets/TemplateNotification.qml | 59 +++++ 3 files changed, 223 insertions(+), 215 deletions(-) create mode 100644 scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml create mode 100644 scripts/system/domainChat/qml_widgets/TemplateNotification.qml diff --git a/scripts/system/domainChat/domainChat.qml b/scripts/system/domainChat/domainChat.qml index 2220127f98..f40121ee71 100644 --- a/scripts/system/domainChat/domainChat.qml +++ b/scripts/system/domainChat/domainChat.qml @@ -2,6 +2,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.3 import controlsUit 1.0 as HifiControlsUit +import "./qml_widgets" Rectangle { color: Qt.rgba(0.1,0.1,0.1,1) @@ -376,221 +377,8 @@ Rectangle { } // Templates - Component { - id: template_chat_message - - Rectangle { - property int index: delegateIndex - property string username: delegateUsername - - height: Math.max(65, children[1].height + 30) - color: index % 2 === 0 ? "transparent" : Qt.rgba(0.15,0.15,0.15,1) - width: listview.parent.parent.width - Layout.fillWidth: true - - Item { - width: parent.width - 10 - anchors.horizontalCenter: parent.horizontalCenter - height: 22 - - Text{ - text: username - color: "lightgray" - } - - Text{ - anchors.right: parent.right - text: delegateDate - color: "lightgray" - } - } - - Flow { - anchors.top: parent.children[0].bottom; - width: parent.width * 0.8 - x: 5 - id: messageBoxFlow - - Repeater { - model: delegateText; - - RowLayout { - Text { - text: model.value || "" - font.pointSize: 12 - wrapMode: Text.Wrap - width: model.type === 'text' || model.type === 'mention' ? Math.min(messageBoxFlow.width, contentWidth) : 0; - visible: model.type === 'text' || model.type === 'mention'; - - color: { - switch (model.type) { - case "mention": - return "purple"; - default: - return "white"; - } - } - } - - RowLayout { - width: children[0].contentWidth; - visible: model.type === 'url'; - - Text { - text: model.value || ""; - font.pointSize: 12; - wrapMode: Text.Wrap; - color: "#4EBAFD"; - font.underline: true; - width: parent.width; - - MouseArea { - anchors.fill: parent; - - onClicked: { - Window.openWebBrowser(model.value); - } - } - } - - Text { - text: "🗗"; - font.pointSize: 10; - wrapMode: Text.Wrap; - color: "white"; - - MouseArea { - anchors.fill: parent; - - onClicked: { - Qt.openUrlExternally(model.value); - } - } - } - } - - RowLayout { - visible: model.type === 'overteLocation'; - width: Math.min(messageBoxFlow.width, children[0].children[1].contentWidth + 35); - height: 20; - Layout.leftMargin: 5 - Layout.rightMargin: 5 - - Rectangle { - width: parent.width; - height: 20; - color: "lightgray" - radius: 2; - - Image { - source: "./img/ui/world_black.png" - width: 18; - height: 18; - sourceSize.width: 18 - sourceSize.height: 18 - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 2 - anchors.rightMargin: 10 - } - - Text { - text: model.type === 'overteLocation' ? model.value.split('hifi://')[1].split('/')[0] : ''; - color: "black" - font.pointSize: 12 - x: parent.children[0].width + 5; - anchors.verticalCenter: parent.verticalCenter - } - - MouseArea { - anchors.fill: parent; - - onClicked: { - Window.openUrl(model.value); - } - } - } - } - - Item { - Layout.fillWidth: true - visible: model.type === 'messageEnd' - } - - Item { - visible: model.type === 'imageEmbed'; - width: messageBoxFlow.width; - height: 200 - - Image { - source: model.type === 'imageEmbed' ? model.value : '' - sourceSize.width: 400 - sourceSize.height: 200 - } - } - } - } - } - } - } - - Component { - id: template_notification - - Rectangle { - property int index: delegateIndex - property string username: delegateUsername - - color: "#171717" - width: parent.width - height: 40 - - Item { - width: 10 - height: parent.height - - Rectangle { - height: parent.height - width: 5 - color: "#505186" - } - } - - Item { - width: parent.width - parent.children[0].width - 5 - height: parent.height - anchors.left: parent.children[0].right - - TextEdit { - text: delegateText - color: "white" - font.pointSize: 12 - readOnly: true - width: parent.width * 0.8 - selectByMouse: true - selectByKeyboard: true - height: parent.height - wrapMode: Text.Wrap - verticalAlignment: Text.AlignVCenter - font.italic: true - } - - Text { - text: delegateDate - color: "white" - font.pointSize: 12 - anchors.right: parent.right - height: parent.height - wrapMode: Text.Wrap - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - font.italic: true - } - } - - } - - } + TemplateChatMessage { id: template_chat_message } + TemplateNotification { id: template_notification } property var channels: { "local": local, diff --git a/scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml b/scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml new file mode 100644 index 0000000000..4165e8d37c --- /dev/null +++ b/scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml @@ -0,0 +1,161 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.3 + +Component { + id: template_chat_message + + Rectangle { + property int index: delegateIndex + property string username: delegateUsername + + height: Math.max(65, children[1].height + 30) + color: index % 2 === 0 ? "transparent" : Qt.rgba(0.15,0.15,0.15,1) + width: listview.parent.parent.width + Layout.fillWidth: true + + Item { + width: parent.width - 10 + anchors.horizontalCenter: parent.horizontalCenter + height: 22 + + Text{ + text: username + color: "lightgray" + } + + Text{ + anchors.right: parent.right + text: delegateDate + color: "lightgray" + } + } + + Flow { + anchors.top: parent.children[0].bottom; + width: parent.width * 0.8 + x: 5 + id: messageBoxFlow + + Repeater { + model: delegateText; + + RowLayout { + Text { + text: model.value || "" + font.pointSize: 12 + wrapMode: Text.Wrap + width: model.type === 'text' || model.type === 'mention' ? Math.min(messageBoxFlow.width, contentWidth) : 0; + visible: model.type === 'text' || model.type === 'mention'; + + color: { + switch (model.type) { + case "mention": + return "purple"; + default: + return "white"; + } + } + } + + RowLayout { + width: children[0].contentWidth; + visible: model.type === 'url'; + + Text { + text: model.value || ""; + font.pointSize: 12; + wrapMode: Text.Wrap; + color: "#4EBAFD"; + font.underline: true; + width: parent.width; + + MouseArea { + anchors.fill: parent; + + onClicked: { + Window.openWebBrowser(model.value); + } + } + } + + Text { + text: "🗗"; + font.pointSize: 10; + wrapMode: Text.Wrap; + color: "white"; + + MouseArea { + anchors.fill: parent; + + onClicked: { + Qt.openUrlExternally(model.value); + } + } + } + } + + RowLayout { + visible: model.type === 'overteLocation'; + width: Math.min(messageBoxFlow.width, children[0].children[1].contentWidth + 35); + height: 20; + Layout.leftMargin: 5 + Layout.rightMargin: 5 + + Rectangle { + width: parent.width; + height: 20; + color: "lightgray" + radius: 2; + + Image { + source: "./img/ui/world_black.png" + width: 18; + height: 18; + sourceSize.width: 18 + sourceSize.height: 18 + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 2 + anchors.rightMargin: 10 + } + + Text { + text: model.type === 'overteLocation' ? model.value.split('hifi://')[1].split('/')[0] : ''; + color: "black" + font.pointSize: 12 + x: parent.children[0].width + 5; + anchors.verticalCenter: parent.verticalCenter + } + + MouseArea { + anchors.fill: parent; + + onClicked: { + Window.openUrl(model.value); + } + } + } + } + + Item { + Layout.fillWidth: true + visible: model.type === 'messageEnd' + } + + Item { + visible: model.type === 'imageEmbed'; + width: messageBoxFlow.width; + height: 200 + + Image { + source: model.type === 'imageEmbed' ? model.value : '' + sourceSize.width: 400 + sourceSize.height: 200 + } + } + } + } + } + } +} \ No newline at end of file diff --git a/scripts/system/domainChat/qml_widgets/TemplateNotification.qml b/scripts/system/domainChat/qml_widgets/TemplateNotification.qml new file mode 100644 index 0000000000..e522d58c54 --- /dev/null +++ b/scripts/system/domainChat/qml_widgets/TemplateNotification.qml @@ -0,0 +1,59 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.3 + +Component { + id: template_notification + + Rectangle { + property int index: delegateIndex + property string username: delegateUsername + + color: "#171717" + width: parent.width + height: 40 + + Item { + width: 10 + height: parent.height + + Rectangle { + height: parent.height + width: 5 + color: "#505186" + } + } + + Item { + width: parent.width - parent.children[0].width - 5 + height: parent.height + anchors.left: parent.children[0].right + + TextEdit { + text: delegateText + color: "white" + font.pointSize: 12 + readOnly: true + width: parent.width * 0.8 + selectByMouse: true + selectByKeyboard: true + height: parent.height + wrapMode: Text.Wrap + verticalAlignment: Text.AlignVCenter + font.italic: true + } + + Text { + text: delegateDate + color: "white" + font.pointSize: 12 + anchors.right: parent.right + height: parent.height + wrapMode: Text.Wrap + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + font.italic: true + } + } + } +} \ No newline at end of file