mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-29 01:39:19 +00:00
feat(ui/views/App/Calls/Incall): display timer
This commit is contained in:
parent
3d83700fd9
commit
2f5d23cbe2
6 changed files with 74 additions and 15 deletions
|
|
@ -57,10 +57,6 @@ void CallModel::transfer () {
|
|||
// TODO
|
||||
}
|
||||
|
||||
float CallModel::getQuality () const {
|
||||
return m_linphone_call->getCurrentQuality();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CallModel::getSipAddress () const {
|
||||
|
|
@ -90,6 +86,14 @@ CallModel::CallStatus CallModel::getStatus () const {
|
|||
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 {
|
||||
return m_micro_muted;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ class CallModel : public QObject {
|
|||
Q_PROPERTY(QString sipAddress READ getSipAddress CONSTANT);
|
||||
Q_PROPERTY(CallStatus status READ getStatus NOTIFY statusChanged);
|
||||
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 pausedByUser READ getPausedByUser WRITE setPausedByUser NOTIFY statusChanged);
|
||||
Q_PROPERTY(bool videoInputEnabled READ getVideoInputEnabled WRITE setVideoInputEnabled NOTIFY videoInputEnabled);
|
||||
|
|
@ -37,8 +39,6 @@ public:
|
|||
Q_INVOKABLE void terminate ();
|
||||
Q_INVOKABLE void transfer ();
|
||||
|
||||
Q_INVOKABLE float getQuality () const;
|
||||
|
||||
signals:
|
||||
void statusChanged (CallStatus status);
|
||||
void microMutedChanged (bool status);
|
||||
|
|
@ -53,6 +53,9 @@ private:
|
|||
return m_linphone_call->getDir() == linphone::CallDirOutgoing;
|
||||
}
|
||||
|
||||
int getDuration () const;
|
||||
float getQuality () const;
|
||||
|
||||
bool getMicroMuted () const;
|
||||
void setMicroMuted (bool status);
|
||||
|
||||
|
|
|
|||
|
|
@ -63,13 +63,21 @@ QVariant CallsListModel::data (const QModelIndex &index, int role) const {
|
|||
|
||||
void CallsListModel::launchAudioCall (const QString &sip_uri) const {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
core->inviteAddress(
|
||||
core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri))
|
||||
);
|
||||
shared_ptr<linphone::Address> address = 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 {
|
||||
// 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) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
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) {
|
||||
var units = ['KB', 'MB', 'GB', 'TB']
|
||||
var unit = 'B'
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import Common 1.0
|
|||
import Common.Styles 1.0
|
||||
import Linphone 1.0
|
||||
import LinphoneUtils 1.0
|
||||
import Utils 1.0
|
||||
|
||||
import App.Styles 1.0
|
||||
|
||||
|
|
@ -56,11 +57,7 @@ Rectangle {
|
|||
triggeredOnStart: true
|
||||
|
||||
onTriggered: {
|
||||
if (!call.getQuality) {
|
||||
return
|
||||
}
|
||||
|
||||
var quality = call.getQuality()
|
||||
var quality = call.quality
|
||||
callQuality.icon = 'call_quality_' + (
|
||||
// Note: `quality` is in the [0, 5] interval.
|
||||
// It's necessary to map in the `call_quality_` interval. ([0, 3])
|
||||
|
|
@ -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.
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -47,5 +47,10 @@ QtObject {
|
|||
property int height: 60
|
||||
property int width: 150
|
||||
}
|
||||
|
||||
property QtObject elapsedTime: QtObject {
|
||||
property color color: Colors.j
|
||||
property int fontSize: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue