mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +02:00
Broke out templates into their own files.
This commit is contained in:
parent
00451ca1f7
commit
48c690a2df
3 changed files with 223 additions and 215 deletions
|
@ -2,6 +2,7 @@ import QtQuick 2.7
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import controlsUit 1.0 as HifiControlsUit
|
import controlsUit 1.0 as HifiControlsUit
|
||||||
|
import "./qml_widgets"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: Qt.rgba(0.1,0.1,0.1,1)
|
color: Qt.rgba(0.1,0.1,0.1,1)
|
||||||
|
@ -376,221 +377,8 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Templates
|
// Templates
|
||||||
Component {
|
TemplateChatMessage { id: template_chat_message }
|
||||||
id: template_chat_message
|
TemplateNotification { id: template_notification }
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
property var channels: {
|
property var channels: {
|
||||||
"local": local,
|
"local": local,
|
||||||
|
|
161
scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml
Normal file
161
scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue