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) {
core->getSipAddressesModel()->connectToChatModel(this);
QObject::connect(mCoreHandlers.get(), &CoreHandlers::messageReceived, this, &ChatModel::handleMessageReceived);
QObject::connect(mCoreHandlers.get(), &CoreHandlers::callStateChanged, this, &ChatModel::handleCallStateChanged);
// Deal with remote composing.
QTimer *timer = new QTimer(this);
timer->setInterval(500);
QObject::connect(timer, &QTimer::timeout, this, [this] {
bool isRemoteComposing = mChatRoom->isRemoteComposing();
if (isRemoteComposing != mIsRemoteComposing) {
mIsRemoteComposing = isRemoteComposing;
emit isRemoteComposingChanged(mIsRemoteComposing);
}
});
timer->start();
{
CoreHandlers *coreHandlers = mCoreHandlers.get();
QObject::connect(coreHandlers, &CoreHandlers::messageReceived, this, &ChatModel::handleMessageReceived);
QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &ChatModel::handleCallStateChanged);
QObject::connect(coreHandlers, &CoreHandlers::isComposingChanged, this, &ChatModel::handleIsComposingChanged);
}
}
ChatModel::~ChatModel () {
......@@ -669,6 +659,16 @@ void ChatModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call,
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) {
if (mChatRoom == message->getChatRoom()) {
insertMessageAtEnd(message);
......
......@@ -138,6 +138,7 @@ private:
void resetMessagesCount ();
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);
bool mIsRemoteComposing = false;
......
......@@ -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 (
const shared_ptr<linphone::Core> &,
linphone::CoreLogCollectionUploadState state,
......
......@@ -46,6 +46,7 @@ signals:
void callTransferFailed (const std::shared_ptr<linphone::Call> &call);
void callTransferSucceeded (const std::shared_ptr<linphone::Call> &call);
void coreStarted ();
void isComposingChanged (const std::shared_ptr<linphone::ChatRoom> &chatRoom);
void logsUploadStateChanged (linphone::CoreLogCollectionUploadState state, const std::string &info);
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
......@@ -84,6 +85,11 @@ private:
const std::string &message
) override;
void onIsComposingReceived (
const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room
) override;
void onLogCollectionUploadStateChanged (
const std::shared_ptr<linphone::Core> &core,
linphone::CoreLogCollectionUploadState state,
......
......@@ -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 {
borderColor: ChatStyle.sendArea.border.color
bottomWidth: ChatStyle.sendArea.border.width
topWidth: ChatStyle.sendArea.border.width
DroppableTextArea {
......@@ -216,16 +225,6 @@ Rectangle {
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 {
property QtObject composingText: QtObject {
property color color: Colors.b
property int pointSize: Units.dp * 9
property int height: 25
property int leftPadding: 6
property int pointSize: Units.dp * 9
}
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