diff --git a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp index 0cb35419f..a48ecafc7 100644 --- a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp @@ -110,7 +110,6 @@ void ChatRoomProxyModel::sendMessage(const QString &text){ void ChatRoomProxyModel::compose (const QString& text) { if (mChatRoomModel && !text.isEmpty()) mChatRoomModel->compose(); - gCachedText = text; } int ChatRoomProxyModel::getEntryTypeFilter () { @@ -255,6 +254,10 @@ QString ChatRoomProxyModel::getCachedText() const{ return gCachedText; } +void ChatRoomProxyModel::setCachedText(const QString& text){ + gCachedText = text; +} + void ChatRoomProxyModel::setIsCall(const bool& isCall){ if(mIsCall != isCall) { if(mChatRoomModel){ diff --git a/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp b/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp index 95866a746..d5e3f647a 100644 --- a/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp +++ b/linphone-app/src/components/chat-room/ChatRoomProxyModel.hpp @@ -40,7 +40,7 @@ class ChatRoomProxyModel : public SortFilterProxyModel { Q_PROPERTY(QString fullLocalAddress READ getFullLocalAddress WRITE setFullLocalAddress NOTIFY fullLocalAddressChanged) Q_PROPERTY(ChatRoomModel *chatRoomModel READ getChatRoomModel WRITE setChatRoomModel NOTIFY chatRoomModelChanged) Q_PROPERTY(QList composers READ getComposers NOTIFY isRemoteComposingChanged) - Q_PROPERTY(QString cachedText READ getCachedText) + Q_PROPERTY(QString cachedText READ getCachedText WRITE setCachedText NOTIFY cachedTextChanged) Q_PROPERTY(QString filterText MEMBER mFilterText WRITE setFilterText NOTIFY filterTextChanged) Q_PROPERTY(bool markAsReadEnabled READ markAsReadEnabled WRITE enableMarkAsRead NOTIFY markAsReadEnabledChanged)// Focus is at end of the list. Used to reset message count if not at end @@ -95,6 +95,7 @@ signals: void entryTypeFilterChanged (int type); void filterTextChanged(); void isCallChanged(); + void cachedTextChanged(); protected: bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override; @@ -122,6 +123,7 @@ private: QList getComposers () const; QString getCachedText() const; + void setCachedText(const QString& text); void reload (ChatRoomModel *chatRoomModel); diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp index 574f8acff..6529f2c7d 100644 --- a/linphone-app/src/utils/Utils.cpp +++ b/linphone-app/src/utils/Utils.cpp @@ -638,7 +638,6 @@ bool Utils::isImage(const QString& path){ }else if(!QMimeDatabase().mimeTypeForFile(info).name().contains("image/")) return false; QImageReader reader(path); - qWarning() << reader.imageCount(); return reader.canRead() && reader.imageCount() == 1; } diff --git a/linphone-app/ui/modules/Linphone/Chat/Chat.qml b/linphone-app/ui/modules/Linphone/Chat/Chat.qml index dfa51a2f4..b923981a9 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Chat.qml @@ -411,9 +411,13 @@ Rectangle { placeholderText: qsTr('newMessagePlaceholder') recordAudioToggled: RecorderManager.haveVocalRecorder && RecorderManager.getVocalRecorder().state != LinphoneEnums.RecorderStateClosed emojiVisible: chatEmojis.visible - onDropped: Logic.handleFilesDropped(files) - onTextChanged: Logic.handleTextChanged(getText()) + property bool componentReady: false + onTextChanged: {// This slot can be call before the item has been completed because of Rich text. So the cache must not take it account. + if(componentReady) { + proxyModel.cachedText=text + } + } onValidText: { textArea.text = '' chat.bindToEnd = true @@ -428,7 +432,7 @@ Rectangle { onEmojiClicked: { chatEmojis.visible = !chatEmojis.visible } - Component.onCompleted: {text = proxyModel.cachedText; cursorPosition=text.length} + Component.onCompleted: {text = proxyModel.cachedText; cursorPosition=text.length;componentReady=true} Rectangle{ anchors.fill:parent color:'white'