mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-28 14:43:09 +00:00
[dialer] Add call timer to the call page
This commit is contained in:
parent
a8db07cf55
commit
3e68d4589f
4 changed files with 35 additions and 2 deletions
|
|
@ -122,7 +122,7 @@ Item {
|
|||
//STATUS_DIALING
|
||||
} else if (ofonoWrapper.status == "dialing") {
|
||||
return i18n("Calling...");
|
||||
} else if (ofonoWrapper.duration > 0) {
|
||||
} else if (dialerUtils.duration > 0) {
|
||||
return secondsToTimeString(ofonoWrapper.duration);
|
||||
} else {
|
||||
return '';
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
#include "call-manager.h"
|
||||
#include "dialerutils.h"
|
||||
#include <QTimer>
|
||||
|
||||
#include <KNotification>
|
||||
#include <KLocalizedString>
|
||||
|
|
@ -36,6 +37,7 @@ struct CallManager::Private
|
|||
KNotification *ringingNotification;
|
||||
KNotification *callsNotification;
|
||||
uint missedCalls;
|
||||
QTimer *callTimer;
|
||||
};
|
||||
|
||||
CallManager::CallManager(const Tp::CallChannelPtr &callChannel, DialerUtils *dialerUtils, QObject *parent)
|
||||
|
|
@ -58,6 +60,7 @@ CallManager::CallManager(const Tp::CallChannelPtr &callChannel, DialerUtils *dia
|
|||
|
||||
d->ringingNotification = nullptr;
|
||||
d->callsNotification = nullptr;
|
||||
d->callTimer = nullptr;
|
||||
|
||||
//create the channel handler
|
||||
// d->channelHandler = new CallChannelHandler(callChannel, this);
|
||||
|
|
@ -147,6 +150,12 @@ void CallManager::onCallStateChanged(Tp::CallState state)
|
|||
// delete d->approver.data();
|
||||
}
|
||||
d->dialerUtils->setCallState("active");
|
||||
d->callTimer = new QTimer(this);
|
||||
connect(d->callTimer, &QTimer::timeout, [=]() {
|
||||
d->dialerUtils->setCallDuration(d->dialerUtils->callDuration() + 1);
|
||||
});
|
||||
d->callTimer->start(1000);
|
||||
|
||||
// ensureCallWindow();
|
||||
// d->callWindow.data()->setStatus(CallWindow::StatusActive);
|
||||
break;
|
||||
|
|
@ -178,6 +187,13 @@ void CallManager::onCallStateChanged(Tp::CallState state)
|
|||
d->callsNotification->update();
|
||||
}
|
||||
}
|
||||
|
||||
if (d->callTimer) {
|
||||
d->callTimer->stop();
|
||||
d->callTimer->deleteLater();
|
||||
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 (d->callChannel->isRequested()) {
|
||||
// ensureCallWindow();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@
|
|||
DialerUtils::DialerUtils(const Tp::AccountPtr &simAccount, QObject *parent)
|
||||
: QObject(parent),
|
||||
m_missedCalls(0),
|
||||
m_simAccount(simAccount)
|
||||
m_simAccount(simAccount),
|
||||
m_callDuration(0),
|
||||
{
|
||||
Tp::PendingReady *op = m_simAccount->becomeReady(Tp::Features() << Tp::Account::FeatureCore);
|
||||
|
||||
|
|
@ -82,6 +83,17 @@ void DialerUtils::setCallState(const QString &state)
|
|||
}
|
||||
}
|
||||
|
||||
uint DialerUtils::callDuration() const
|
||||
{
|
||||
return m_callDuration;
|
||||
}
|
||||
|
||||
void DialerUtils::setCallDuration(uint duration)
|
||||
{
|
||||
m_callDuration = duration;
|
||||
Q_EMIT callDurationChanged();
|
||||
}
|
||||
|
||||
void DialerUtils::resetMissedCalls()
|
||||
{
|
||||
m_missedCalls = 0;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class DialerUtils : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString callState READ callState NOTIFY callStateChanged);
|
||||
Q_PROPERTY(uint callDuration READ callDuration NOTIFY callDurationChanged);
|
||||
public:
|
||||
|
||||
DialerUtils(const Tp::AccountPtr &simAccount, QObject *parent = 0);
|
||||
|
|
@ -37,12 +38,15 @@ public:
|
|||
QString callState() const;
|
||||
void setCallState(const QString &state);
|
||||
|
||||
uint callDuration() const;
|
||||
void setCallDuration(uint duration);
|
||||
Q_INVOKABLE void resetMissedCalls();
|
||||
Q_INVOKABLE void dial(const QString &number);
|
||||
|
||||
Q_SIGNALS:
|
||||
void missedCallsActionTriggered();
|
||||
void callStateChanged();
|
||||
void callDurationChanged();
|
||||
void acceptCall();
|
||||
void rejectCall();
|
||||
void hangUp();
|
||||
|
|
@ -53,6 +57,7 @@ private:
|
|||
int m_missedCalls;
|
||||
QString m_callState;
|
||||
Tp::AccountPtr m_simAccount;
|
||||
uint m_callDuration;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue