Skip to content

Commit

Permalink
[lipstick] Expose android type color info on notifications. Contribut…
Browse files Browse the repository at this point in the history
…es to JB#51447

Expose color set on apkd, used with app icon.
  • Loading branch information
pvuorela committed Oct 15, 2020
1 parent 83c4721 commit 2bbb079
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/notifications/lipsticknotification.cpp
Expand Up @@ -232,6 +232,7 @@ void LipstickNotification::setHints(const QVariantHash &hints)
qreal oldProgress = progress();
bool oldHasProgress = hasProgress();
bool oldIsTransient = isTransient();
QString oldColor = color();

m_hints = hints;
updateHintValues();
Expand Down Expand Up @@ -286,6 +287,10 @@ void LipstickNotification::setHints(const QVariantHash &hints)
emit isTransientChanged();
}

if (oldColor != color()) {
emit colorChanged();
}

emit hintsChanged();
}

Expand Down Expand Up @@ -344,6 +349,11 @@ bool LipstickNotification::isTransient() const
return m_hints.value(LipstickNotification::HINT_TRANSIENT).toBool();
}

QString LipstickNotification::color() const
{
return m_hints.value(QLatin1String("x-nemo-color")).toString();
}

bool LipstickNotification::isUserRemovable() const
{
if (hasProgress() && m_activeProgressTimer && m_activeProgressTimer->isActive()) {
Expand Down
5 changes: 5 additions & 0 deletions src/notifications/lipsticknotification.h
Expand Up @@ -56,6 +56,7 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool hasProgress READ hasProgress NOTIFY hasProgressChanged)
Q_PROPERTY(bool isTransient READ isTransient NOTIFY isTransientChanged)
Q_PROPERTY(QString color READ color NOTIFY colorChanged)

public:
enum Urgency { Low = 0, Normal = 1, Critical = 2 };
Expand Down Expand Up @@ -241,6 +242,9 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Returns whether the notification is transient
bool isTransient() const;

//! Returns the color set for notification, commonly just for Android compatibility
QString color() const;

//! Returns the user removability of the notification
bool isUserRemovable() const;

Expand Down Expand Up @@ -334,6 +338,7 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
void progressChanged();

void isTransientChanged();
void colorChanged();

private:
void updateHintValues();
Expand Down

0 comments on commit 2bbb079

Please sign in to comment.