status-desktop/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml

92 lines
2.3 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
2020-05-28 12:56:43 +00:00
import "../../../../imports"
import "../../../../shared"
import "../../Profile/Sections/Contacts/"
2020-05-28 12:56:43 +00:00
import "./"
2020-05-29 16:27:50 +00:00
ModalPopup {
property string validationError: ""
function validate() {
// TODO change this when we support ENS names
if (!Utils.isChatKey(chatKey.text)) {
validationError = "This needs to be a valid chat key"
} else {
validationError = ""
}
return validationError === ""
}
function doJoin() {
if (chatKey.text !== "") {
if (!validate()) {
return
}
chatsModel.joinChat(chatKey.text, Constants.chatTypeOneToOne);
} else if (contactListView.selectedContact.checked) {
chatsModel.joinChat(contactListView.selectedContact.parent.address, Constants.chatTypeOneToOne);
} else {
return;
}
popup.close();
}
2020-05-28 12:56:43 +00:00
id: popup
2020-05-29 16:27:50 +00:00
title: qsTr("New chat")
2020-05-29 18:38:11 +00:00
onOpened: {
chatKey.text = "";
chatKey.forceActiveFocus(Qt.MouseFocusReason)
if (contactListView.selectedContact) {
contactListView.selectedContact.checked = false
}
2020-05-29 18:38:11 +00:00
}
Input {
id: chatKey
placeholderText: qsTr("Enter ENS username or chat key")
Keys.onEnterPressed: doJoin()
Keys.onReturnPressed: doJoin()
validationError: popup.validationError
textField.onEditingFinished: {
validate()
}
2020-05-29 16:27:50 +00:00
}
2020-05-28 12:56:43 +00:00
ContactList {
id: contactListView
contacts: profileModel.contactList
selectable: true
}
2020-05-29 16:27:50 +00:00
footer: Button {
width: 44
height: 44
anchors.bottom: parent.bottom
anchors.right: parent.right
SVGImage {
2020-05-29 16:27:50 +00:00
source: chatKey.text == "" ? "../../../img/arrow-button-inactive.svg" : "../../../img/arrow-btn-active.svg"
width: 50
height: 50
2020-05-28 12:56:43 +00:00
}
2020-05-29 16:27:50 +00:00
background: Rectangle {
color: "transparent"
2020-05-28 12:56:43 +00:00
}
2020-05-29 16:27:50 +00:00
MouseArea {
id: btnMAnewChat
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked : doJoin()
2020-05-28 12:56:43 +00:00
}
}
}
/*##^##
Designer {
D{i:0;height:300;width:300}
}
##^##*/