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
1 change: 0 additions & 1 deletion panels/notification/center/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ qt_add_qml_module(notificationcenterpanel
NotifySettingMenu.qml
AnimationSettingButton.qml
BoundingRectangle.qml
DataPanel.qml
NotifyHeaderTitleText.qml
SOURCES
notificationcenterpanel.h
Expand Down
63 changes: 0 additions & 63 deletions panels/notification/center/DataPanel.qml

This file was deleted.

28 changes: 0 additions & 28 deletions panels/notification/center/NotifyHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,6 @@ FocusScope {
id: root

required property NotifyModel notifyModel
signal headerClicked()

// test
onHeaderClicked: function () {
dataPanelLoader.active = !dataPanelLoader.active
NotifyAccessor.fetchDataInfo()
dataPanelLoader.item.show()
}
Loader {
id: dataPanelLoader
active: false
sourceComponent: Window {
id: dataPanel
width: 360
height: 600
x: dataPanel.transientParent.x + root.Window.width + 10
y: dataPanel.transientParent.y
DataPanel {
notifyModel: root.notifyModel
}
}
}

RowLayout {
anchors.fill: parent
Expand All @@ -43,12 +21,6 @@ FocusScope {
Layout.alignment: Qt.AlignLeft
Layout.leftMargin: 18
tFont: DTK.fontManager.t4
MouseArea {
anchors.fill: parent
onDoubleClicked: {
root.headerClicked()
}
}
}

Item {
Expand Down
6 changes: 1 addition & 5 deletions panels/notification/center/notificationcenterpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ bool NotificationCenterPanel::init()
Qt::QueuedConnection);
notifycenter::NotifyAccessor::instance()->setDataUpdater(server);
notifycenter::NotifyAccessor::instance()->setEnabled(visible());
} else {
// old interface by dbus
auto connection = QDBusConnection::sessionBus();
valid = connection.connect(DDENotifyDBusServer, DDENotifyDBusPath, DDENotifyDBusInterface,
"RecordAdded", this, SLOT(onReceivedRecord(const QString &)));
}
if (!valid) {
qWarning(notifyLog) << "NotifyConnection is invalid, and can't receive RecordAdded signal.";
return false;
}

return true;
Expand Down
58 changes: 3 additions & 55 deletions panels/notification/center/notifyaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,35 +139,21 @@ QStringList NotifyAccessor::fetchApps(int maxCount) const
void NotifyAccessor::removeEntity(qint64 id)
{
qDebug(notifyLog) << "Remove notify" << id;
if (m_dataUpdater) {
QMetaObject::invokeMethod(m_dataUpdater, "removeNotification", Qt::DirectConnection,
Q_ARG(qint64, id));
} else {
m_accessor->removeEntity(id);
}
QMetaObject::invokeMethod(m_dataUpdater, "removeNotification", Qt::DirectConnection, Q_ARG(qint64, id));
}

void NotifyAccessor::removeEntityByApp(const QString &appName)
{
qDebug(notifyLog) << "Remove notifies for the application" << appName;

if (m_dataUpdater) {
QMetaObject::invokeMethod(m_dataUpdater, "removeNotifications", Qt::DirectConnection,
Q_ARG(const QString &, appName));
} else {
m_accessor->removeEntityByApp(appName);
}
QMetaObject::invokeMethod(m_dataUpdater, "removeNotifications", Qt::DirectConnection, Q_ARG(const QString &, appName));
}

void NotifyAccessor::clear()
{
qDebug(notifyLog) << "Remove all notify";

if (m_dataUpdater) {
QMetaObject::invokeMethod(m_dataUpdater, "removeNotifications", Qt::DirectConnection);
} else {
m_accessor->clear();
}
QMetaObject::invokeMethod(m_dataUpdater, "removeNotifications", Qt::DirectConnection);
}

void NotifyAccessor::closeNotify(const NotifyEntity &entity, NotifyEntity::ClosedReason reason)
Expand Down Expand Up @@ -240,34 +226,6 @@ void NotifyAccessor::openNotificationSetting()
}
}

