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
23 changes: 7 additions & 16 deletions panels/notification/center/NotifyAction.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Control {
height: 30
NotifyActionButton {
actionData: actions[0]
Layout.maximumWidth: 60
Layout.maximumWidth: 120
Layout.preferredHeight: 30
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter
Expand All @@ -29,7 +29,7 @@ Control {
Loader {
active: actions.length === 2
visible: active
Layout.maximumWidth: 60
Layout.maximumWidth: 120
Layout.preferredHeight: 30
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter
Expand All @@ -41,7 +41,7 @@ Control {
Loader {
active: actions.length > 2
visible: active
Layout.maximumWidth: 80
Layout.maximumWidth: 120
Layout.alignment: Qt.AlignHCenter
sourceComponent: ComboBox {
property var expandActions: actions.slice(1)
Expand Down Expand Up @@ -75,22 +75,13 @@ Control {
actionInvoked(actionData.id)
}

background: DP.ButtonPanel {
background: NotifyItemBackground {
implicitHeight: 30
implicitWidth: 50
button: actionButton
color1: Palette {
normal {
common: ("transparent")
crystal: Qt.rgba(0 / 255.0, 0 / 255.0, 0 / 255.0, 0.15)
}
normalDark {
crystal: Qt.rgba(24 / 255.0, 24 / 255.0, 24 / 255.0, 1)
}
}
color2: color1
insideBorderColor: null
radius: 6
outsideBorderColor: null
insideBorderColor: null
anchors.fill: parent
}
}
}
2 changes: 1 addition & 1 deletion panels/notification/center/NotifyHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FocusScope {
onHeaderClicked: function () {
dataPanelLoader.active = !dataPanelLoader.active
NotifyAccessor.fetchDataInfo()
dataPanel.show()
dataPanelLoader.item.show()
}
Loader {
id: dataPanelLoader
Expand Down
7 changes: 0 additions & 7 deletions panels/notification/center/NotifyItemContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ NotifyItem {
onActionInvoked: function (actionId) {
root.actionInvoked(actionId)
}
background: NotifyItemBackground {
radius: 6
implicitHeight: 30
implicitWidth: 50
outsideBorderColor: null
insideBorderColor: null
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion panels/notification/center/notifyaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@
}
}

void NotifyAccessor::fetchDataInfo()

Check warning on line 269 in panels/notification/center/notifyaccessor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'fetchDataInfo' is never used.
{
QStringList info;
auto entityCount = fetchEntityCount();
auto entityCount = fetchEntityCount(DataAccessor::AllApp());
auto apps = fetchApps();
info.append(QString("notifyCount: %1, appCount: %2").arg(entityCount).arg(apps.size()));
for (auto item : apps) {
Expand Down
2 changes: 1 addition & 1 deletion panels/notification/center/notifyaccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NotifyAccessor : public QObject
Q_INVOKABLE void openNotificationSetting();

NotifyEntity fetchEntity(qint64 id) const;
int fetchEntityCount(const QString &appName = QString()) const;
int fetchEntityCount(const QString &appName) const;
NotifyEntity fetchLastEntity(const QString &appName) const;
QList<NotifyEntity> fetchEntities(const QString &appName, int maxCount = -1);
QStringList fetchApps(int maxCount = -1) const;
Expand Down
35 changes: 18 additions & 17 deletions panels/notification/center/notifymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ QVariant NotifyModel::data(const QModelIndex &index, int role) const
} else if (role == NotifyRole::NotifyId) {
return notify->id();
} else if (role == NotifyRole::NotifyAppId) {
return notify->appId();
} else if (role == NotifyRole::NotifyAppName) {
return notify->appName();
} else if (role == NotifyRole::NotifyIconName) {
return notify->entity().appIcon();
Expand All @@ -692,11 +694,11 @@ QVariant NotifyModel::data(const QModelIndex &index, int role) const
return notify->actions();
} else if (role == NotifyRole::NotifyDefaultAction) {
return notify->defaultAction();
} else if (role == NotifyRole::NotifyTime) {
} else if (role == NotifyRole::NotifyTime) {
return notify->time();
} else if (role == NotifyRole::NotifyPinned) {
return notify->pinned();
} else if (role == NotifyRole::NotifyStrongInteractive) {
} else if (role == NotifyRole::NotifyStrongInteractive) {
return notify->strongInteractive();
} else if (role == NotifyRole::NotifyContentIcon) {
return notify->contentIcon();
Expand Down Expand Up @@ -744,21 +746,20 @@ void NotifyModel::updateTime()

QHash<int, QByteArray> NotifyModel::roleNames() const
{
static const QHash<int, QByteArray> roles {
{NotifyItemType, "type"},
{NotifyId, "id"},
{NotifyAppId, "appName"},
{NotifyIconName, "iconName"},
{NotifyActions, "actions"},
{NotifyDefaultAction, "defaultAction"},
{NotifyTime, "time"},
{NotifyTitle, "title"},
{NotifyContent, "content"},
{NotifyPinned, "pinned"},
{NotifyStrongInteractive, "strongInteractive"},
{NotifyContentIcon, "contentIcon"},
{NotifyOverlapCount, "overlapCount"}
};
static const QHash<int, QByteArray> roles{{NotifyItemType, "type"},
{NotifyId, "id"},
{NotifyAppId, "appId"},
{NotifyAppName, "appName"},
{NotifyIconName, "iconName"},
{NotifyActions, "actions"},
{NotifyDefaultAction, "defaultAction"},
{NotifyTime, "time"},
{NotifyTitle, "title"},
{NotifyContent, "content"},
{NotifyPinned, "pinned"},
{NotifyStrongInteractive, "strongInteractive"},
{NotifyContentIcon, "contentIcon"},
{NotifyOverlapCount, "overlapCount"}};
return roles;
}

Expand Down
1 change: 1 addition & 0 deletions panels/notification/center/notifymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class NotifyModel : public QAbstractListModel
enum NotifyRole {
NotifyItemType = Qt::UserRole + 1,
NotifyId,
NotifyAppName,
NotifyAppId,
NotifyIconName,
NotifyActions,
Expand Down
37 changes: 19 additions & 18 deletions panels/notification/center/notifystagingmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
}
{
// update count
auto count = m_accessor->fetchEntityCount("", NotifyEntity::NotProcessed);
auto count = m_accessor->fetchEntityCount(DataAccessor::AllApp(), NotifyEntity::NotProcessed);
updateOverlapCount(count);
}

Expand Down Expand Up @@ -96,10 +96,10 @@
break;
}

auto entities = m_accessor->fetchEntities("", NotifyEntity::NotProcessed, BubbleMaxCount + OverlayMaxCount);
auto entities = m_accessor->fetchEntities(DataAccessor::AllApp(), NotifyEntity::NotProcessed, BubbleMaxCount + OverlayMaxCount);

if (row >= 0) {
auto notify = m_appNotifies[row];

Check warning on line 102 in panels/notification/center/notifystagingmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Local variable 'notify' shadows outer variable
const auto entity = notify->entity();

beginRemoveRows(QModelIndex(), row, row);
Expand Down Expand Up @@ -153,7 +153,7 @@
{
qDebug(notifyLog) << "Open staging model";

auto entities = m_accessor->fetchEntities("", NotifyEntity::NotProcessed, BubbleMaxCount + OverlayMaxCount);
auto entities = m_accessor->fetchEntities(DataAccessor::AllApp(), NotifyEntity::NotProcessed, BubbleMaxCount + OverlayMaxCount);

qDebug(notifyLog) << "Fetched staging size" << entities.size();
if (entities.size() <= 0)
Expand Down Expand Up @@ -186,6 +186,8 @@
if (role == NotifyRole::NotifyId) {
return notify->id();
} else if (role == NotifyRole::NotifyAppId) {
return notify->appId();
} else if (role == NotifyRole::NotifyAppName) {
return notify->appName();
} else if (role == NotifyRole::NotifyIconName) {
return notify->entity().appIcon();
Expand All @@ -197,7 +199,7 @@
return notify->actions();
} else if (role == NotifyRole::NotifyDefaultAction) {
return notify->defaultAction();
} else if (role == NotifyRole::NotifyTime) {
} else if (role == NotifyRole::NotifyTime) {
return notify->time();
} else if (role == NotifyRole::NotifyStrongInteractive) {
return notify->strongInteractive();
Expand Down Expand Up @@ -237,20 +239,19 @@

QHash<int, QByteArray> NotifyStagingModel::roleNames() const
{
static const QHash<int, QByteArray> roles {
{NotifyItemType, "type"},
{NotifyId, "id"},
{NotifyAppId, "appName"},
{NotifyIconName, "iconName"},
{NotifyActions, "actions"},
{NotifyDefaultAction, "defaultAction"},
{NotifyTime, "time"},
{NotifyTitle, "title"},
{NotifyContent, "content"},
{NotifyStrongInteractive, "strongInteractive"},
{NotifyContentIcon, "contentIcon"},
{NotifyOverlapCount, "overlapCount"}
};
static const QHash<int, QByteArray> roles{{NotifyItemType, "type"},
{NotifyId, "id"},
{NotifyAppName, "appName"},
{NotifyAppId, "appId"},
{NotifyIconName, "iconName"},
{NotifyActions, "actions"},
{NotifyDefaultAction, "defaultAction"},
{NotifyTime, "time"},
{NotifyTitle, "title"},
{NotifyContent, "content"},
{NotifyStrongInteractive, "strongInteractive"},
{NotifyContentIcon, "contentIcon"},
{NotifyOverlapCount, "overlapCount"}};
return roles;
}

Expand Down
1 change: 1 addition & 0 deletions panels/notification/center/notifystagingmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class NotifyStagingModel : public QAbstractListModel
NotifyItemType = Qt::UserRole + 1,
NotifyId,
NotifyAppId,
NotifyAppName,
NotifyIconName,
NotifyActions,
NotifyDefaultAction,
Expand Down
4 changes: 4 additions & 0 deletions panels/notification/common/dataaccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class DataAccessor
virtual void removeEntity(qint64 id) { Q_UNUSED(id); }
virtual void removeEntityByApp(const QString &appName) { Q_UNUSED(appName); }
virtual void clear() {}
inline static QString AllApp()
{
return QLatin1String("AllApp");
}
};

}
21 changes: 9 additions & 12 deletions panels/notification/common/dbaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@
BENCHMARK();

QSqlQuery query(m_connection);
if (appName.isEmpty()) {
if (appName == DataAccessor::AllApp()) {
QString cmd = QString("SELECT COUNT(*) FROM notifications2 WHERE (ProcessedType = :processedType OR ProcessedType IS NULL)");
query.prepare(cmd);

Check warning on line 233 in panels/notification/common/dbaccessor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Error code from the return value of function query.prepare() is not used.
} else {
QString cmd = QString("SELECT COUNT(*) FROM notifications2 WHERE AppName = :appName AND (ProcessedType = :processedType OR ProcessedType IS NULL)");
query.prepare(cmd);
Expand All @@ -255,16 +255,13 @@
BENCHMARK();

QSqlQuery query(m_connection);
if (appName.isEmpty()) {
QString cmd = QString("SELECT %1 FROM notifications2 WHERE (ProcessedType = :processedType OR ProcessedType IS NULL) ORDER BY CTime DESC LIMIT 1").arg(EntityFields.join(","));
query.prepare(cmd);
query.bindValue(":processedType", processedType);
} else {
QString cmd = QString("SELECT %1 FROM notifications2 WHERE AppName = :appName AND (ProcessedType = :processedType OR ProcessedType IS NULL) ORDER BY CTime DESC LIMIT 1").arg(EntityFields.join(","));
query.prepare(cmd);
query.bindValue(":appName", appName);
query.bindValue(":processedType", processedType);
}
QString cmd =
QString(
"SELECT %1 FROM notifications2 WHERE AppName = :appName AND (ProcessedType = :processedType OR ProcessedType IS NULL) ORDER BY CTime DESC LIMIT 1")
.arg(EntityFields.join(","));
query.prepare(cmd);

Check warning on line 262 in panels/notification/common/dbaccessor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Error code from the return value of function query.prepare() is not used.
query.bindValue(":appName", appName);
query.bindValue(":processedType", processedType);

if (!query.exec()) {
qWarning(notifyDBLog) << "Query execution error:" << query.lastError().text();
Expand All @@ -285,10 +282,10 @@
BENCHMARK();

QSqlQuery query(m_connection);
if (appName.isEmpty()) {
if (appName == DataAccessor::AllApp()) {
if (maxCount >= 0) {
QString cmd = QString("SELECT %1 FROM notifications2 WHERE (ProcessedType = :processedType OR ProcessedType IS NULL) ORDER BY CTime DESC LIMIT :limit").arg(EntityFields.join(","));
query.prepare(cmd);

Check warning on line 288 in panels/notification/common/dbaccessor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Error code from the return value of function query.prepare() is not used.
query.bindValue(":limit", maxCount);
} else {
QString cmd = QString("SELECT %1 FROM notifications2 WHERE (ProcessedType = :processedType OR ProcessedType IS NULL) ORDER BY CTime DESC").arg(EntityFields.join(","));
Expand Down
8 changes: 5 additions & 3 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool NotificationManager::registerDbusService()

uint NotificationManager::recordCount() const
{
return m_persistence->fetchEntityCount(QLatin1String(), NotifyEntity::Processed);
return m_persistence->fetchEntityCount(DataAccessor::AllApp(), NotifyEntity::Processed);
}

void NotificationManager::actionInvoked(qint64 id, uint bubbleId, const QString &actionKey)
Expand All @@ -112,6 +112,7 @@ void NotificationManager::actionInvoked(qint64 id, uint bubbleId, const QString

void NotificationManager::notificationClosed(qint64 id, uint bubbleId, uint reason)
{
qDebug(notifyLog) << "Close notification id" << id << ", reason" << reason;
updateEntityProcessed(id, reason);

Q_EMIT NotificationClosed(bubbleId, reason);
Expand Down Expand Up @@ -166,6 +167,7 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
<< ", expireTimeout:" << expireTimeout;

if (calledFromDBus() && m_setting->systemValue(NotificationSetting::CloseNotification).toBool()) {
qDebug(notifyLog) << "Notify has been disabled by CloseNotification setting.";
return 0;
}

Expand Down Expand Up @@ -196,7 +198,7 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const

bool lockScreenShow = true;
bool dndMode = isDoNotDisturb();
bool systemNotification = m_systemApps.contains(appName);
bool systemNotification = m_systemApps.contains(appId);
bool lockScreen = m_userSessionManager->locked();
const bool desktopScreen = !lockScreen;

Expand Down Expand Up @@ -368,7 +370,7 @@ void NotificationManager::tryPlayNotificationSound(const NotifyEntity &entity, c

void NotificationManager::emitRecordCountChanged()
{
const auto count = m_persistence->fetchEntityCount(QLatin1String(), NotifyEntity::Processed);
const auto count = m_persistence->fetchEntityCount(DataAccessor::AllApp(), NotifyEntity::Processed);
emit RecordCountChanged(count);
}

Expand Down
Loading