Commit 2f5d23cb authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Calls/Incall): display timer

parent 3d83700f
...@@ -57,10 +57,6 @@ void CallModel::transfer () { ...@@ -57,10 +57,6 @@ void CallModel::transfer () {
// TODO // TODO
} }
float CallModel::getQuality () const {
return m_linphone_call->getCurrentQuality();
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString CallModel::getSipAddress () const { QString CallModel::getSipAddress () const {
...@@ -90,6 +86,14 @@ CallModel::CallStatus CallModel::getStatus () const { ...@@ -90,6 +86,14 @@ CallModel::CallStatus CallModel::getStatus () const {
return m_linphone_call->getDir() == linphone::CallDirIncoming ? CallStatusIncoming : CallStatusOutgoing; return m_linphone_call->getDir() == linphone::CallDirIncoming ? CallStatusIncoming : CallStatusOutgoing;
} }
int CallModel::getDuration () const {
return m_linphone_call->getDuration();
}
float CallModel::getQuality () const {
return m_linphone_call->getCurrentQuality();
}
bool CallModel::getMicroMuted () const { bool CallModel::getMicroMuted () const {
return m_micro_muted; return m_micro_muted;
} }
......
...@@ -12,6 +12,8 @@ class CallModel : public QObject { ...@@ -12,6 +12,8 @@ class CallModel : public QObject {
Q_PROPERTY(QString sipAddress READ getSipAddress CONSTANT); Q_PROPERTY(QString sipAddress READ getSipAddress CONSTANT);
Q_PROPERTY(CallStatus status READ getStatus NOTIFY statusChanged); Q_PROPERTY(CallStatus status READ getStatus NOTIFY statusChanged);
Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT); Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT);
Q_PROPERTY(int duration READ getDuration CONSTANT);
Q_PROPERTY(float quality READ getQuality CONSTANT);
Q_PROPERTY(bool microMuted READ getMicroMuted WRITE setMicroMuted NOTIFY microMutedChanged); Q_PROPERTY(bool microMuted READ getMicroMuted WRITE setMicroMuted NOTIFY microMutedChanged);
Q_PROPERTY(bool pausedByUser READ getPausedByUser WRITE setPausedByUser NOTIFY statusChanged); Q_PROPERTY(bool pausedByUser READ getPausedByUser WRITE setPausedByUser NOTIFY statusChanged);
Q_PROPERTY(bool videoInputEnabled READ getVideoInputEnabled WRITE setVideoInputEnabled NOTIFY videoInputEnabled); Q_PROPERTY(bool videoInputEnabled READ getVideoInputEnabled WRITE setVideoInputEnabled NOTIFY videoInputEnabled);
...@@ -37,8 +39,6 @@ public: ...@@ -37,8 +39,6 @@ public:
Q_INVOKABLE void terminate (); Q_INVOKABLE void terminate ();
Q_INVOKABLE void transfer (); Q_INVOKABLE void transfer ();
Q_INVOKABLE float getQuality () const;
signals: signals:
void statusChanged (CallStatus status); void statusChanged (CallStatus status);
void microMutedChanged (bool status); void microMutedChanged (bool status);
...@@ -53,6 +53,9 @@ private: ...@@ -53,6 +53,9 @@ private:
return m_linphone_call->getDir() == linphone::CallDirOutgoing; return m_linphone_call->getDir() == linphone::CallDirOutgoing;
} }
int getDuration () const;
float getQuality () const;
bool getMicroMuted () const; bool getMicroMuted () const;
void setMicroMuted (bool status); void setMicroMuted (bool status);
......
...@@ -63,13 +63,21 @@ QVariant CallsListModel::data (const QModelIndex &index, int role) const { ...@@ -63,13 +63,21 @@ QVariant CallsListModel::data (const QModelIndex &index, int role) const {
void CallsListModel::launchAudioCall (const QString &sip_uri) const { void CallsListModel::launchAudioCall (const QString &sip_uri) const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
core->inviteAddress( shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri));
core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri))
); if (!address)
return;
shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
params->enableVideo(false);
core->inviteAddressWithParams(address, params);
} }
void CallsListModel::launchVideoCall (const QString &sip_uri) const { void CallsListModel::launchVideoCall (const QString &sip_uri) const {
// TODO shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
// TODO: Deal with videos.
core->inviteAddress(core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)));
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -314,6 +314,30 @@ function find (obj, cb, context) { ...@@ -314,6 +314,30 @@ function find (obj, cb, context) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function formatElapsedTime (seconds) {
seconds = parseInt(seconds, 10)
var h = Math.floor(seconds / 3600)
var m = Math.floor((seconds - h * 3600) / 60)
var s = seconds - h * 3600 - m * 60
if (h < 10 && h > 0) {
h = '0' + h
}
if (m < 10) {
m = '0' + m
}
if (s < 10) {
s = '0' + s
}
return (h === 0 ? '' : h + ':') + m + ':' + s
}
// -----------------------------------------------------------------------------
function formatSize (size) { function formatSize (size) {
var units = ['KB', 'MB', 'GB', 'TB'] var units = ['KB', 'MB', 'GB', 'TB']
var unit = 'B' var unit = 'B'
......
...@@ -5,6 +5,7 @@ import Common 1.0 ...@@ -5,6 +5,7 @@ import Common 1.0
import Common.Styles 1.0 import Common.Styles 1.0
import Linphone 1.0 import Linphone 1.0
import LinphoneUtils 1.0 import LinphoneUtils 1.0
import Utils 1.0
import App.Styles 1.0 import App.Styles 1.0
...@@ -56,11 +57,7 @@ Rectangle { ...@@ -56,11 +57,7 @@ Rectangle {
triggeredOnStart: true triggeredOnStart: true
onTriggered: { onTriggered: {
if (!call.getQuality) { var quality = call.quality
return
}
var quality = call.getQuality()
callQuality.icon = 'call_quality_' + ( callQuality.icon = 'call_quality_' + (
// Note: `quality` is in the [0, 5] interval. // Note: `quality` is in the [0, 5] interval.
// It's necessary to map in the `call_quality_` interval. ([0, 3]) // It's necessary to map in the `call_quality_` interval. ([0, 3])
...@@ -106,6 +103,24 @@ Rectangle { ...@@ -106,6 +103,24 @@ Rectangle {
} }
} }
Text {
id: elapsedTime
Layout.fillWidth: true
color: CallStyle.header.elapsedTime.color
font.pointSize: CallStyle.header.elapsedTime.fontSize
horizontalAlignment: Text.AlignHCenter
Component.onCompleted: {
var updateDuration = function () {
text = Utils .formatElapsedTime(call.duration)
Utils.setTimeout(elapsedTime, 1000, updateDuration)
}
updateDuration()
}
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Contact visual. // Contact visual.
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
...@@ -47,5 +47,10 @@ QtObject { ...@@ -47,5 +47,10 @@ QtObject {
property int height: 60 property int height: 60
property int width: 150 property int width: 150
} }
property QtObject elapsedTime: QtObject {
property color color: Colors.j
property int fontSize: 10
}
} }
} }
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