Commit 7cc79c08 authored by Andreas Traczyk's avatar Andreas Traczyk

callwidget: remove references to CallModel

Change-Id: Iaa7f805e50d02f234c77083cd68198a00e8884c5
parent dc2703ed
......@@ -545,22 +545,6 @@ CallWidget::smartListSelectionChanged(const QItemSelection &selected, const QIt
selectConversation(selectedIndex);
}
void
CallWidget::placeCall()
{
if (ui->ringContactLineEdit->text().isEmpty())
return;
Call* c = CallModel::instance().dialingCall(PhoneDirectoryModel::instance().getNumber(ui->ringContactLineEdit->text()));
c->performAction(Call::Action::ACCEPT);
ui->ringContactLineEdit->clear();
auto photoRect = ui->callingPhoto->frameGeometry();
ui->callingPhoto->setPixmap(
QPixmap::fromImage(
GlobalInstances::pixmapManipulator()
.callPhoto(c, QSize(photoRect.width(), photoRect.height()))
.value<QImage>()));
}
void
CallWidget::conversationsButtonClicked()
{
......
......@@ -33,7 +33,6 @@
#include "smartlistmodel.h"
// old LRC
#include "callmodel.h"
#include "video/renderer.h"
#include "video/previewmanager.h"
#include "accountmodel.h"
......
......@@ -430,18 +430,23 @@ Utils::generateTintedPixmap(const QString& filename, QColor color)
return QPixmap::fromImage(tmpImage);
}
std::string
Utils::getConversationFromCallId(const std::string& callId)
lrc::api::conversation::Info
Utils::getConversationFromCallId(const std::string & callId)
{
auto convModel = LRCInstance::getCurrentConversationModel();
auto conversations = convModel->allFilteredConversations();
std::string convUid;
for (auto conversation : conversations) {
if (conversation.callId == callId) {
return conversation.uid;
using namespace lrc::api::profile;
for (int i = toUnderlyingValue(Type::RING); i <= toUnderlyingValue(Type::TEMPORARY); ++i) {
auto filter = toEnum<lrc::api::profile::Type>(i);
auto conversations = convModel->getFilteredConversations(filter);
auto conv = std::find_if(conversations.begin(), conversations.end(),
[&](const lrc::api::conversation::Info& conv) {
return callId == conv.callId;
});
if (conv != conversations.end()) {
return *conv;
}
}
return "";
return lrc::api::conversation::Info();
}
lrc::api::conversation::Info
......
......@@ -78,7 +78,7 @@ namespace Utils
QImage conversationPhoto(const std::string& convUid, const lrc::api::account::Info& accountInfo);
QByteArray QByteArrayFromFile(const QString& filename);
QPixmap generateTintedPixmap(const QString& filename, QColor color);
std::string getConversationFromCallId(const std::string& callId);
lrc::api::conversation::Info getConversationFromCallId(const std::string& callId);
lrc::api::conversation::Info getSelectedConversation();
lrc::api::conversation::Info getConversationFromUid(const std::string & convUid, bool filtered = true);
......
......@@ -42,9 +42,6 @@ VideoView::VideoView(QWidget* parent) :
{
ui->setupUi(this);
connect(&CallModel::instance(), SIGNAL(callStateChanged(Call*, Call::State)),
this, SLOT(callStateChanged(Call*, Call::State)));
overlay_ = new VideoOverlay(this);
auto effect = new QGraphicsOpacityEffect(overlay_);
effect->setOpacity(maxOverlayOpacity_);
......@@ -150,23 +147,27 @@ VideoView::fadeOverlayOut()
}
void
VideoView::callStateChanged(Call* call, Call::State previousState)
VideoView::slotCallStatusChanged(const std::string& callId)
{
Q_UNUSED(previousState)
if (call->state() == Call::State::CURRENT) {
using namespace lrc::api::call;
auto call = LRCInstance::getCurrentCallModel()->getCall(callId);
switch (call.status) {
case Status::IN_PROGRESS:
{
ui->videoWidget->show();
timerConnection_ = connect(call, SIGNAL(changed()), this, SLOT(updateCall()));
} else {
QObject::disconnect(timerConnection_);
try {
if (call) {
emit closing(call->historyId().toStdString());
}
} catch (...) {
qWarning() << "VideoView::callStateChanged except";
auto convInfo = Utils::getConversationFromCallId(call.id);
if (!convInfo.uid.empty()) {
auto contactInfo = LRCInstance::getCurrentAccountInfo().contactModel->getContact(convInfo.participants[0]);
auto contactName = Utils::bestNameForContact(contactInfo);
overlay_->setName(QString::fromStdString(contactName));
}
return;
}
default:
emit closing(call.id);
break;
}
QObject::disconnect(timerConnection_);
}
void
......@@ -182,14 +183,6 @@ VideoView::simulateShowChatview(bool checked)
overlay_->simulateShowChatview(true);
}
void
VideoView::updateCall()
{
if (auto call = CallModel::instance().selectedCall()) {
overlay_->setName(call->formattedName());
}
}
void
VideoView::mouseDoubleClickEvent(QMouseEvent* e) {
QWidget::mouseDoubleClickEvent(e);
......@@ -328,6 +321,8 @@ VideoView::pushRenderer(const std::string& callId) {
auto callModel = LRCInstance::getCurrentCallModel();
QObject::disconnect(videoStartedConnection_);
QObject::disconnect(callStatusChangedConnection_);
if (!callModel->hasCall(callId)) {
return;
}
......@@ -337,6 +332,9 @@ VideoView::pushRenderer(const std::string& callId) {
this->overlay_->callStarted(callId);
this->overlay_->setVideoMuteVisibility(!LRCInstance::getCurrentCallModel()->getCall(callId).isAudioOnly);
callStatusChangedConnection_ = QObject::connect(callModel, &lrc::api::NewCallModel::callStatusChanged,
this, &VideoView::slotCallStatusChanged);
videoStartedConnection_ = QObject::connect(callModel, &lrc::api::NewCallModel::remotePreviewStarted,
[this](const std::string& callId, Video::Renderer* renderer) {
Q_UNUSED(callId);
......
......@@ -57,8 +57,7 @@ protected:
void mouseMoveEvent(QMouseEvent* event);
private slots:
void callStateChanged(Call* call, Call::State previousState);
void updateCall();
void slotCallStatusChanged(const std::string& callId);
void showContextMenu(const QPoint& pos);
void slotVideoStarted(Video::Renderer* renderer);
void fadeOverlayOut();
......@@ -73,6 +72,7 @@ private:
QSize oldSize_;
QMetaObject::Connection timerConnection_;
QMetaObject::Connection videoStartedConnection_;
QMetaObject::Connection callStatusChangedConnection_;
QPoint origin_;
QPoint originMouseDisplacement_;
bool draggingPreview_ = false;
......@@ -102,4 +102,3 @@ signals:
void toggleFullScreenClicked();
void closing(const std::string& callid);
};
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