Commit 5eefb274 authored by Martin Klapetek's avatar Martin Klapetek

[dialer] Make the history work

parent 9b1cc9f1
...@@ -26,7 +26,6 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras ...@@ -26,7 +26,6 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
Item { Item {
function secondsToTimeString(seconds) { function secondsToTimeString(seconds) {
seconds = Math.floor(seconds/1000)
var h = Math.floor(seconds / 3600); var h = Math.floor(seconds / 3600);
var m = Math.floor((seconds - (h * 3600)) / 60); var m = Math.floor((seconds - (h * 3600)) / 60);
var s = seconds - h * 3600 - m * 60; var s = seconds - h * 3600 - m * 60;
...@@ -105,4 +104,4 @@ Item { ...@@ -105,4 +104,4 @@ Item {
} }
} }
} }
} }
\ No newline at end of file
...@@ -102,7 +102,7 @@ Item { ...@@ -102,7 +102,7 @@ Item {
text: "Name (todo)" text: "Name (todo)"
} }
PlasmaComponents.Label { PlasmaComponents.Label {
text: i18n("Number: %1", model.number) text: model.number
Layout.fillWidth: true Layout.fillWidth: true
} }
} }
......
...@@ -47,6 +47,9 @@ ApplicationWindow { ...@@ -47,6 +47,9 @@ ApplicationWindow {
onMissedCallsActionTriggered: { onMissedCallsActionTriggered: {
root.visible = true; root.visible = true;
} }
onCallEnded: {
insertCallInHistory(callContactNumber, callDuration, incomingCall ? 1 : 2);
}
} }
onVisibleChanged: { onVisibleChanged: {
......
...@@ -56,6 +56,7 @@ CallManager::CallManager(const Tp::CallChannelPtr &callChannel, DialerUtils *dia ...@@ -56,6 +56,7 @@ CallManager::CallManager(const Tp::CallChannelPtr &callChannel, DialerUtils *dia
connect(d->callChannel.data(), &Tp::CallChannel::invalidated, this, [=]() { connect(d->callChannel.data(), &Tp::CallChannel::invalidated, this, [=]() {
qDebug() << "Channel invalidated"; qDebug() << "Channel invalidated";
d->dialerUtils->setCallState("idle"); d->dialerUtils->setCallState("idle");
d->dialerUtils->emitCallEnded();
}); });
d->ringingNotification = nullptr; d->ringingNotification = nullptr;
...@@ -197,7 +198,6 @@ void CallManager::onCallStateChanged(Tp::CallState state) ...@@ -197,7 +198,6 @@ void CallManager::onCallStateChanged(Tp::CallState state)
d->callTimer->stop(); d->callTimer->stop();
d->callTimer->deleteLater(); d->callTimer->deleteLater();
d->callTimer = nullptr; d->callTimer = nullptr;
d->dialerUtils->setCallDuration(0);
} }
//if we requested the call, make sure we have a window to show the error (if any) //if we requested the call, make sure we have a window to show the error (if any)
// if (d->callChannel->isRequested()) { // if (d->callChannel->isRequested()) {
......
...@@ -122,6 +122,15 @@ void DialerUtils::setCallContactNumber(const QString &contactNumber) ...@@ -122,6 +122,15 @@ void DialerUtils::setCallContactNumber(const QString &contactNumber)
} }
} }
void DialerUtils::emitCallEnded()
{
qDebug() << "Call ended:" << m_callContactNumber << m_callDuration;
Q_EMIT callEnded(m_callContactNumber, m_callDuration, true);
m_callDuration = 0;
m_callContactNumber = QString();
m_callContactAlias = QString();
}
void DialerUtils::resetMissedCalls() void DialerUtils::resetMissedCalls()
{ {
m_missedCalls = 0; m_missedCalls = 0;
......
...@@ -50,6 +50,8 @@ public: ...@@ -50,6 +50,8 @@ public:
QString callContactNumber() const; QString callContactNumber() const;
void setCallContactNumber(const QString &contactNumber); void setCallContactNumber(const QString &contactNumber);
void emitCallEnded();
Q_INVOKABLE void resetMissedCalls(); Q_INVOKABLE void resetMissedCalls();
Q_INVOKABLE void dial(const QString &number); Q_INVOKABLE void dial(const QString &number);
...@@ -62,6 +64,7 @@ Q_SIGNALS: ...@@ -62,6 +64,7 @@ Q_SIGNALS:
void acceptCall(); void acceptCall();
void rejectCall(); void rejectCall();
void hangUp(); void hangUp();
void callEnded(const QString &callContactNumber, uint callDuration, bool incomingCall);
private: private:
QPointer <KNotification> m_callsNotification; QPointer <KNotification> m_callsNotification;
......
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