mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-21 13:48:08 +00:00
Match incoming call notification timeout with the value of incoming call timeout from SDK.
This commit is contained in:
parent
342f780c18
commit
f15a68d343
4 changed files with 71 additions and 55 deletions
|
|
@ -63,7 +63,6 @@ namespace {
|
|||
|
||||
constexpr int NotificationSpacing = 10;
|
||||
constexpr int MaxNotificationsNumber = 5;
|
||||
constexpr int MaxTimeout = 30000;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -81,14 +80,16 @@ void setProperty (QObject &object, const char *property, const T &value) {
|
|||
// =============================================================================
|
||||
|
||||
const QHash<int, Notifier::Notification> Notifier::Notifications = {
|
||||
{ Notifier::ReceivedMessage, { "NotificationReceivedMessage.qml", 10 } },
|
||||
{ Notifier::ReceivedFileMessage, { "NotificationReceivedFileMessage.qml", 10 } },
|
||||
{ Notifier::ReceivedCall, { "NotificationReceivedCall.qml", 30 } },
|
||||
{ Notifier::NewVersionAvailable, { "NotificationNewVersionAvailable.qml", 30 } },
|
||||
{ Notifier::SnapshotWasTaken, { "NotificationSnapshotWasTaken.qml", 10 } },
|
||||
{ Notifier::RecordingCompleted, { "NotificationRecordingCompleted.qml", 10 } }
|
||||
{ Notifier::ReceivedMessage, { Notifier::ReceivedMessage, "NotificationReceivedMessage.qml", 10 } },
|
||||
{ Notifier::ReceivedFileMessage, { Notifier::ReceivedFileMessage, "NotificationReceivedFileMessage.qml", 10 } },
|
||||
{ Notifier::ReceivedCall, { Notifier::ReceivedCall, "NotificationReceivedCall.qml", 30 } },
|
||||
{ Notifier::NewVersionAvailable, { Notifier::NewVersionAvailable, "NotificationNewVersionAvailable.qml", 30 } },
|
||||
{ Notifier::SnapshotWasTaken, { Notifier::SnapshotWasTaken, "NotificationSnapshotWasTaken.qml", 10 } },
|
||||
{ Notifier::RecordingCompleted, { Notifier::RecordingCompleted, "NotificationRecordingCompleted.qml", 10 } }
|
||||
};
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Notifier::Notifier (QObject *parent) : QObject(parent) {
|
||||
|
|
@ -206,7 +207,7 @@ void Notifier::showNotification (QObject *notification, int timeout) {
|
|||
QMetaObject::invokeMethod(notification, NotificationShowMethodName, Qt::DirectConnection);
|
||||
|
||||
QTimer *timer = new QTimer(notification);
|
||||
timer->setInterval(timeout > MaxTimeout ? MaxTimeout : timeout);
|
||||
timer->setInterval(timeout);
|
||||
timer->setSingleShot(true);
|
||||
notification->setProperty(NotificationPropertyTimer, QVariant::fromValue(timer));
|
||||
|
||||
|
|
@ -266,7 +267,7 @@ void Notifier::deleteNotification (QVariant notification) {
|
|||
QObject * notification = createNotification(TYPE, DATA); \
|
||||
if (!notification) \
|
||||
return; \
|
||||
const int timeout = Notifications[TYPE].timeout * 1000; \
|
||||
const int timeout = Notifications[TYPE].getTimeout() * 1000; \
|
||||
showNotification(notification, timeout);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -26,64 +26,74 @@
|
|||
#include <QObject>
|
||||
#include <QHash>
|
||||
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
// =============================================================================
|
||||
|
||||
class QMutex;
|
||||
class QQmlComponent;
|
||||
|
||||
namespace linphone {
|
||||
class Call;
|
||||
class ChatMessage;
|
||||
class Call;
|
||||
class ChatMessage;
|
||||
}
|
||||
|
||||
class Notifier : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
Notifier (QObject *parent = Q_NULLPTR);
|
||||
~Notifier ();
|
||||
|
||||
enum NotificationType {
|
||||
ReceivedMessage,
|
||||
ReceivedFileMessage,
|
||||
ReceivedCall,
|
||||
NewVersionAvailable,
|
||||
SnapshotWasTaken,
|
||||
RecordingCompleted
|
||||
};
|
||||
|
||||
void notifyReceivedMessage (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void notifyReceivedFileMessage (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void notifyReceivedCall (const std::shared_ptr<linphone::Call> &call);
|
||||
void notifyNewVersionAvailable (const QString &version, const QString &url);
|
||||
void notifySnapshotWasTaken (const QString &filePath);
|
||||
void notifyRecordingCompleted (const QString &filePath);
|
||||
|
||||
Notifier (QObject *parent = Q_NULLPTR);
|
||||
~Notifier ();
|
||||
|
||||
enum NotificationType {
|
||||
ReceivedMessage,
|
||||
ReceivedFileMessage,
|
||||
ReceivedCall,
|
||||
NewVersionAvailable,
|
||||
SnapshotWasTaken,
|
||||
RecordingCompleted
|
||||
};
|
||||
|
||||
void notifyReceivedMessage (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void notifyReceivedFileMessage (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void notifyReceivedCall (const std::shared_ptr<linphone::Call> &call);
|
||||
void notifyNewVersionAvailable (const QString &version, const QString &url);
|
||||
void notifySnapshotWasTaken (const QString &filePath);
|
||||
void notifyRecordingCompleted (const QString &filePath);
|
||||
|
||||
public slots:
|
||||
void deleteNotificationOnTimeout(QVariant notification);
|
||||
void deleteNotification (QVariant notification);
|
||||
|
||||
void deleteNotificationOnTimeout(QVariant notification);
|
||||
void deleteNotification (QVariant notification);
|
||||
|
||||
private:
|
||||
struct Notification {
|
||||
Notification (const QString &filename = QString(""), int timeout = 0) {
|
||||
this->filename = filename;
|
||||
this->timeout = timeout;
|
||||
}
|
||||
|
||||
QString filename;
|
||||
int timeout;
|
||||
};
|
||||
|
||||
QObject *createNotification (NotificationType type, QVariantMap data);
|
||||
void showNotification (QObject *notification, int timeout);
|
||||
|
||||
QHash<QString,int> mScreenHeightOffset;
|
||||
int mInstancesNumber = 0;
|
||||
|
||||
QMutex *mMutex = nullptr;
|
||||
QQmlComponent **mComponents = nullptr;
|
||||
|
||||
static const QHash<int, Notification> Notifications;
|
||||
struct Notification {
|
||||
Notification (const int& type = 0, const QString &filename = QString(""), int timeout = 0) {
|
||||
this->type = type;
|
||||
this->filename = filename;
|
||||
this->timeout = timeout;
|
||||
}
|
||||
int getTimeout() const{
|
||||
if( type == Notifier::ReceivedCall){
|
||||
return CoreManager::getInstance()->getSettingsModel()->getIncomingCallTimeout();
|
||||
}else
|
||||
return timeout;
|
||||
}
|
||||
QString filename;
|
||||
private:
|
||||
int timeout;
|
||||
int type;
|
||||
};
|
||||
|
||||
QObject *createNotification (NotificationType type, QVariantMap data);
|
||||
void showNotification (QObject *notification, int timeout);
|
||||
|
||||
QHash<QString,int> mScreenHeightOffset;
|
||||
int mInstancesNumber = 0;
|
||||
|
||||
QMutex *mMutex = nullptr;
|
||||
QQmlComponent **mComponents = nullptr;
|
||||
|
||||
static const QHash<int, Notification> Notifications;
|
||||
};
|
||||
|
||||
#endif // NOTIFIER_H_
|
||||
|
|
|
|||
|
|
@ -798,6 +798,9 @@ void SettingsModel::setContactsEnabled (bool status) {
|
|||
emit contactsEnabledChanged(getContactsEnabled ());
|
||||
}
|
||||
|
||||
int SettingsModel::getIncomingCallTimeout() const {
|
||||
return CoreManager::getInstance()->getCore()->getIncTimeout();
|
||||
}
|
||||
// =============================================================================
|
||||
// Network.
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -370,6 +370,8 @@ public:
|
|||
bool getContactsEnabled () const;
|
||||
void setContactsEnabled (bool status);
|
||||
|
||||
int getIncomingCallTimeout() const;
|
||||
|
||||
// Network. ------------------------------------------------------------------
|
||||
|
||||
bool getShowNetworkSettings () const;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue