Commit 4971ff9d authored by Ronan Abhamon's avatar Ronan Abhamon

fix(Chat): better core on composing

parent c11de612
...@@ -197,22 +197,12 @@ ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) { ...@@ -197,22 +197,12 @@ ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) {
core->getSipAddressesModel()->connectToChatModel(this); core->getSipAddressesModel()->connectToChatModel(this);
QObject::connect(mCoreHandlers.get(), &CoreHandlers::messageReceived, this, &ChatModel::handleMessageReceived); {
QObject::connect(mCoreHandlers.get(), &CoreHandlers::callStateChanged, this, &ChatModel::handleCallStateChanged); CoreHandlers *coreHandlers = mCoreHandlers.get();
QObject::connect(coreHandlers, &CoreHandlers::messageReceived, this, &ChatModel::handleMessageReceived);
// Deal with remote composing. QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &ChatModel::handleCallStateChanged);
QTimer *timer = new QTimer(this); QObject::connect(coreHandlers, &CoreHandlers::isComposingChanged, this, &ChatModel::handleIsComposingChanged);
timer->setInterval(500);
QObject::connect(timer, &QTimer::timeout, this, [this] {
bool isRemoteComposing = mChatRoom->isRemoteComposing();
if (isRemoteComposing != mIsRemoteComposing) {
mIsRemoteComposing = isRemoteComposing;
emit isRemoteComposingChanged(mIsRemoteComposing);
} }
});
timer->start();
} }
ChatModel::~ChatModel () { ChatModel::~ChatModel () {
...@@ -669,6 +659,16 @@ void ChatModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call, ...@@ -669,6 +659,16 @@ void ChatModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call,
insertCall(call->getCallLog()); insertCall(call->getCallLog());
} }
void ChatModel::handleIsComposingChanged (const shared_ptr<linphone::ChatRoom> &chatRoom) {
if (mChatRoom == chatRoom) {
bool isRemoteComposing = mChatRoom->isRemoteComposing();
if (isRemoteComposing != mIsRemoteComposing) {
mIsRemoteComposing = isRemoteComposing;
emit isRemoteComposingChanged(mIsRemoteComposing);
}
}
}
void ChatModel::handleMessageReceived (const shared_ptr<linphone::ChatMessage> &message) { void ChatModel::handleMessageReceived (const shared_ptr<linphone::ChatMessage> &message) {
if (mChatRoom == message->getChatRoom()) { if (mChatRoom == message->getChatRoom()) {
insertMessageAtEnd(message); insertMessageAtEnd(message);
......
...@@ -138,6 +138,7 @@ private: ...@@ -138,6 +138,7 @@ private:
void resetMessagesCount (); void resetMessagesCount ();
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void handleIsComposingChanged (const std::shared_ptr<linphone::ChatRoom> &chatRoom);
void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
bool mIsRemoteComposing = false; bool mIsRemoteComposing = false;
......
...@@ -121,6 +121,13 @@ void CoreHandlers::onGlobalStateChanged ( ...@@ -121,6 +121,13 @@ void CoreHandlers::onGlobalStateChanged (
} }
} }
void CoreHandlers::onIsComposingReceived (
const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::ChatRoom> &room
) {
emit isComposingChanged(room);
}
void CoreHandlers::onLogCollectionUploadStateChanged ( void CoreHandlers::onLogCollectionUploadStateChanged (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
linphone::CoreLogCollectionUploadState state, linphone::CoreLogCollectionUploadState state,
......
...@@ -46,6 +46,7 @@ signals: ...@@ -46,6 +46,7 @@ signals:
void callTransferFailed (const std::shared_ptr<linphone::Call> &call); void callTransferFailed (const std::shared_ptr<linphone::Call> &call);
void callTransferSucceeded (const std::shared_ptr<linphone::Call> &call); void callTransferSucceeded (const std::shared_ptr<linphone::Call> &call);
void coreStarted (); void coreStarted ();
void isComposingChanged (const std::shared_ptr<linphone::ChatRoom> &chatRoom);
void logsUploadStateChanged (linphone::CoreLogCollectionUploadState state, const std::string &info); void logsUploadStateChanged (linphone::CoreLogCollectionUploadState state, const std::string &info);
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel); void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
...@@ -84,6 +85,11 @@ private: ...@@ -84,6 +85,11 @@ private:
const std::string &message const std::string &message
) override; ) override;
void onIsComposingReceived (
const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room
) override;
void onLogCollectionUploadStateChanged ( void onLogCollectionUploadStateChanged (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
linphone::CoreLogCollectionUploadState state, linphone::CoreLogCollectionUploadState state,
......
...@@ -187,6 +187,16 @@ Rectangle { ...@@ -187,6 +187,16 @@ Rectangle {
} }
} }
} }
footer: Text {
color: ChatStyle.composingText.color
font.pointSize: ChatStyle.composingText.pointSize
height: visible ? ChatStyle.composingText.height : 0
leftPadding: ChatStyle.composingText.leftPadding
visible: text.length > 0
text: Logic.getIsComposingMessage()
}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -199,7 +209,6 @@ Rectangle { ...@@ -199,7 +209,6 @@ Rectangle {
borderColor: ChatStyle.sendArea.border.color borderColor: ChatStyle.sendArea.border.color
bottomWidth: ChatStyle.sendArea.border.width
topWidth: ChatStyle.sendArea.border.width topWidth: ChatStyle.sendArea.border.width
DroppableTextArea { DroppableTextArea {
...@@ -216,16 +225,6 @@ Rectangle { ...@@ -216,16 +225,6 @@ Rectangle {
onValidText: Logic.sendMessage(text) onValidText: Logic.sendMessage(text)
} }
} }
Text {
Layout.fillWidth: true
color: ChatStyle.composingText.color
font.pointSize: ChatStyle.composingText.pointSize
leftPadding: ChatStyle.composingText.leftPadding
text: Logic.getIsComposingMessage()
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
...@@ -35,8 +35,9 @@ QtObject { ...@@ -35,8 +35,9 @@ QtObject {
property QtObject composingText: QtObject { property QtObject composingText: QtObject {
property color color: Colors.b property color color: Colors.b
property int pointSize: Units.dp * 9 property int height: 25
property int leftPadding: 6 property int leftPadding: 6
property int pointSize: Units.dp * 9
} }
property QtObject entry: QtObject { property QtObject entry: QtObject {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment