Skip to content

Commit

Permalink
[notifications] Add API for the "sound-file" hint. Fixes JB#50223
Browse files Browse the repository at this point in the history
  • Loading branch information
adenexter committed Aug 18, 2020
1 parent 4a48dc5 commit 3ee9f65
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/notification.cpp
Expand Up @@ -57,6 +57,7 @@ const char *HINT_OWNER = "x-nemo-owner";
const char *HINT_MAX_CONTENT_LINES = "x-nemo-max-content-lines";
const char *DEFAULT_ACTION_NAME = "default";
const char *HINT_PROGRESS = "x-nemo-progress";
const char *HINT_SOUND_FILE = "sound-file";

static inline QString processName() {
// Defaults to the filename if not set
Expand Down Expand Up @@ -940,6 +941,34 @@ void Notification::setSubText(const QString &subText)
emit subTextChanged();
}
}
/*!
\qmlproperty string Notification::sound
The file path of a sound to be played when the notification is shown.
This property is transmitted as the hint value "sound-file".
*/
/*!
\property Notification::sound
The file path of a sound to be played when the notification is shown.
This property is transmitted as the hint value "sound-file".
*/
QString Notification::sound() const
{
Q_D(const Notification);
return d->hints.value(HINT_SOUND_FILE).toString();
}

void Notification::setSound(const QString &sound)
{
Q_D(Notification);
if (sound != this->sound()) {
d->hints.insert(HINT_SOUND_FILE, sound);
emit soundChanged();
}
}

/*!
\qmlproperty int Notification::itemCount
Expand Down
5 changes: 5 additions & 0 deletions src/notification.h
Expand Up @@ -59,6 +59,7 @@ class Q_DECL_EXPORT Notification : public QObject
Q_PROPERTY(QString previewSummary READ previewSummary WRITE setPreviewSummary RESET clearPreviewSummary NOTIFY previewSummaryChanged)
Q_PROPERTY(QString previewBody READ previewBody WRITE setPreviewBody RESET clearPreviewBody NOTIFY previewBodyChanged)
Q_PROPERTY(QString subText READ subText WRITE setSubText NOTIFY subTextChanged)
Q_PROPERTY(QString sound READ sound WRITE setSound NOTIFY soundChanged)
Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged)
Q_PROPERTY(QString remoteDBusCallServiceName READ remoteDBusCallServiceName WRITE setRemoteDBusCallServiceName NOTIFY remoteDBusCallChanged)
Q_PROPERTY(QString remoteDBusCallObjectPath READ remoteDBusCallObjectPath WRITE setRemoteDBusCallObjectPath NOTIFY remoteDBusCallChanged)
Expand Down Expand Up @@ -124,6 +125,9 @@ class Q_DECL_EXPORT Notification : public QObject
QString subText() const;
void setSubText(const QString &subText);

QString sound() const;
void setSound(const QString &sound);

int itemCount() const;
void setItemCount(int itemCount);

Expand Down Expand Up @@ -193,6 +197,7 @@ class Q_DECL_EXPORT Notification : public QObject
void timestampChanged();
void previewSummaryChanged();
void previewBodyChanged();
void soundChanged();
void itemCountChanged();
void remoteActionsChanged();
void remoteDBusCallChanged();
Expand Down

0 comments on commit 3ee9f65

Please sign in to comment.