Commit 1b197eb0 authored by Edric Milaret's avatar Edric Milaret Committed by Guillaume Roguez

im: link ui to LRC media text API

Refs #74275

Change-Id: If02ceef8b7bf7dce2785953377c873d5d6b13272
parent a34e4bac
......@@ -30,6 +30,9 @@
#include "historydelegate.h"
#include "contactdelegate.h"
#include "localhistorycollection.h"
#include "media/text.h"
#include "media/recording.h"
#include "media/textrecording.h"
#include "wizarddialog.h"
......@@ -221,6 +224,51 @@ CallWidget::callStateChanged(Call* call, Call::State previousState)
ui->callStateLabel->setText("Call State : " + state.at((int)call->state()));
}
void
CallWidget::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, [=]()
{
textMedia->send(ui->messageInput->text());
ui->messageInput->clear();
});
ui->messageInput->show();
} else {
ui->messageOutput->disconnect();
ui->messageInput->disconnect();
ui->messageOutput->hide();
ui->messageInput->hide();
}
}
void
CallWidget::mediaAdd(Media::Media *media)
{
switch(static_cast<int>(media->type())) {
case 0: /*AUDIO*/
break;
case 1: /*VIDEO*/
break;
case 2: /*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()));
ui->messageOutput->show();
}
break;
case 3: /*FILE*/
break;
}
}
void
CallWidget::on_callList_activated(const QModelIndex &index)
{
......@@ -317,7 +365,9 @@ CallWidget::setActualCall(Call* value)
actualCall_ = value;
ui->holdButton->setEnabled(actualCall_ != nullptr);
ui->hangupButton->setEnabled(actualCall_ != nullptr);
ui->messageInput->setEnabled(actualCall_ != nullptr);
ui->messageOutput->setEnabled(actualCall_ != nullptr);
setMediaText(actualCall_);
}
void
CallWidget::on_sortComboBox_currentIndexChanged(int index)
......
......@@ -66,14 +66,14 @@ private slots:
void on_micSlider_sliderReleased();
void on_contactView_doubleClicked(const QModelIndex &index);
void on_historyList_doubleClicked(const QModelIndex &index);
void on_sortComboBox_currentIndexChanged(int index);
private slots:
void callIncoming(Call *call);
void addedCall(Call *call, Call *parent);
void callStateChanged(Call *call, Call::State previousState);
void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
void on_sortComboBox_currentIndexChanged(int index);
void mediaAdd(Media::Media* media);
private:
Ui::CallWidget *ui;
......@@ -86,6 +86,7 @@ private:
private:
void findRingAccount();
void setActualCall(Call *value);
void setMediaText(Call* call);
};
#endif // CALLWIDGET_H
......@@ -405,10 +405,22 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="flow">
<enum>QListView::TopToBottom</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="messageInput">
<property name="placeholderText">
<string>Send text message...</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
......
......@@ -21,12 +21,18 @@
#include <QFile>
#include "callmodel.h"
#include "media/audio.h"
#include "media/video.h"
#include "media/text.h"
#include "media/file.h"
#include <iostream>
#include <QThread>
#include <windows.h>
REGISTER_MEDIA();
int
main(int argc, char *argv[])
{
......
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