Uploading pictures, videos and documents work, status bar still missing
This commit is contained in:
parent
5fa2a1200f
commit
35e9373f49
1 changed files with 55 additions and 38 deletions
|
@ -133,7 +133,24 @@ Page {
|
||||||
attachmentPreviewRow.isPicture = false;
|
attachmentPreviewRow.isPicture = false;
|
||||||
attachmentPreviewRow.isVideo = false;
|
attachmentPreviewRow.isVideo = false;
|
||||||
attachmentPreviewRow.isDocument = false;
|
attachmentPreviewRow.isDocument = false;
|
||||||
attachmentPreviewRow.filePath = "";
|
attachmentPreviewRow.fileProperties = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
function controlEnterKey() {
|
||||||
|
if (newMessageTextField.text.length !== 0
|
||||||
|
|| attachmentPreviewRow.isPicture
|
||||||
|
|| attachmentPreviewRow.isDocument
|
||||||
|
|| attachmentPreviewRow.isVideo) {
|
||||||
|
newMessageSendButton.enabled = true;
|
||||||
|
if (tdLibWrapper.getSendByEnter()) {
|
||||||
|
EnterKey.enabled = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newMessageSendButton.enabled = false;
|
||||||
|
if (tdLibWrapper.getSendByEnter()) {
|
||||||
|
EnterKey.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMessage() {
|
function sendMessage() {
|
||||||
|
@ -142,19 +159,20 @@ Page {
|
||||||
} else {
|
} else {
|
||||||
if (attachmentPreviewRow.visible) {
|
if (attachmentPreviewRow.visible) {
|
||||||
if (attachmentPreviewRow.isPicture) {
|
if (attachmentPreviewRow.isPicture) {
|
||||||
tdLibWrapper.sendPhotoMessage(chatInformation.id, attachmentPreviewRow.filePath, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
tdLibWrapper.sendPhotoMessage(chatInformation.id, attachmentPreviewRow.fileProperties.filePath, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
||||||
}
|
}
|
||||||
if (attachmentPreviewRow.isVideo) {
|
if (attachmentPreviewRow.isVideo) {
|
||||||
tdLibWrapper.sendVideoMessage(chatInformation.id, attachmentPreviewRow.filePath, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
tdLibWrapper.sendVideoMessage(chatInformation.id, attachmentPreviewRow.fileProperties.filePath, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
||||||
}
|
}
|
||||||
if (attachmentPreviewRow.isDocument) {
|
if (attachmentPreviewRow.isDocument) {
|
||||||
tdLibWrapper.sendDocumentMessage(chatInformation.id, attachmentPreviewRow.filePath, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
tdLibWrapper.sendDocumentMessage(chatInformation.id, attachmentPreviewRow.fileProperties.filePath, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
||||||
}
|
}
|
||||||
clearAttachmentPreviewRow();
|
clearAttachmentPreviewRow();
|
||||||
} else {
|
} else {
|
||||||
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
controlEnterKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -836,9 +854,10 @@ Page {
|
||||||
onSelectedContentPropertiesChanged: {
|
onSelectedContentPropertiesChanged: {
|
||||||
attachmentOptionsRow.visible = false;
|
attachmentOptionsRow.visible = false;
|
||||||
console.log("Selected photo: " + selectedContentProperties.filePath );
|
console.log("Selected photo: " + selectedContentProperties.filePath );
|
||||||
attachmentPreviewRow.filePath = selectedContentProperties.filePath;
|
attachmentPreviewRow.fileProperties = selectedContentProperties;
|
||||||
attachmentPreviewRow.isPicture = true;
|
attachmentPreviewRow.isPicture = true;
|
||||||
attachmentPreviewRow.visible = true;
|
attachmentPreviewRow.visible = true;
|
||||||
|
controlEnterKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -849,9 +868,10 @@ Page {
|
||||||
onSelectedContentPropertiesChanged: {
|
onSelectedContentPropertiesChanged: {
|
||||||
attachmentOptionsRow.visible = false;
|
attachmentOptionsRow.visible = false;
|
||||||
console.log("Selected video: " + selectedContentProperties.filePath );
|
console.log("Selected video: " + selectedContentProperties.filePath );
|
||||||
attachmentPreviewRow.filePath = selectedContentProperties.filePath;
|
attachmentPreviewRow.fileProperties = selectedContentProperties;
|
||||||
attachmentPreviewRow.isVideo = true;
|
attachmentPreviewRow.isVideo = true;
|
||||||
attachmentPreviewRow.visible = true;
|
attachmentPreviewRow.visible = true;
|
||||||
|
controlEnterKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,9 +882,10 @@ Page {
|
||||||
onSelectedContentPropertiesChanged: {
|
onSelectedContentPropertiesChanged: {
|
||||||
attachmentOptionsRow.visible = false;
|
attachmentOptionsRow.visible = false;
|
||||||
console.log("Selected document: " + selectedContentProperties.filePath );
|
console.log("Selected document: " + selectedContentProperties.filePath );
|
||||||
attachmentPreviewRow.filePath = selectedContentProperties.filePath;
|
attachmentPreviewRow.fileProperties = selectedContentProperties;
|
||||||
attachmentPreviewRow.isDocument = true;
|
attachmentPreviewRow.isDocument = true;
|
||||||
attachmentPreviewRow.visible = true;
|
attachmentPreviewRow.visible = true;
|
||||||
|
controlEnterKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -890,12 +911,14 @@ Page {
|
||||||
id: attachmentOptionsRow
|
id: attachmentOptionsRow
|
||||||
visible: false
|
visible: false
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
width: parent.width
|
||||||
|
layoutDirection: Qt.RightToLeft
|
||||||
spacing: Theme.paddingMedium
|
spacing: Theme.paddingMedium
|
||||||
IconButton {
|
IconButton {
|
||||||
id: documentAttachmentButton
|
id: imageAttachmentButton
|
||||||
icon.source: "image://theme/icon-m-document"
|
icon.source: "image://theme/icon-m-image"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(documentPickerPage);
|
pageStack.push(imagePickerPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IconButton {
|
IconButton {
|
||||||
|
@ -906,10 +929,10 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IconButton {
|
IconButton {
|
||||||
id: imageAttachmentButton
|
id: documentAttachmentButton
|
||||||
icon.source: "image://theme/icon-m-image"
|
icon.source: "image://theme/icon-m-document"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(imagePickerPage);
|
pageStack.push(documentPickerPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -918,12 +941,23 @@ Page {
|
||||||
id: attachmentPreviewRow
|
id: attachmentPreviewRow
|
||||||
visible: false
|
visible: false
|
||||||
spacing: Theme.paddingMedium
|
spacing: Theme.paddingMedium
|
||||||
|
width: parent.width
|
||||||
|
layoutDirection: Qt.RightToLeft
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
property bool isPicture: false;
|
property bool isPicture: false;
|
||||||
property bool isVideo: false;
|
property bool isVideo: false;
|
||||||
property bool isDocument: false;
|
property bool isDocument: false;
|
||||||
property string filePath: "";
|
property variant fileProperties;
|
||||||
|
|
||||||
|
IconButton {
|
||||||
|
id: removeAttachmentsIconButton
|
||||||
|
icon.source: "image://theme/icon-m-clear"
|
||||||
|
onClicked: {
|
||||||
|
clearAttachmentPreviewRow();
|
||||||
|
controlEnterKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Thumbnail {
|
Thumbnail {
|
||||||
id: attachmentPreviewImage
|
id: attachmentPreviewImage
|
||||||
|
@ -933,28 +967,21 @@ Page {
|
||||||
sourceSize.height: height
|
sourceSize.height: height
|
||||||
|
|
||||||
fillMode: Thumbnail.PreserveAspectCrop
|
fillMode: Thumbnail.PreserveAspectCrop
|
||||||
source: attachmentPreviewRow.filePath
|
mimeType: attachmentPreviewRow.fileProperties.mimeType
|
||||||
|
source: attachmentPreviewRow.fileProperties.url
|
||||||
visible: attachmentPreviewRow.isPicture || attachmentPreviewRow.isVideo
|
visible: attachmentPreviewRow.isPicture || attachmentPreviewRow.isVideo
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
width: parent.width - Theme.paddingMedium - removeAttachmentsIconButton.width
|
|
||||||
|
|
||||||
id: attachmentPreviewText
|
id: attachmentPreviewText
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
text: attachmentPreviewRow.filePath;
|
text: attachmentPreviewRow.fileProperties.fileName;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
color: Theme.secondaryColor
|
color: Theme.secondaryColor
|
||||||
visible: attachmentPreviewRow.isPicture
|
visible: attachmentPreviewRow.isDocument
|
||||||
}
|
|
||||||
|
|
||||||
IconButton {
|
|
||||||
id: removeAttachmentsIconButton
|
|
||||||
icon.source: "image://theme/icon-m-clear"
|
|
||||||
onClicked: {
|
|
||||||
clearAttachmentPreviewRow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,17 +1037,7 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if (text.length === 0) {
|
controlEnterKey();
|
||||||
newMessageSendButton.enabled = false;
|
|
||||||
if (tdLibWrapper.getSendByEnter()) {
|
|
||||||
EnterKey.enabled = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newMessageSendButton.enabled = true;
|
|
||||||
if (tdLibWrapper.getSendByEnter()) {
|
|
||||||
EnterKey.enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue