Skip to content

Commit 118177f

Browse files
committed
refactor(notification): move wayland guard into initScreenLockedState
1. Moved the Wayland platform check from the constructor into initScreenLockedState() 2. Replaced QGuiApplication::platformName() string comparison with DGuiApplicationHelper::testAttribute(IsWaylandPlatform) 3. Added TODO note for future Wayland session support in screen lock detection Log: Refactor Wayland session check into initScreenLockedState using Dtk API refactor(notification): 将 Wayland 检测移入 initScreenLockedState 1. 将 Wayland 平台检测从构造函数移入 initScreenLockedState() 方法 2. 使用 DGuiApplicationHelper::testAttribute(IsWaylandPlatform) 替代 QGuiApplication::platformName() 字符串比较 3. 添加 TODO 注释记录待 Wayland 支持屏幕锁检测 Log: 用 Dtk API 重构 Wayland 检测逻辑,移入 initScreenLockedState
1 parent ae3a27b commit 118177f

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

panels/notification/server/notificationmanager.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <QGuiApplication>
2626

2727
#include <appletbridge.h>
28+
#include <DGuiApplicationHelper>
2829
#include <pluginloader.h>
2930

3031
DCORE_USE_NAMESPACE
@@ -81,9 +82,7 @@ NotificationManager::NotificationManager(QObject *parent)
8182
if(!config->value("notificationCleanupDays").isNull()) {
8283
m_cleanupDays = config->value("notificationCleanupDays").toInt();
8384
}
84-
if (QStringLiteral("wayland") != QGuiApplication::platformName()) {
85-
initScreenLockedState();
86-
}
85+
initScreenLockedState();
8786
}
8887

8988
NotificationManager::~NotificationManager()
@@ -641,9 +640,20 @@ bool NotificationManager::invokeShellAction(const QString &data)
641640

642641
void NotificationManager::initScreenLockedState()
643642
{
643+
// TODO: un implement in wayland session
644+
if (Dtk::Gui::DGuiApplicationHelper::testAttribute(Dtk::Gui::DGuiApplicationHelper::IsWaylandPlatform)) {
645+
return;
646+
}
647+
644648
const QString interfaceAndServiceName = "org.deepin.dde.LockFront1";
645649
const QString path = "/org/deepin/dde/LockFront1";
646650

651+
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(interfaceAndServiceName)) {
652+
m_screenLocked = false;
653+
qWarning(notifyLog) << "LockFront1 service is not registered, skip init screen locked state.";
654+
return;
655+
}
656+
647657
QDBusInterface interface(interfaceAndServiceName, path,
648658
"org.freedesktop.DBus.Properties", QDBusConnection::sessionBus());
649659

0 commit comments

Comments
 (0)