Prepare message attachments

This commit is contained in:
Sebastian J. Wolf 2020-09-23 23:41:17 +02:00
parent f2284a8fe9
commit e222ab115d

View file

@ -841,74 +841,27 @@ Page {
height: sendMessageColumn.height + Theme.paddingMedium height: sendMessageColumn.height + Theme.paddingMedium
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Column { TextArea {
id: sendMessageColumn id: newMessageTextField
width: parent.width - newMessageSendButton.width width: parent.width - attachmentIconButton.width - newMessageSendButton.width
height: Math.min(chatContainer.height / 3, implicitHeight)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
font.pixelSize: Theme.fontSizeSmall
TextArea { placeholderText: qsTr("Your message")
id: newMessageTextField labelVisible: false
width: parent.width textLeftMargin: 0
height: Math.min(chatContainer.height / 3, implicitHeight) textTopMargin: 0
font.pixelSize: Theme.fontSizeSmall onFocusChanged: {
placeholderText: qsTr("Your message") if (!focus) {
labelVisible: false newMessageInReplyToRow.inReplyToMessage = null;
textLeftMargin: 0 if (newMessageColumn.editMessageId !== "0") {
textTopMargin: 0 newMessageColumn.editMessageId = "0";
onFocusChanged: {
if (!focus) {
newMessageInReplyToRow.inReplyToMessage = null;
if (newMessageColumn.editMessageId !== "0") {
newMessageColumn.editMessageId = "0";
newMessageTextField.text = "";
}
}
}
EnterKey.onClicked: {
if (tdLibWrapper.getSendByEnter()) {
if (newMessageColumn.editMessageId !== "0") {
tdLibWrapper.editMessageText(chatInformation.id, newMessageColumn.editMessageId, newMessageTextField.text);
} else {
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
}
newMessageTextField.text = ""; newMessageTextField.text = "";
newMessageTextField.focus = false;
}
}
Component.onCompleted: {
if (tdLibWrapper.getSendByEnter()) {
EnterKey.iconSource = "image://theme/icon-m-chat";
EnterKey.enabled = false;
}
}
onTextChanged: {
if (text.length === 0) {
newMessageSendButton.enabled = false;
if (tdLibWrapper.getSendByEnter()) {
EnterKey.enabled = false;
}
} else {
newMessageSendButton.enabled = true;
if (tdLibWrapper.getSendByEnter()) {
EnterKey.enabled = true;
}
} }
} }
} }
} EnterKey.onClicked: {
if (tdLibWrapper.getSendByEnter()) {
Column {
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingSmall
IconButton {
id: newMessageSendButton
icon.source: "image://theme/icon-m-chat"
anchors.horizontalCenter: parent.horizontalCenter
enabled: false
onClicked: {
if (newMessageColumn.editMessageId !== "0") { if (newMessageColumn.editMessageId !== "0") {
tdLibWrapper.editMessageText(chatInformation.id, newMessageColumn.editMessageId, newMessageTextField.text); tdLibWrapper.editMessageText(chatInformation.id, newMessageColumn.editMessageId, newMessageTextField.text);
} else { } else {
@ -918,7 +871,54 @@ Page {
newMessageTextField.focus = false; newMessageTextField.focus = false;
} }
} }
Component.onCompleted: {
if (tdLibWrapper.getSendByEnter()) {
EnterKey.iconSource = "image://theme/icon-m-chat";
EnterKey.enabled = false;
}
}
onTextChanged: {
if (text.length === 0) {
newMessageSendButton.enabled = false;
if (tdLibWrapper.getSendByEnter()) {
EnterKey.enabled = false;
}
} else {
newMessageSendButton.enabled = true;
if (tdLibWrapper.getSendByEnter()) {
EnterKey.enabled = true;
}
}
}
} }
IconButton {
id: attachmentIconButton
icon.source: "image://theme/icon-m-attach"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
}
}
IconButton {
id: newMessageSendButton
icon.source: "image://theme/icon-m-chat"
anchors.verticalCenter: parent.verticalCenter
enabled: false
onClicked: {
if (newMessageColumn.editMessageId !== "0") {
tdLibWrapper.editMessageText(chatInformation.id, newMessageColumn.editMessageId, newMessageTextField.text);
} else {
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
}
newMessageTextField.text = "";
newMessageTextField.focus = false;
}
}
} }
} }