Skip to content
Merged
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
10 changes: 8 additions & 2 deletions panels/notification/bubble/bubbleitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,15 @@ QVariantList BubbleItem::actions() const
void BubbleItem::updateActions()
{
QStringList actions = m_entity.actions();
if (actions.contains(QLatin1String("default"))) {
actions.removeAll(QLatin1String("default"));
const auto index = actions.indexOf(QLatin1String("default"));
if (index >= 0) {
// default Action maybe have text.
m_defaultAction = QLatin1String("default");
if (actions.size() % 2 == 1) {
actions.remove(index);
} else {
actions.remove(index, 2);
}
}

Q_ASSERT(actions.size() % 2 != 1);
Expand Down
4 changes: 2 additions & 2 deletions panels/notification/bubble/package/NormalBubble.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ D.Control {
if (!bubble.defaultAction)
return

console.log("default action", bubble.index)
Applet.invokeDefaultAction(bubble.index, bubble.defaultAction)
console.log("default action notify", bubble.appName, bubble.defaultAction)
Applet.invokeAction(bubble.index, bubble.defaultAction)
}
property bool longPressed
onPressAndHold: {
Expand Down
11 changes: 8 additions & 3 deletions panels/notification/center/notifyitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ QVariantList AppNotifyItem::actions() const
void AppNotifyItem::updateActions()
{
QStringList actions = m_entity.actions();
if (actions.contains(QLatin1String("default"))) {
actions.removeAll(QLatin1String("default"));
m_defaultAction = QLatin1String("default");
const auto index = actions.indexOf(QLatin1String("default"));
if (index >= 0) {
// default Action maybe have text.
if (actions.size() % 2 == 1) {
actions.remove(index);
} else {
actions.remove(index, 2);
}
}

Q_ASSERT(actions.size() % 2 != 1);
Expand Down
5 changes: 5 additions & 0 deletions panels/notification/common/notifyentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ bool NotifyEntity::operator==(const NotifyEntity &other) const
return false;
}

bool NotifyEntity::operator!=(const NotifyEntity &other) const
{
return !(operator==(other));
}

bool NotifyEntity::isValid() const
{
return d && d->id > 0;
Expand Down
1 change: 1 addition & 0 deletions panels/notification/common/notifyentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class NotifyEntity
NotifyEntity &operator=(NotifyEntity &&other);

bool operator==(const NotifyEntity &other) const;
bool operator!=(const NotifyEntity &other) const;

bool isValid() const;

Expand Down
12 changes: 8 additions & 4 deletions panels/notification/server/dbusadaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

QStringList DbusAdaptor::GetCapabilities()
{
qDebug(notifyLog) << "GetCapabilities";
qInfo(notifyLog) << "GetCapabilities";
return manager()->GetCapabilities();
}

Expand All @@ -40,13 +40,13 @@

void DbusAdaptor::CloseNotification(uint id)
{
qDebug(notifyLog) << "Close notification" << id;
qInfo(notifyLog) << "Close notification" << id;
manager()->CloseNotification(id);
}

void DbusAdaptor::GetServerInformation(QString &name, QString &vendor, QString &version, QString &specVersion)
{
qDebug(notifyLog) << "GetServerInformation";
qInfo(notifyLog) << "GetServerInformation";
manager()->GetServerInformation(name, vendor, version, specVersion);
}

Expand All @@ -63,6 +63,7 @@

QStringList DDENotificationDbusAdaptor::GetCapabilities()
{
qInfo(notifyLog) << "GetCapabilities";
return manager()->GetCapabilities();
}

Expand All @@ -83,11 +84,13 @@

void DDENotificationDbusAdaptor::CloseNotification(uint id)
{
qInfo(notifyLog) << "Close Notification" << id;
manager()->CloseNotification(id);
}

void DDENotificationDbusAdaptor::GetServerInformation(QString &name, QString &vendor, QString &version, QString &specVersion)
{
qInfo(notifyLog) << "GetServerInformation";
manager()->GetServerInformation(name, vendor, version, specVersion);
}

Expand Down Expand Up @@ -116,12 +119,13 @@
return manager()->SetAppInfo(appId, configItem, value.variant());
}

QString DDENotificationDbusAdaptor::GetAppSetting(const QString &appName)

Check warning on line 122 in panels/notification/server/dbusadaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'GetAppSetting' is never used.
{
return QString();
Q_UNUSED(appName)
return {};
}

void DDENotificationDbusAdaptor::SetAppSetting(const QString &settings)

Check warning on line 128 in panels/notification/server/dbusadaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'SetAppSetting' is never used.
{

}
Expand Down
30 changes: 25 additions & 5 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ uint NotificationManager::recordCount() const

void NotificationManager::actionInvoked(qint64 id, uint bubbleId, const QString &actionKey)
{
qInfo(notifyLog) << "Action invoked, bubbleId:" << bubbleId << ", id:" << id << ", actionKey" << actionKey;
auto entity = m_persistence->fetchEntity(id);
if (entity.isValid()) {
doActionInvoked(entity, actionKey);

entity.setProcessedType(NotifyEntity::Removed);
updateEntityProcessed(entity);
}
doActionInvoked(entity, actionKey);

Q_EMIT ActionInvoked(bubbleId, actionKey);
Q_EMIT NotificationClosed(bubbleId, NotifyEntity::Closed);
Expand Down Expand Up @@ -257,19 +259,22 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
}
}

qInfo(notifyLog) << "Notify done, bubbleId:" << entity.bubbleId() << ", id:" << entity.id();

// If replaces_id is 0, the return value is a UINT32 that represent the notification.
// If replaces_id is not 0, the returned value is the same value as replaces_id.
return replacesId == 0 ? entity.bubbleId() : replacesId;
return entity.bubbleId();
}
void NotificationManager::CloseNotification(uint id)
{
// TODO If the notification no longer exists, an empty D-BUS Error message is sent back.
const auto entity = m_persistence->fetchLastEntity(id);
auto entity = m_persistence->fetchLastEntity(id);
if (entity.isValid()) {
Q_EMIT NotificationStateChanged(entity.id(), entity.processedType());
entity.setProcessedType(NotifyEntity::Removed);
updateEntityProcessed(entity);
}

Q_EMIT NotificationClosed(id, NotifyEntity::Closed);
qDebug(notifyLog) << "Close notify, bubbleId" << id << ", id:" << entity.id();
}

void NotificationManager::GetServerInformation(QString &name, QString &vendor, QString &version, QString &specVersion)
Expand Down Expand Up @@ -413,6 +418,7 @@ void NotificationManager::updateEntityProcessed(const NotifyEntity &entity)
const auto bluetooth = entity.body().contains("%") && entity.actions().contains("cancel");
if (removed || !showInCenter || bluetooth) {
m_persistence->removeEntity(id);
removePendingEntity(entity);
} else {
m_persistence->updateEntityProcessedType(id, entity.processedType());
}
Expand Down Expand Up @@ -485,4 +491,18 @@ void NotificationManager::onHandingPendingEntities()
}
}

void NotificationManager::removePendingEntity(const NotifyEntity &entity)
{
for (auto iter = m_pendingTimeoutEntities.begin(); iter != m_pendingTimeoutEntities.end();) {
const auto item = iter.value();
if (item != entity) {
iter++;
continue;
}
m_pendingTimeoutEntities.erase(iter);
onHandingPendingEntities();
break;
}
}

} // notification
1 change: 1 addition & 0 deletions panels/notification/server/notificationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public Q_SLOTS:

private slots:
void onHandingPendingEntities();
void removePendingEntity(const NotifyEntity &entity);

private:
uint m_replacesCount = 0;
Expand Down
Loading