Skip to content

Commit

Permalink
Merge branch 'vibra_while_display_off' into 'master'
Browse files Browse the repository at this point in the history
Vibra while display off

See merge request mer-core/lipstick!102
  • Loading branch information
pvuorela committed Jan 16, 2019
2 parents eab5441 + 4a46d42 commit 46b0020
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/notifications/notificationfeedbackplayer.cpp
Expand Up @@ -50,8 +50,8 @@ void NotificationFeedbackPlayer::addNotification(uint id)
{
LipstickNotification *notification = NotificationManager::instance()->notification(id);

// feedback on notifications just directly omitted, not expecting practical use for playing feedback on every update
if (notification != 0 && isEnabled(notification) && !notification->hasProgress()) {
// feedback on progress update just directly omitted, not expecting practical use for playing feedback on every update
if (notification != 0 && !notification->hasProgress()) {
// Stop feedback previously generated by this notification, if current
QMultiHash<LipstickNotification *, uint>::iterator it = m_idToEventId.find(notification);
while (it != m_idToEventId.end() && it.key() == notification) {
Expand All @@ -62,7 +62,7 @@ void NotificationFeedbackPlayer::addNotification(uint id)
// Play the feedback related to the notification if any
const QString feedback = notification->hints().value(LipstickNotification::HINT_FEEDBACK).toString();
const QStringList feedbackItems = feedback.split(QStringLiteral(","), QString::SkipEmptyParts);
if (!feedbackItems.isEmpty()) {
if (isEnabled(notification, m_minimumPriority) && !feedbackItems.isEmpty()) {
QMap<QString, QVariant> properties;
if (notification->hints().value(LipstickNotification::HINT_LED_DISABLED_WITHOUT_BODY_AND_SUMMARY, true).toBool() &&
notification->body().isEmpty() &&
Expand All @@ -82,7 +82,9 @@ void NotificationFeedbackPlayer::addNotification(uint id)
m_idToEventId.insert(notification, m_ngfClient->play(item, properties));
}
}
if (notification->hints().value(LipstickNotification::HINT_VIBRA, false).toBool()) {

// vibra played if it's asked regardless of priorities
if (isEnabled(notification, 0) && notification->hints().value(LipstickNotification::HINT_VIBRA, false).toBool()) {
m_ngfClient->stop("vibra");
m_idToEventId.insert(notification, m_ngfClient->play("vibra", QMap<QString, QVariant>()));
}
Expand All @@ -103,7 +105,7 @@ void NotificationFeedbackPlayer::removeNotification(uint id)
}
}

bool NotificationFeedbackPlayer::isEnabled(LipstickNotification *notification)
bool NotificationFeedbackPlayer::isEnabled(LipstickNotification *notification, int minimumPriority)
{
if (notification->hidden() || notification->restored())
return false;
Expand All @@ -118,10 +120,10 @@ bool NotificationFeedbackPlayer::isEnabled(LipstickNotification *notification)
int priority = notification->priority();
int notificationIsCritical = urgency >= 2 || notification->hints().value(LipstickNotification::HINT_DISPLAY_ON).toBool();

return !(urgency < 2 && priority < m_minimumPriority) &&
(mode == AllNotificationsEnabled ||
(mode == ApplicationNotificationsDisabled && notificationIsCritical) ||
(mode == SystemNotificationsDisabled && urgency < 2));
return (priority >= minimumPriority || notificationIsCritical)
&& (mode == AllNotificationsEnabled
|| (mode == ApplicationNotificationsDisabled && notificationIsCritical)
|| (mode == SystemNotificationsDisabled && urgency < 2));
}

int NotificationFeedbackPlayer::minimumPriority() const
Expand Down
2 changes: 1 addition & 1 deletion src/notifications/notificationfeedbackplayer.h
Expand Up @@ -76,7 +76,7 @@ private slots:

private:
//! Check whether feedbacks should be enabled for the given notification
bool isEnabled(LipstickNotification *notification);
bool isEnabled(LipstickNotification *notification, int minimumPriority);

//! Non-graphical feedback player
Ngf::Client *m_ngfClient;
Expand Down
2 changes: 2 additions & 0 deletions src/notifications/notificationmanager.cpp
Expand Up @@ -20,6 +20,8 @@
#include <QSqlQuery>
#include <QSqlRecord>
#include <QSqlTableModel>
#include <QFile>
#include <QFileInfo>
#include <mremoteaction.h>
#include <mdesktopentry.h>
#include <sys/statfs.h>
Expand Down

0 comments on commit 46b0020

Please sign in to comment.