Repository navigation
feat: add systemd service for login wallpaper change - #27
Conversation
Reviewer's GuideThis PR integrates a systemd-based service and D-Bus method to trigger login wallpaper changes, refactors the changeBgAfterLogin logic to remove manual session tracking in favor of JSON-based iteration across monitors, and updates CMake rules to install the new service files. Class diagram for WallpaperSlideshow and SlideshowManager changesclassDiagram
class WallpaperSlideshow {
+void SetWallpaperSlideShow(QString monitorName, QString slideShow)
+QString GetWallpaperSlideShow(QString monitorName)
+void requestChangeWallpaper(QString condition)
+void onPropertyChanged(QString name, QVariant value)
-SlideshowManager* m_manager
}
class SlideshowManager {
+void setMonitorBackground(QString monitorName, QString imageGile)
+void handlePrepareForSleep(bool sleep)
+void changeBgAfterLogin()
-void autoChangeBg(QString monitorSpace, QDateTime time)
-QString m_wallpaperSlideShow
}
WallpaperSlideshow --> SlideshowManager
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review我来审查这段代码变更,从语法逻辑、代码质量、性能和安全性几个方面进行分析: 语法逻辑
代码质量
性能
安全性
建议改进
void WallpaperSlideshow::requestChangeWallpaper(const QString &condition)
{
// 验证输入参数
if (condition.isEmpty()) {
qWarning() << "Empty condition received";
return;
}
if (condition == WSPOLICYLOGIN) {
m_manager->changeBgAfterLogin();
} else {
qWarning() << "Unknown condition:" << condition;
// 可以考虑在这里扩展支持其他条件
}
}
void SlideshowManager::changeBgAfterLogin()
{
qInfo() << "changeBgAfterLogin";
// 缓存解析结果
static QJsonDocument cachedDoc;
static QHash<QString, QString> cachedConfig;
if (cachedDoc.isNull()) {
cachedDoc = QJsonDocument::fromJson(m_wallpaperSlideShow.toLatin1());
cachedConfig = cachedDoc.object().toVariantMap();
}
for (auto it = cachedConfig.begin(); it != cachedConfig.end(); ++it) {
if (it.value().toString() == WSPOLICYLOGIN)
autoChangeBg(it.key(), QDateTime::currentDateTimeUtc());
}
}
总体来说,这次代码变更改进了代码的简洁性和性能,移除了不必要的文件操作,改用更现代的D-Bus通信方式。但在安全性和错误处理方面还有提升空间。 |
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/plugin-qt/wallpaperslideshow/slideshowmanager.cpp:252-253` </location>
<code_context>
- }
- }
+ qInfo() << "changeBgAfterLogin";
+ QJsonDocument doc = QJsonDocument::fromJson(m_wallpaperSlideShow.toLatin1());
+ QVariantMap tempMap = doc.object().toVariantMap();
- if (needChangeBg) {
</code_context>
<issue_to_address>
**issue (bug_risk):** No error handling for invalid JSON in m_wallpaperSlideShow.
Add a validity check for QJsonDocument and log a warning if parsing fails to improve reliability and aid debugging.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull Request Overview
Adds systemd service integration for automated wallpaper changes on user login, replacing manual session tracking with D-Bus method calls triggered by systemd services.
- Introduces
requestChangeWallpaperD-Bus method to handle login-triggered wallpaper changes - Replaces manual
/proc/self/sessionidtracking with systemd-based activation for improved reliability - Simplifies login wallpaper logic to iterate through all monitors with login policy
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| wallpaperslideshow.h | Adds new D-Bus method declaration for wallpaper change requests |
| wallpaperslideshow.cpp | Implements requestChangeWallpaper method to trigger login wallpaper changes |
| slideshowmanager.h | Changes changeBgAfterLogin signature from returning bool to void |
| slideshowmanager.cpp | Replaces session file tracking with simplified monitor iteration logic |
| org.deepin.dde.WallpaperSlideshow.xml | Adds D-Bus interface definition for new requestChangeWallpaper method |
| dde-postlogin-wallpaper.service (symlink) | Creates systemd service symlink for target integration |
| dde-postlogin-wallpaper.service | Defines systemd user service to call D-Bus method on login |
| org.deepin.dde.WallpaperSlideshow.service | Adds D-Bus service file for automatic service activation |
| CMakeLists.txt | Adds installation rules for D-Bus and systemd service files |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
1. Replace reading session ID from /proc/self/sessionid with D-Bus call to org.deepin.dde.SessionManager1.GetSessionPath 2. Improve file handling by using QFileInfo and ensuring directory creation 3. Enhance session tracking by comparing D-Bus session paths instead of session IDs 4. Add proper error handling for D-Bus calls and file operations 5. Use QIODevice::ReadWrite mode for better file management The changes provide more reliable session detection using D-Bus services and improve the robustness of wallpaper slideshow management during login sessions. refactor: 使用 D-Bus 会话路径替换会话 ID 进行登录检测 1. 将读取 /proc/self/sessionid 替换为调用 org.deepin.dde.SessionManager1.GetSessionPath 的 D-Bus 方法 2. 使用 QFileInfo 改进文件处理并确保目录创建 3. 通过比较 D-Bus 会话路径而非会话 ID 来增强会话跟踪 4. 为 D-Bus 调用和文件操作添加适当的错误处理 5. 使用 QIODevice::ReadWrite 模式改进文件管理 这些更改通过使用 D-Bus 服务提供了更可靠的会话检测,并提高了登录会话期间 壁纸幻灯片管理的鲁棒性。 pms: BUG-333159
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
feat: 添加登录壁纸更改的 systemd 服务
pms: BUG-333159
Summary by Sourcery
Enable automated wallpaper slideshow changes on user login by adding D-Bus and systemd user services, removing manual session tracking, and refactoring the login-triggered background change logic.
New Features:
Enhancements:
Build: