Skip to content

Commit

Permalink
[lipstick] Add subText hint and property. JB#50447
Browse files Browse the repository at this point in the history
  • Loading branch information
Bea Lam committed Jul 27, 2020
1 parent 058d26a commit 404ace5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/notifications/lipsticknotification.cpp
Expand Up @@ -36,6 +36,7 @@ const char *LipstickNotification::HINT_TIMESTAMP = "x-nemo-timestamp";
const char *LipstickNotification::HINT_PREVIEW_ICON = "x-nemo-preview-icon";
const char *LipstickNotification::HINT_PREVIEW_BODY = "x-nemo-preview-body";
const char *LipstickNotification::HINT_PREVIEW_SUMMARY = "x-nemo-preview-summary";
const char *LipstickNotification::HINT_SUB_TEXT = "x-nemo-sub-text";
const char *LipstickNotification::HINT_REMOTE_ACTION_PREFIX = "x-nemo-remote-action-";
const char *LipstickNotification::HINT_REMOTE_ACTION_ICON_PREFIX = "x-nemo-remote-action-icon-";
const char *LipstickNotification::HINT_USER_REMOVABLE = "x-nemo-user-removable";
Expand Down Expand Up @@ -184,6 +185,7 @@ void LipstickNotification::setHints(const QVariantHash &hints)
quint64 oldTimestamp = m_timestamp;
QString oldPreviewSummary = previewSummary();
QString oldPreviewBody = previewBody();
QString oldSubText = subText();
int oldUrgency = urgency();
int oldItemCount = itemCount();
int oldPriority = m_priority;
Expand Down Expand Up @@ -211,6 +213,10 @@ void LipstickNotification::setHints(const QVariantHash &hints)
emit previewBodyChanged();
}

if (oldSubText != subText()) {
emit subTextChanged();
}

if (oldUrgency != urgency()) {
emit urgencyChanged();
}
Expand Down Expand Up @@ -264,6 +270,11 @@ QString LipstickNotification::previewBody() const
return m_hints.value(LipstickNotification::HINT_PREVIEW_BODY).toString();
}

QString LipstickNotification::subText() const
{
return m_hints.value(LipstickNotification::HINT_SUB_TEXT).toString();
}

int LipstickNotification::urgency() const
{
return m_hints.value(LipstickNotification::HINT_URGENCY).toInt();
Expand Down Expand Up @@ -439,6 +450,7 @@ void LipstickNotification::updateHintValues()
hint.compare(LipstickNotification::HINT_TIMESTAMP, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_PREVIEW_SUMMARY, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_PREVIEW_BODY, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_SUB_TEXT, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_URGENCY, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_ITEM_COUNT, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_PRIORITY, Qt::CaseInsensitive) != 0 &&
Expand Down
10 changes: 10 additions & 0 deletions src/notifications/lipsticknotification.h
Expand Up @@ -42,6 +42,7 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY timestampChanged)
Q_PROPERTY(QString previewSummary READ previewSummary NOTIFY previewSummaryChanged)
Q_PROPERTY(QString previewBody READ previewBody NOTIFY previewBodyChanged)
Q_PROPERTY(QString subText READ subText NOTIFY subTextChanged)
Q_PROPERTY(int urgency READ urgency NOTIFY urgencyChanged)
Q_PROPERTY(int itemCount READ itemCount NOTIFY itemCountChanged)
Q_PROPERTY(int priority READ priority NOTIFY priorityChanged)
Expand Down Expand Up @@ -102,6 +103,9 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Nemo hint: Summary text of the preview of the notification.
static const char *HINT_PREVIEW_SUMMARY;

//! Nemo hint: Sub-text of the notification.
static const char *HINT_SUB_TEXT;

//! Nemo hint: Remote action of the notification. Prefix only: the action identifier is to be appended.
static const char *HINT_REMOTE_ACTION_PREFIX;

Expand Down Expand Up @@ -227,6 +231,9 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Returns the body text for the preview of the notification
QString previewBody() const;

//! Returns the sub-text for the notification
QString subText() const;

//! Returns the urgency of the notification
int urgency() const;

Expand Down Expand Up @@ -318,6 +325,9 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Sent when the preview body has been modified
void previewBodyChanged();

//! Sent when the sub text has been modified
void subTextChanged();

//! Sent when the urgency has been modified
void urgencyChanged();

Expand Down

0 comments on commit 404ace5

Please sign in to comment.