diff --git a/qml/components/VoiceNoteOverlay.qml b/qml/components/VoiceNoteOverlay.qml
index 66dcb4f..423bdfb 100644
--- a/qml/components/VoiceNoteOverlay.qml
+++ b/qml/components/VoiceNoteOverlay.qml
@@ -29,14 +29,15 @@ Item {
property int recordingState: fernschreiberUtils.getVoiceNoteRecordingState();
property int recordingDuration: 0;
+ property bool recordingDone: false;
function handleRecordingState() {
switch (recordingState) {
case FernschreiberUtilities.Unavailable:
recordingStateLabel.text = qsTr("Unavailable");
break;
- case FernschreiberUtilities.Stopped:
- recordingStateLabel.text = qsTr("Stopped");
+ case FernschreiberUtilities.Ready:
+ recordingStateLabel.text = qsTr("Ready");
break;
case FernschreiberUtilities.Starting:
recordingStateLabel.text = qsTr("Starting");
@@ -167,6 +168,7 @@ Item {
onClicked: {
recordButton.visible = true;
fernschreiberUtils.stopRecordingVoiceNote();
+ recordingDone = true;
}
}
}
@@ -194,6 +196,22 @@ Item {
}
}
+ Button {
+ visible: recordingDone
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ }
+ text: qsTr("Use recording")
+ onClicked: {
+ attachmentOptionsRow.isNeeded = false;
+ attachmentPreviewRow.isVoiceNote = true;
+ attachmentPreviewRow.attachmentDescription = qsTr("Voice Note (%1)").arg(recordingDurationLabel.text);
+ attachmentPreviewRow.visible = true;
+ controlSendButton();
+ voiceNoteOverlayLoader.active = false;
+ }
+ }
+
}
}
diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml
index 0cdbb6f..b652072 100644
--- a/qml/pages/ChatPage.qml
+++ b/qml/pages/ChatPage.qml
@@ -211,14 +211,17 @@ Page {
attachmentPreviewRow.isPicture = false;
attachmentPreviewRow.isVideo = false;
attachmentPreviewRow.isDocument = false;
+ attachmentPreviewRow.isVoiceNote = false;
attachmentPreviewRow.fileProperties = {};
+ attachmentPreviewRow.attachmentDescription = "";
}
function controlSendButton() {
if (newMessageTextField.text.length !== 0
|| attachmentPreviewRow.isPicture
|| attachmentPreviewRow.isDocument
- || attachmentPreviewRow.isVideo) {
+ || attachmentPreviewRow.isVideo
+ || attachmentPreviewRow.isVoiceNote) {
newMessageSendButton.enabled = true;
} else {
newMessageSendButton.enabled = false;
@@ -239,6 +242,9 @@ Page {
if (attachmentPreviewRow.isDocument) {
tdLibWrapper.sendDocumentMessage(chatInformation.id, attachmentPreviewRow.fileProperties.filePath, newMessageTextField.text, newMessageColumn.replyToMessageId);
}
+ if (attachmentPreviewRow.isVoiceNote) {
+ tdLibWrapper.sendVoiceNoteMessage(chatInformation.id, fernschreiberUtils.voiceNotePath(), newMessageTextField.text, newMessageColumn.replyToMessageId);
+ }
clearAttachmentPreviewRow();
} else {
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
@@ -1300,7 +1306,9 @@ Page {
property bool isPicture: false;
property bool isVideo: false;
property bool isDocument: false;
+ property bool isVoiceNote: false;
property var fileProperties:({});
+ property string attachmentDescription: "";
IconButton {
id: removeAttachmentsIconButton
@@ -1327,13 +1335,13 @@ Page {
Label {
id: attachmentPreviewText
font.pixelSize: Theme.fontSizeSmall
- text: typeof attachmentPreviewRow.fileProperties !== "undefined" ? attachmentPreviewRow.fileProperties.fileName || "" : "";
+ text: attachmentPreviewRow.isVoiceNote ? attachmentPreviewRow.attachmentDescription : ( typeof attachmentPreviewRow.fileProperties !== "undefined" ? attachmentPreviewRow.fileProperties.fileName || "" : "" );
anchors.verticalCenter: parent.verticalCenter
maximumLineCount: 1
truncationMode: TruncationMode.Fade
color: Theme.secondaryColor
- visible: attachmentPreviewRow.isDocument
+ visible: attachmentPreviewRow.isDocument || attachmentPreviewRow.isVoiceNote
}
}
diff --git a/src/fernschreiberutils.cpp b/src/fernschreiberutils.cpp
index d079d59..0d56554 100644
--- a/src/fernschreiberutils.cpp
+++ b/src/fernschreiberutils.cpp
@@ -55,6 +55,11 @@ FernschreiberUtils::FernschreiberUtils(QObject *parent) : QObject(parent)
}
+FernschreiberUtils::~FernschreiberUtils()
+{
+ this->cleanUp();
+}
+
QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, const QVariantMap &messageContent, const bool isChannel, const qlonglong currentUserId, const QVariantMap &messageSender)
{
if (messageContent.isEmpty()) {
@@ -179,12 +184,7 @@ QString FernschreiberUtils::getUserName(const QVariantMap &userInformation)
void FernschreiberUtils::startRecordingVoiceNote()
{
LOG("Start recording voice note...");
- QString voiceNotePath = this->voiceNotePath();
- LOG("Using temporary file at " << voiceNotePath);
- if (QFile::exists(voiceNotePath)) {
- LOG("Removing old temporary file...");
- QFile::remove(voiceNotePath);
- }
+ this->cleanUp();
this->audioRecorder.setVolume(1);
this->audioRecorder.record();
}
@@ -216,7 +216,7 @@ void FernschreiberUtils::handleAudioRecorderStatusChanged(QMediaRecorder::Status
break;
case QMediaRecorder::LoadedStatus:
case QMediaRecorder::PausedStatus:
- this->voiceNoteRecordingState = VoiceNoteRecordingState::Stopped;
+ this->voiceNoteRecordingState = VoiceNoteRecordingState::Ready;
break;
case QMediaRecorder::StartingStatus:
this->voiceNoteRecordingState = VoiceNoteRecordingState::Starting;
@@ -230,3 +230,12 @@ void FernschreiberUtils::handleAudioRecorderStatusChanged(QMediaRecorder::Status
}
emit voiceNoteRecordingStateChanged(this->voiceNoteRecordingState);
}
+
+void FernschreiberUtils::cleanUp()
+{
+ QString voiceNotePath = this->voiceNotePath();
+ if (QFile::exists(voiceNotePath)) {
+ LOG("Removing old temporary file...");
+ QFile::remove(voiceNotePath);
+ }
+}
diff --git a/src/fernschreiberutils.h b/src/fernschreiberutils.h
index 16e80c3..74d7378 100644
--- a/src/fernschreiberutils.h
+++ b/src/fernschreiberutils.h
@@ -29,10 +29,11 @@ class FernschreiberUtils : public QObject
Q_OBJECT
public:
explicit FernschreiberUtils(QObject *parent = nullptr);
+ ~FernschreiberUtils();
enum VoiceNoteRecordingState {
Unavailable,
- Stopped,
+ Ready,
Starting,
Recording,
Stopping
@@ -58,6 +59,8 @@ private:
QAudioRecorder audioRecorder;
VoiceNoteRecordingState voiceNoteRecordingState;
+ void cleanUp();
+
};
#endif // FERNSCHREIBERUTILS_H
diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp
index fe436c8..a791319 100644
--- a/src/tdlibwrapper.cpp
+++ b/src/tdlibwrapper.cpp
@@ -473,6 +473,30 @@ void TDLibWrapper::sendDocumentMessage(const QString &chatId, const QString &fil
this->sendRequest(requestObject);
}
+void TDLibWrapper::sendVoiceNoteMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId)
+{
+ LOG("Sending voice note message" << chatId << filePath << message << replyToMessageId);
+ QVariantMap requestObject;
+ requestObject.insert(_TYPE, "sendMessage");
+ requestObject.insert(CHAT_ID, chatId);
+ if (replyToMessageId != "0") {
+ requestObject.insert("reply_to_message_id", replyToMessageId);
+ }
+ QVariantMap inputMessageContent;
+ inputMessageContent.insert(_TYPE, "inputMessageVoiceNote");
+ QVariantMap formattedText;
+ formattedText.insert("text", message);
+ formattedText.insert(_TYPE, "formattedText");
+ inputMessageContent.insert("caption", formattedText);
+ QVariantMap documentInputFile;
+ documentInputFile.insert(_TYPE, "inputFileLocal");
+ documentInputFile.insert("path", filePath);
+ inputMessageContent.insert("voice_note", documentInputFile);
+
+ requestObject.insert("input_message_content", inputMessageContent);
+ this->sendRequest(requestObject);
+}
+
void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId)
{
LOG("Sending sticker message" << chatId << fileId << replyToMessageId);
diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h
index c24941b..026bb69 100644
--- a/src/tdlibwrapper.h
+++ b/src/tdlibwrapper.h
@@ -139,6 +139,7 @@ public:
Q_INVOKABLE void sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendDocumentMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
+ Q_INVOKABLE void sendVoiceNoteMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &replyToMessageId = "0");
Q_INVOKABLE void forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, bool sendCopy, bool removeCaption);
diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts
index 6894a9e..6f36201 100644
--- a/translations/harbour-fernschreiber-de.ts
+++ b/translations/harbour-fernschreiber-de.ts
@@ -1436,31 +1436,39 @@
VoiceNoteOverlay
-
+ Eine Sprachnachricht aufzeichnen
-
+ Drücken Sie den Knopf, um die Aufzeichnung zu starten
-
+ Nicht verfügbar
-
-
+
+ Bereit
-
+ Startet
-
+ Zeichnet auf
-
+ Stoppt
+
+
+
+ Aufzeichnung verwenden
+
+
+
+ Sprachnachricht (%1)
diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts
index e474f3f..d7e1769 100644
--- a/translations/harbour-fernschreiber-en.ts
+++ b/translations/harbour-fernschreiber-en.ts
@@ -1436,31 +1436,39 @@
VoiceNoteOverlay
-
+ Record a Voice Note
-
+ Press the button to start recording
-
-
-
-
-
+ Unavailable
-
+ Starting
-
+ Recording
-
+ Stopping
+
+
+
+ Use recording
+
+
+
+ Voice Note (%1)
+
+
+
+ Ready
diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts
index 5f812e5..75b4911 100644
--- a/translations/harbour-fernschreiber-es.ts
+++ b/translations/harbour-fernschreiber-es.ts
@@ -1425,10 +1425,6 @@
-
-
-
-
@@ -1441,6 +1437,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts
index cb1004c..e2eaba2 100644
--- a/translations/harbour-fernschreiber-fi.ts
+++ b/translations/harbour-fernschreiber-fi.ts
@@ -1447,10 +1447,6 @@
-
-
-
-
@@ -1463,6 +1459,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts
index a160d2d..ed24a74 100644
--- a/translations/harbour-fernschreiber-hu.ts
+++ b/translations/harbour-fernschreiber-hu.ts
@@ -1425,10 +1425,6 @@
-
-
-
-
@@ -1441,6 +1437,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts
index d0319bc..7bc968a 100644
--- a/translations/harbour-fernschreiber-it.ts
+++ b/translations/harbour-fernschreiber-it.ts
@@ -1446,10 +1446,6 @@
-
-
-
-
@@ -1462,6 +1458,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts
index fc7f215..b6ba872 100644
--- a/translations/harbour-fernschreiber-pl.ts
+++ b/translations/harbour-fernschreiber-pl.ts
@@ -1467,10 +1467,6 @@
-
-
-
-
@@ -1483,6 +1479,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts
index d3b4699..68f8e57 100644
--- a/translations/harbour-fernschreiber-ru.ts
+++ b/translations/harbour-fernschreiber-ru.ts
@@ -1467,10 +1467,6 @@
-
-
-
-
@@ -1483,6 +1479,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts
index 0bbb2e4..81e5a0a 100644
--- a/translations/harbour-fernschreiber-sv.ts
+++ b/translations/harbour-fernschreiber-sv.ts
@@ -1446,10 +1446,6 @@
-
-
-
-
@@ -1462,6 +1458,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts
index 437b5d8..fa3ccfe 100644
--- a/translations/harbour-fernschreiber-zh_CN.ts
+++ b/translations/harbour-fernschreiber-zh_CN.ts
@@ -1425,10 +1425,6 @@
-
-
-
-
@@ -1441,6 +1437,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview
diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts
index 5664771..74e0ed6 100644
--- a/translations/harbour-fernschreiber.ts
+++ b/translations/harbour-fernschreiber.ts
@@ -1446,10 +1446,6 @@
-
-
-
-
@@ -1462,6 +1458,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
WebPagePreview