void NotifyAccessor::addNotify(const QString &appName, const QString &content)
{
qDebug(notifyLog) << "Add notify" << appName;
static int id = 10000;
NotifyEntity entity(id++, appName);
entity.setBody(content);
m_accessor->addEntity(entity);

if (auto entity = fetchLastEntity(appName); entity.isValid()) {
entityReceived(entity.id());
}
}

void NotifyAccessor::fetchDataInfo()
{
QStringList info;
auto entityCount = fetchEntityCount(DataAccessor::AllApp());
auto apps = fetchApps();
info.append(QString("notifyCount: %1, appCount: %2").arg(entityCount).arg(apps.size()));
for (auto item : apps) {
info.append(QString("%1 -> %2").arg(item).arg(fetchEntityCount(item)));
}
QString ret = info.join("\n");
m_dataInfo = ret;
dataInfoChanged();
appsChanged();
}

void NotifyAccessor::onNotificationStateChanged(qint64 id, int processedType)
{
if (!enabled())
Expand All @@ -285,16 +243,6 @@ void NotifyAccessor::onReceivedRecord(const QString &id)
emit entityReceived(id.toLongLong());
}

QString NotifyAccessor::dataInfo() const
{
return m_dataInfo;
}

QStringList NotifyAccessor::apps() const
{
return m_apps;
}

bool NotifyAccessor::debugging() const
{
return m_debugging;
Expand Down
13 changes: 0 additions & 13 deletions panels/notification/center/notifyaccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(QString dataInfo READ dataInfo NOTIFY dataInfoChanged FINAL)
Q_PROPERTY(QStringList apps READ apps NOTIFY appsChanged FINAL)
Q_PROPERTY(bool debugging READ debugging NOTIFY debuggingChanged)
public:
static NotifyAccessor *instance();
Expand Down Expand Up @@ -60,33 +58,22 @@
void stagingEntityReceived(qint64 id);
void stagingEntityClosed(qint64 id);

public slots:
void addNotify(const QString &appName, const QString &content);
void fetchDataInfo();

signals:
void dataInfoChanged();
void appsChanged();
void debuggingChanged();

private slots:

Check warning on line 63 in panels/notification/center/notifyaccessor.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If slots is a macro then please configure it.
void onNotificationStateChanged(qint64 id, int processedType);
void onReceivedRecord(const QString &id);

private:
explicit NotifyAccessor(QObject *parent = nullptr);

QString dataInfo() const;
QStringList apps() const;
bool debugging() const;

private:
DataAccessor *m_accessor = nullptr;
QObject *m_dataUpdater = nullptr;
QStringList m_pinnedApps;
QStringList m_apps;
bool m_debugging = false;
QString m_dataInfo;
bool m_enabled = false;
};
}
6 changes: 5 additions & 1 deletion panels/notification/common/dbaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ bool DBAccessor::open(const QString &dataPath)
bool DBAccessor::isValid() const
{
QMutexLocker locker(&m_mutex);
return !m_connection.lastError().isValid();
if (m_connection.lastError().isValid()) {
qWarning(notifyLog) << "Database error" << m_connection.lastError().text();
return false;
}
return true;
}

qint64 DBAccessor::addEntity(const NotifyEntity &entity)
Expand Down
12 changes: 3 additions & 9 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,9 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
const QString &body, const QStringList &actions, const QVariantMap &hints,
int expireTimeout)
{
qDebug(notifyLog) << "Notify"
<< ", appName:" << appName
<< ", summary:" << summary
<< ", appIcon:" << appIcon
<< ", body size:" << body.size()
<< ", actions:" << actions
<< ", hint: " << hints
<< ", replaceId:" << replacesId
<< ", expireTimeout:" << expireTimeout;
qInfo(notifyLog) << "Notify"
<< ", appName:" << appName << ", summary:" << summary << ", appIcon:" << appIcon << ", body size:" << body.size()
<< ", actions:" << actions << ", hint: " << hints << ", replaceId:" << replacesId << ", expireTimeout:" << expireTimeout;

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