Warning, /rolisteam/rolisteam/src/libraries/qml_views/InstantMessaging/ChatView.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 0002 import QtQuick.Controls 0003 import QtQuick.Layouts 0004 import QtMultimedia 0005 import InstantMessaging 0006 import Customization 0007 0008 Item { 0009 id: root 0010 property QtObject styleSheet: Theme.styleSheet("InstantMessaging") 0011 property QtObject paletteSheet: Theme.styleSheet("Palette") 0012 property alias localPersonModel: imEditText.model 0013 property alias chatroomModel: repeater.model 0014 property ChatRoom chatRoom: chatroomModel.get(tabHeader.currentIndex) 0015 property alias tabBarHeight: tabHeader.height 0016 property int tabBarRightMargin: 0 0017 signal zoomChanged(var delta) 0018 signal addChat(var title, var all, var recipiants) 0019 signal split(var uuid, var index) 0020 signal detach(var uuid, var index) 0021 0022 SoundEffect { 0023 id: effect 0024 source: "qrc:/resources/sounds/Doorbell.wav" 0025 muted: !sideMenu.sound 0026 volume: 1.0 0027 } 0028 0029 0030 MouseArea { 0031 anchors.fill: parent 0032 acceptedButtons: Qt.LeftButton | Qt.RightButton 0033 onClicked: (mouse)=>{ 0034 if (mouse.button === Qt.RightButton) 0035 contextMenu.popup() 0036 } 0037 onPressAndHold:(mouse)=> { 0038 if (mouse.source === Qt.MouseEventNotSynthesized) 0039 contextMenu.popup() 0040 } 0041 0042 onWheel: (wheel) => {//(wheel) 0043 if (wheel.modifiers & Qt.ControlModifier) { 0044 zoomChanged(wheel.angleDelta.y / 240) 0045 /*fontFactor += wheel.angleDelta.y / 240; 0046 if(fontFactor<1.0) 0047 fontFactor=1.0 0048 else if(fontFactor>10.0) 0049 fontFactor=10.0*/ 0050 } 0051 } 0052 0053 Menu { 0054 id: contextMenu 0055 Action { 0056 text: qsTr("Split view") 0057 onTriggered: { 0058 root.split(root.chatRoom.uuid, tabHeader.currentIndex) 0059 root.chatRoom = chatroomModel.get(tabHeader.currentIndex) 0060 } 0061 } 0062 Action { 0063 text: qsTr("Detach") 0064 onTriggered: root.detach(root.chatRoom.uuid, tabHeader.currentIndex) 0065 } 0066 Action { 0067 text: qsTr("Reatach") 0068 //onTriggered: root.detach(root.chatRoom.uuid, tabHeader.currentIndex) 0069 } 0070 } 0071 } 0072 0073 ColumnLayout { 0074 anchors.fill: parent 0075 RowLayout { 0076 Layout.fillWidth: true 0077 TabBar { 0078 id: tabHeader 0079 Layout.fillWidth: true 0080 Layout.rightMargin: root.tabBarRightMargin 0081 Repeater { 0082 id: repeater 0083 TabButton { 0084 id: tabButton 0085 property bool current: tabHeader.currentIndex === index 0086 background: Rectangle { 0087 color: tabButton.current ? root.paletteSheet.alternateBase : model.unread ? root.paletteSheet.highlight : root.paletteSheet.mid 0088 } 0089 0090 contentItem: RowLayout { 0091 Label { 0092 text: model.unread ? "%1 (\*)".arg(model.title) : model.title 0093 Layout.fillWidth: true 0094 horizontalAlignment: Qt.AlignHCenter 0095 color: tabButton.current ? root.paletteSheet.text : root.paletteSheet.button 0096 } 0097 ToolButton { 0098 visible: model.closable 0099 text: "X" 0100 ToolTip.text: qsTr("close") 0101 ToolTip.visible: down 0102 } 0103 } 0104 Connections { 0105 target: model.chatroom 0106 function onUnreadMessageChanged(unread) { 0107 if(unread && !tabButton.current) 0108 effect.play() 0109 } 0110 } 0111 } 0112 } 0113 } 0114 } 0115 0116 SplitView { 0117 Layout.fillWidth: true 0118 Layout.fillHeight: true 0119 Layout.leftMargin: root.styleSheet.sideMargin 0120 Layout.rightMargin: root.styleSheet.sideMargin 0121 orientation: Qt.Vertical 0122 0123 ListView { 0124 id: listView 0125 SplitView.fillWidth: true 0126 SplitView.fillHeight: true 0127 model: root.chatRoom.messageModel 0128 clip: true 0129 spacing: 5 0130 verticalLayoutDirection: ListView.BottomToTop 0131 delegate: Component { 0132 id: delegateComponent 0133 Loader { 0134 property string writerIdldr: model.writerId 0135 property string messageTextldr: model.text 0136 property bool localldr: model.local 0137 property string timeldr: model.time 0138 property string writerNameldr: model.writerName 0139 property real windowWidthldr: parent.width 0140 property url imageLinkldr: model.imageLink ?? "" 0141 0142 property bool isTextMessage: model.type === MessageInterface.Text 0143 property bool isDiceMessage: model.type === MessageInterface.Dice 0144 property bool isCommandMessage: model.type === MessageInterface.Command 0145 property bool isErrorMessage: model.type === MessageInterface.Error 0146 property bool mustBeOnTheRight: model.local && (isTextMessage || isCommandMessage) 0147 anchors.right: mustBeOnTheRight ? parent.right : undefined 0148 width: (isDiceMessage || isErrorMessage) ? parent.width-10 : undefined 0149 source: isTextMessage ? "TextMessageDelegate.qml" : 0150 isCommandMessage ? "CommandMessageDelegate.qml" : 0151 isDiceMessage ? "DiceMessageDelegate.qml" : "ErrorMessageDelegate.qml" 0152 } 0153 } 0154 } 0155 0156 InstantMessagingEditText { 0157 id: imEditText 0158 SplitView.fillWidth: true 0159 SplitView.preferredHeight: root.styleSheet.preferredHeight 0160 0161 onSendClicked: (text, imageLink) => { 0162 root.chatRoom.addMessage(text,imageLink, imEditText.currentPersonId, imEditText.currentPersonName) 0163 } 0164 function updateUnread() { 0165 root.chatRoom.unreadMessage = false 0166 } 0167 onFocusGained: updateUnread() 0168 } 0169 0170 } 0171 } 0172 }