Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions panels/notification/bubble/bubblemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void BubbleModel::insertBubble(BubbleItem *bubble)
beginInsertRows(QModelIndex(), 0, 0);
m_bubbles.prepend(bubble);
endInsertRows();

Q_EMIT bubbleShown(bubble->id());
}

bool BubbleModel::isReplaceBubble(const BubbleItem *bubble) const
Expand All @@ -98,6 +100,8 @@ BubbleItem *BubbleModel::replaceBubble(BubbleItem *bubble)
m_bubbles.replace(replaceIndex, bubble);
Q_EMIT dataChanged(index(replaceIndex), index(replaceIndex));

Q_EMIT bubbleShown(bubble->id());

return oldBubble;
}

Expand Down
3 changes: 3 additions & 0 deletions panels/notification/bubble/bubblemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class BubbleModel : public QAbstractListModel
explicit BubbleModel(QObject *parent = nullptr);
~BubbleModel() override;

Q_SIGNALS:
void bubbleShown(qint64 id);

public:
void push(BubbleItem *bubble);

Expand Down
7 changes: 7 additions & 0 deletions panels/notification/bubble/bubblepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ bool BubblePanel::init()
connect(m_bubbles, &BubbleModel::rowsInserted, this, &BubblePanel::onBubbleCountChanged);
connect(m_bubbles, &BubbleModel::rowsRemoved, this, &BubblePanel::onBubbleCountChanged);

connect(m_bubbles, &BubbleModel::bubbleShown, this, &BubblePanel::onBubbleShown);

return true;
}

Expand Down Expand Up @@ -168,6 +170,11 @@ void BubblePanel::onBubbleClosed(qint64 id, uint bubbleId, uint reason)
Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, reason));
}

void BubblePanel::onBubbleShown(qint64 id)
{
QMetaObject::invokeMethod(m_notificationServer, "onBubbleShowed", Qt::DirectConnection, Q_ARG(qint64, id));
}

void BubblePanel::setVisible(const bool visible)
{
if (visible == m_visible)
Expand Down
1 change: 1 addition & 0 deletions panels/notification/bubble/bubblepanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private Q_SLOTS:
void addBubble(qint64 id);
void closeBubble(qint64 id);
void onBubbleCountChanged();
void onBubbleShown(qint64 id);

private:
void onBubbleExpired(BubbleItem *);
Expand Down
22 changes: 21 additions & 1 deletion panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
}
// 0: never expire. -1: DefaultTimeOutMSecs
if (expireTimeout != 0 && !critical) {
pushPendingEntity(entity, expireTimeout);
m_pendingExpireTimeouts.insert(entity.id(), expireTimeout);
}
}

Expand Down Expand Up @@ -513,6 +513,25 @@ void NotificationManager::pushPendingEntity(const NotifyEntity &entity, int expi
}
}

void NotificationManager::onBubbleShowed(qint64 id)
{
auto it = m_pendingExpireTimeouts.find(id);
if (it == m_pendingExpireTimeouts.end()) {
return;
}

auto entity = m_persistence->fetchEntity(id);
if (!entity.isValid()) {
qWarning(notifyLog) << "onBubbleShowed: invalid entity for id" << id;
m_pendingExpireTimeouts.erase(it);
return;
}

int expireTimeout = it.value();
m_pendingExpireTimeouts.erase(it);
pushPendingEntity(entity, expireTimeout);
}

void NotificationManager::updateEntityProcessed(qint64 id, uint reason)
{
auto entity = m_persistence->fetchEntity(id);
Expand Down Expand Up @@ -768,6 +787,7 @@ void NotificationManager::removePendingEntity(const NotifyEntity &entity)
}
++iter;
}
m_pendingExpireTimeouts.remove(entity.id());
}

void NotificationManager::onScreenLockedChanged(bool screenLocked)
Expand Down
2 changes: 2 additions & 0 deletions panels/notification/server/notificationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class NotificationManager : public QObject, public QDBusContext
Q_INVOKABLE void actionInvoked(qint64 id, uint bubbleId, const QString &actionKey);
Q_INVOKABLE void notificationClosed(qint64 id, uint bubbleId, uint reason);
Q_INVOKABLE void notificationReplaced(qint64 id);
Q_INVOKABLE void onBubbleShowed(qint64 id);

void removeNotification(qint64 id);
void removeNotifications(const QString &appName);
Expand Down Expand Up @@ -99,6 +100,7 @@ private slots:
QTimer *m_pendingTimeout = nullptr;
qint64 m_lastTimeoutPoint = std::numeric_limits<qint64>::max();
QMultiHash<qint64, NotifyEntity> m_pendingTimeoutEntities;
QHash<qint64, int> m_pendingExpireTimeouts;
QStringList m_systemApps;
QMap<QString, QVariant> m_appNamesMap;
int m_cleanupDays = 7;
Expand Down
5 changes: 5 additions & 0 deletions panels/notification/server/notifyserverapplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ void NotifyServerApplet::setBlockClosedId(qint64 id)
m_manager->setBlockClosedId(id);
}

void NotifyServerApplet::onBubbleShowed(qint64 id)
{
QMetaObject::invokeMethod(m_manager, "onBubbleShowed", Qt::DirectConnection, Q_ARG(qint64, id));
}

D_APPLET_CLASS(NotifyServerApplet)

}
Expand Down
1 change: 1 addition & 0 deletions panels/notification/server/notifyserverapplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public Q_SLOTS:
void removeNotifications();
void removeExpiredNotifications();
void setBlockClosedId(qint64 id);
void onBubbleShowed(qint64 id);

private:
NotificationManager *m_manager = nullptr;
Expand Down
Loading