Warning, /rolisteam/rolisteam/src/libraries/qml_views/InstantMessaging/InstantMessagingEditText.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick
0002 import QtQuick.Controls
0003 import QtQuick.Layouts
0004 import InstantMessaging
0005 import Customization
0006 
0007 Frame {
0008     id: root
0009     property alias model: selector.model
0010     property alias currentPersonId: selector.currentValue
0011     property alias currentPersonName: selector.currentText
0012     signal sendClicked(string text, url imageLink)
0013     signal focusGained()
0014     padding: 0
0015 
0016     TextWriterController {
0017         id: textCtrl
0018         text: edit.text
0019         onTextComputed: {
0020             root.sendClicked(textCtrl.text, textCtrl.imageLink)
0021         }
0022     }
0023 
0024     Connections {
0025         target: textCtrl
0026         function onTextChanged(text){ edit.text = text }
0027     }
0028 
0029     ColumnLayout {
0030         anchors.fill: parent
0031 
0032         RowLayout {
0033             Layout.fillWidth: true
0034             Layout.alignment: Qt.AlignTop
0035             ToolBar {
0036                 Layout.fillWidth: true
0037                 RowLayout {
0038                     ComboBox {
0039                         id: selector
0040                         textRole: "name"
0041                         valueRole: "uuid"
0042                         onCountChanged: {
0043                             if(selector.currentIndex < 0 && count > 0)
0044                                 selector.currentIndex = 0
0045                         }
0046 
0047                         contentItem:  RowLayout {
0048                             Image {
0049                                 source: selector.currentValue ? "image://avatar/%1".arg(selector.currentValue) : ""
0050                                 fillMode: Image.PreserveAspectFit
0051                                 Layout.fillHeight: true
0052                                 Layout.leftMargin: 10
0053                                 sourceSize.height: selector.height
0054                                 sourceSize.width: selector.height
0055                             }
0056                             Label {
0057                                 id: nameLbl
0058                                  leftPadding: 0
0059                                  rightPadding: selector.indicator.width + selector.spacing
0060                                  text: selector.displayText
0061                                  font: selector.font
0062                                  Layout.fillHeight: true
0063                                  verticalAlignment: Text.AlignVCenter
0064                                  horizontalAlignment: Text.AlignHCenter
0065                                  elide: Text.ElideRight
0066                                  fontSizeMode : Text.VerticalFit
0067                              }
0068                         }
0069 
0070                         delegate: ItemDelegate {
0071                             width: selector.width
0072                             contentItem: RowLayout {
0073                                 Image {
0074                                     source: "image://avatar/%1".arg(model.uuid)
0075                                     fillMode: Image.PreserveAspectFit
0076                                     sourceSize.height: textlbl.height
0077                                     sourceSize.width: textlbl.height
0078                                 }
0079                                 Label {
0080                                     id: textlbl
0081                                     text: model.name
0082                                 }
0083                             }
0084                             highlighted: selector.highlightedIndex === index
0085                         }
0086                     }
0087                     ToolButton {
0088                         text: "😀"
0089                         font: Theme.imFont
0090                         onClicked: popup.open()
0091                         Popup {
0092                             id: popup
0093                             width: 200
0094                             height: 100
0095                             ScrollView {
0096                                 anchors.fill: parent
0097                                 contentWidth: pane.width
0098                                 contentHeight: pane.height
0099                                 Pane {
0100                                     id: pane
0101                                     padding: 0
0102                                     width: gridLyt.implicitWidth+10
0103                                     height: gridLyt.implicitHeight
0104                                     GridLayout {
0105                                         id: gridLyt
0106 
0107                                         columns: 5
0108                                         columnSpacing: 1
0109                                         rowSpacing: 1
0110                                         Repeater {
0111                                             model: ["😀","😁","😂","😃","😄","😅","😆","😉","😊","😋","😎","😍","😘",
0112                                                     "😗","😙","😚","â˜ē","😐","😑","đŸ˜ļ","😏","đŸ˜Ŗ","đŸ˜Ĩ","😮","đŸ˜¯","đŸ˜Ē",
0113                                                     "đŸ˜Ģ","😴","😌","😛","😜","😝","😒","😓","😔","😕","🙃","😲","☚ī¸",
0114                                                     "😖","😞","😟","đŸ˜ĸ","😭","đŸ˜Ļ","😧","😨","😩","😰","😱",
0115                                                     "đŸ˜ŗ","đŸ˜ĩ","😡","😠","đŸ¤Ŧ","😷","😇","😈","đŸ‘Ŋ","🤖","💩","đŸ˜ē","😸","😹","đŸ˜ģ","đŸ˜ŧ","đŸ˜Ŋ","🙀","đŸ˜ŋ","😾"]
0116                                             ToolButton {
0117                                                 text: modelData
0118                                                 flat: true
0119                                                 objectName: "debug%1".arg(index)
0120                                                 font: Theme.imFont
0121                                                 padding: 0
0122                                                 onClicked: {
0123                                                     edit.text += modelData
0124                                                 }
0125                                             }
0126                                         }
0127                                     }
0128                                 }
0129                             }
0130                         }
0131                     }
0132                 }
0133             }
0134         }
0135         RowLayout {
0136             id: layout
0137             Layout.fillWidth: true
0138             Layout.bottomMargin: 10
0139             function sendMessage() {
0140                 textCtrl.computeText()
0141             }
0142             ScrollView {
0143                 Layout.fillWidth: true
0144                 Layout.fillHeight: true
0145                 clip: true
0146                 TextArea {
0147                     id: edit
0148                     text: textCtrl.text
0149                     onPressed: root.focusGained()
0150                     font: Theme.imFont
0151                     Keys.onUpPressed: textCtrl.up()
0152                     Keys.onDownPressed: textCtrl.down()
0153                     Keys.onReturnPressed: event => {
0154                         if(event.modifiers === Qt.NoModifier)
0155                         {
0156                             layout.sendMessage()
0157                             event.accepted = true
0158                         }
0159                         else
0160                             event.accepted = false
0161                     }
0162                 }
0163             }
0164             Button {
0165                 text: qsTr("send")
0166                 Layout.fillHeight: true
0167                 enabled:  edit.length > 0
0168                 onClicked: {
0169                     layout.sendMessage()
0170                 }
0171             }
0172         }
0173     }
0174 }