summaryrefslogtreecommitdiffstats
path: root/app/phone.cpp
diff options
context:
space:
mode:
authorMatt Porter <mporter@konsulko.com>2017-11-11 23:36:34 -0500
committerMatt Porter <mporter@konsulko.com>2017-11-11 23:36:34 -0500
commitb79d2e9c18ffcaaa73df03ff908a62fc7603bba5 (patch)
tree46fd6bd6b253a51a95a6ce19d964c7051cde419a /app/phone.cpp
parent202a1402f1e59c73e631ef9495c22fee30bafac2 (diff)
Move call timer functionality from QML into the C++ Phone class
Removes the QML call timer implementation in favor of a C++ implementation in the Phone class. This allows the call timer to be started even if the QML application is in the background (QSG RenderThread not scheduled). Bug-AGL: SPEC-1083 Change-Id: I0cb9087d73862992d25b105f97b830eef5c83ef0 Signed-off-by: Matt Porter <mporter@konsulko.com>
Diffstat (limited to 'app/phone.cpp')
-rw-r--r--app/phone.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/app/phone.cpp b/app/phone.cpp
index 4eca02a..254fe24 100644
--- a/app/phone.cpp
+++ b/app/phone.cpp
@@ -17,6 +17,7 @@
#include <QDebug>
#include <QObject>
#include <QSoundEffect>
+#include <QTimer>
#include <telephony.h>
#include "phone.h"
@@ -28,12 +29,28 @@ Phone::Phone(Telephony *telephony, QObject *parent) :
m_ringtone.setLoopCount(QSoundEffect::Infinite);
QObject::connect(telephony, &Telephony::callStateChanged, this, &Phone::onCallStateChanged);
+
+ m_call_timer.setInterval(1000);
+ m_call_timer.setSingleShot(false);
+ connect(&m_call_timer, SIGNAL(timeout()), this, SLOT(updateElapsedTime()));
}
void Phone::onCallStateChanged(QString callState)
{
- if ((callState == "disconnected") || (callState == "active"))
+ if (callState == "disconnected") {
+ m_ringtone.stop();
+ m_call_timer.stop();
+ } else if (callState == "active") {
m_ringtone.stop();
- else if (callState == "incoming")
+ m_date_time = m_date_time.fromSecsSinceEpoch(0);
+ setElapsedTime("00:00:00");
+ m_call_timer.start();
+ } else if (callState == "incoming") {
m_ringtone.play();
+ }
+}
+
+void Phone::updateElapsedTime() {
+ m_date_time = m_date_time.addSecs(1);
+ setElapsedTime(m_date_time.toString(Qt::ISODate).right(8));
}