mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-07-31 16:54:46 +00:00
add a knotification for missed calls
This commit is contained in:
parent
3fab7b980c
commit
c3f65ad5e8
6 changed files with 89 additions and 5 deletions
|
|
@ -26,7 +26,7 @@ include(FeatureSummary)
|
||||||
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Widgets Qml Quick Test)
|
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Widgets Qml Quick Test)
|
||||||
|
|
||||||
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative I18n)
|
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative I18n)
|
||||||
find_package(KF5 REQUIRED COMPONENTS PlasmaQuick DBusAddons)
|
find_package(KF5 REQUIRED COMPONENTS PlasmaQuick DBusAddons Notifications)
|
||||||
|
|
||||||
|
|
||||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,39 @@ ApplicationWindow {
|
||||||
width: 600
|
width: 600
|
||||||
height: 800
|
height: 800
|
||||||
|
|
||||||
|
|
||||||
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
|
property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0
|
||||||
|
//keep track of the status we were in
|
||||||
|
property int previousStatus
|
||||||
|
//keep track if we were visible when ringing
|
||||||
|
property bool wasVisible
|
||||||
//END PROPERTIES
|
//END PROPERTIES
|
||||||
|
|
||||||
//BEGIN SIGNAL HANDLERS
|
//BEGIN SIGNAL HANDLERS
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
//STATUS_INCOMING
|
//STATUS_INCOMING
|
||||||
if (status == 5) {
|
if (status == 5) {
|
||||||
|
wasVisible = root.visible;
|
||||||
root.visible = true;
|
root.visible = true;
|
||||||
|
//Was STATUS_INCOMING now is STATUS_DISCONNECTED: Missed call!
|
||||||
|
} else if (status == 7 && previousStatus == 5) {
|
||||||
|
dialerUtils.notifyMissedCall();
|
||||||
|
root.visible = wasVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
previousStatus = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: dialerUtils
|
||||||
|
onMissedCallsActionTriggered: {
|
||||||
|
root.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
//reset missed calls if the status is not STATUS_INCOMING when got visible
|
||||||
|
if (visible && status != 5) {
|
||||||
|
dialerUtils.resetMissedCalls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//END SIGNAL HANDLERS
|
//END SIGNAL HANDLERS
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ target_link_libraries(plasmaphonedialer
|
||||||
KF5::Package
|
KF5::Package
|
||||||
KF5::QuickAddons
|
KF5::QuickAddons
|
||||||
KF5::DBusAddons
|
KF5::DBusAddons
|
||||||
|
KF5::Notifications
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS plasmaphonedialer ${INSTALL_TARGETS_DEFAULT_ARGS})
|
install(TARGETS plasmaphonedialer ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
install(FILES plasma_dialer.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR})
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,54 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
DialerUtils::DialerUtils(QObject *parent)
|
#include <KLocalizedString>
|
||||||
: QObject(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
DialerUtils::DialerUtils(QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
m_missedCalls(0)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DialerUtils::~DialerUtils()
|
DialerUtils::~DialerUtils()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialerUtils::notifyMissedCall()
|
||||||
|
{
|
||||||
|
qWarning() << "Missed Call.";
|
||||||
|
|
||||||
|
++m_missedCalls;
|
||||||
|
if (!m_callsNotification) {
|
||||||
|
m_callsNotification = new KNotification("callMissed", KNotification::Persistent, 0);
|
||||||
|
}
|
||||||
|
m_callsNotification->setComponentName("plasma_dialer");
|
||||||
|
m_callsNotification->setIconName("call-start");
|
||||||
|
m_callsNotification->setTitle(i18np("One call missed", "%1 calls missed", m_missedCalls));
|
||||||
|
|
||||||
|
QStringList actions;
|
||||||
|
actions.append(i18n("View"));
|
||||||
|
m_callsNotification->setActions(actions);
|
||||||
|
QObject::connect(m_callsNotification.data(), &KNotification::action1Activated,
|
||||||
|
[=]() {
|
||||||
|
qWarning()<<"View action activated";
|
||||||
|
emit missedCallsActionTriggered();
|
||||||
|
resetMissedCalls();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (m_missedCalls == 1) {
|
||||||
|
m_callsNotification->sendEvent();
|
||||||
|
} else {
|
||||||
|
m_callsNotification->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialerUtils::resetMissedCalls()
|
||||||
|
{
|
||||||
|
m_missedCalls = 0;
|
||||||
|
if (m_callsNotification) {
|
||||||
|
m_callsNotification->close();
|
||||||
|
}
|
||||||
|
m_callsNotification.clear();
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_dialerutils.cpp"
|
#include "moc_dialerutils.cpp"
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
#define DIALERUTILS_H
|
#define DIALERUTILS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <KNotification>
|
||||||
|
|
||||||
class DialerUtils : public QObject
|
class DialerUtils : public QObject
|
||||||
{
|
{
|
||||||
|
|
@ -29,8 +31,15 @@ public:
|
||||||
DialerUtils(QObject *parent = 0);
|
DialerUtils(QObject *parent = 0);
|
||||||
virtual ~DialerUtils();
|
virtual ~DialerUtils();
|
||||||
|
|
||||||
private:
|
Q_INVOKABLE void notifyMissedCall();
|
||||||
|
Q_INVOKABLE void resetMissedCalls();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void missedCallsActionTriggered();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer <KNotification> m_callsNotification;
|
||||||
|
int m_missedCalls;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
9
dialer/src/plasma_dialer.notifyrc
Normal file
9
dialer/src/plasma_dialer.notifyrc
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Global]
|
||||||
|
IconName=call-start
|
||||||
|
Comment=Plasma Phone Dialer
|
||||||
|
|
||||||
|
[Event/callMissed]
|
||||||
|
Name=Missed Call
|
||||||
|
Comment=A call has been missed
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
Loading…
Reference in a new issue