Skip to content
Snippets Groups Projects
Commit 7cc79c08 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

callwidget: remove references to CallModel

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