Commit c54e2278 authored by Edric Milaret's avatar Edric Milaret

chat: fix history not being displayed

Issue: #79704
Change-Id: I8336277ec8932b74782b92e2ed14db7e0319f9d1
parent 791f000c
......@@ -311,6 +311,7 @@ CallWidget::callStateChanged(Call* call, Call::State previousState)
|| call->state() == Call::State::FAILURE
|| call->state() == Call::State::ABORTED) {
setActualCall(nullptr);
ui->instantMessagingWidget->setMediaText(nullptr);
ui->videoWidget->hide();
displaySpinner(false);
auto onHoldCall = callModel_->getActiveCalls().first();
......@@ -321,6 +322,7 @@ CallWidget::callStateChanged(Call* call, Call::State previousState)
} else if (call->state() == Call::State::CURRENT) {
displaySpinner(false);
ui->videoWidget->show();
ui->instantMessagingWidget->setMediaText(actualCall_);
}
ui->callStateLabel->setText(QString(tr("Call State: %1", "%1 is the state of the call"))
.arg(call->toHumanStateName()));
......@@ -394,7 +396,6 @@ void
CallWidget::setActualCall(Call* value)
{
actualCall_ = value;
ui->instantMessagingWidget->setMediaText(actualCall_);
}
void
......
......@@ -75,14 +75,27 @@ InstantMessagingWidget::setMediaText(Call *call)
if (call != nullptr) {
connect(call, SIGNAL(mediaAdded(Media::Media*)),
this, SLOT(mediaAdd(Media::Media*)));
Media::Text *textMedia = call->addOutgoingMedia<Media::Text>();
connect(ui->messageInput, &QLineEdit::returnPressed, [=]()
{
QMap<QString, QString> messages;
messages["text/plain"] = ui->messageInput->text();
textMedia->send(messages);
ui->messageInput->clear();
});
Media::Text *textMedia = nullptr;
if (call->hasMedia(Media::Media::Type::TEXT, Media::Media::Direction::OUT)) {
textMedia = call->firstMedia<Media::Text>(Media::Media::Direction::OUT);
} else {
textMedia = call->addOutgoingMedia<Media::Text>();
}
if (textMedia) {
connect(ui->messageOutput->model(),
SIGNAL(rowsInserted(const QModelIndex&, int, int)),
ui->messageOutput, SLOT(scrollToBottom()));
ui->messageOutput->setModel(
textMedia->recording()->
instantMessagingModel());
connect(ui->messageInput, &QLineEdit::returnPressed, [=]()
{
QMap<QString, QString> messages;
messages["text/plain"] = ui->messageInput->text();
textMedia->send(messages);
ui->messageInput->clear();
});
}
} else {
ui->messageOutput->disconnect();
ui->messageInput->disconnect();
......@@ -99,12 +112,6 @@ InstantMessagingWidget::mediaAdd(Media::Media *media)
break;
case Media::Media::Type::TEXT:
if (media->direction() == Media::Text::Direction::IN) {
ui->messageOutput->setModel(
static_cast<Media::Text*>(media)->recording()->
instantMessagingModel());
connect(ui->messageOutput->model(),
SIGNAL(rowsInserted(const QModelIndex&, int, int)),
ui->messageOutput, SLOT(scrollToBottom()));
connect(static_cast<Media::Text*>(media),
SIGNAL(messageReceived(QMap<QString,QString>)),
this,
......@@ -158,4 +165,5 @@ InstantMessagingWidget::onMsgReceived(const QMap<QString,QString>& message)
GlobalSystemTray::instance().showMessage("Ring: Message Received", message["text/plain"]);
QApplication::alert(this, 5000);
}
this->show();
}
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