Repository navigation
Conversation
When the viewer is already running, the D-Bus openImageFile call only loaded the image without raising or focusing the existing window. Now the running instance activates the main window (restores it from minimized, raises, requests focus) before loading the image, so the window pops up on top and focused. 已运行实例通过 D-Bus openImageFile 打开图片时仅加载图片,不会还原、 置顶或聚焦已有窗口。现在先激活主窗口(最小化则还原,再置顶并请求 焦点)再加载图片,保证窗口置顶弹出。 Log: D-Bus 调用 openImageFile 打开图片时激活主窗口
Reviewer's GuideThe PR backports the D-Bus window-activation fix by adding centralized Qt window restoration/focus behavior and invoking it only for successfully validated image-open requests, preserving window state and avoiding minimize/WM focus races. Sequence diagram for D-Bus image opening and window activationsequenceDiagram
participant Caller as D-Bus caller
participant Adaptor as ApplicationAdaptor
participant Control as FileControl
participant Window as MainWindow
participant EventLoop as Qt event loop
Caller->>Adaptor: openImageFile(fileName)
Adaptor->>Control: isCanReadable(urlPath)
Adaptor->>Control: isImage(urlPath)
alt image is valid
Adaptor->>Control: activateMainWindow()
alt window is minimized
Control->>Window: setWindowStates(states without WindowMinimized)
Control->>EventLoop: QTimer::singleShot(0)
EventLoop->>Window: raise()
EventLoop->>Window: requestActivate()
else window is not minimized
Control->>Window: raise()
Control->>Window: requestActivate()
end
Adaptor-->>Control: openImageFile(urlPath)
Adaptor-->>Caller: true
else image is invalid
Adaptor-->>Caller: false
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议将 raise()+requestActivate() 提取为私有辅助方法或在分支后统一调用, 减少代码重复。', '建议在窗口类型过滤中补充 Qt::ToolTip、Qt::SplashScreen 等排除条件, 使 activateMainWindow() 在多窗口场景下更健壮。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 建议改进:补充窗口类型过滤并提取公共激活逻辑 void FileControl::activateMainWindow() {
qCDebug(logImageViewer) << "FileControl::activateMainWindow() called.";
const QList<QWindow *> windows = QGuiApplication::topLevelWindows();
for (QWindow *win : windows) {
if (!win || !win->isVisible() ||
win->type() == Qt::Popup ||
win->type() == Qt::ToolTip ||
win->type() == Qt::SplashScreen) {
continue;
}
auto doActivate = [win]() {
win->raise();
win->requestActivate();
};
const Qt::WindowStates states = win->windowStates();
if (states & Qt::WindowMinimized) {
win->setWindowStates(states & ~Qt::WindowMinimized);
QTimer::singleShot(0, win, doActivate);
} else {
doActivate();
}
break;
}
}本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.0.61 |
说明
master 分支修复 PR #417 的 backport,pick 到 release/snipe(基于 39b1669)。
仅包含代码修改(3 个 src 文件,+34 行),不含单元测试(release/snipe 分支无对应测试文件)。改动内容与 #417 一致:
问题 / Problem
应用已运行时(D-Bus 服务
com.deepin.imageViewer已注册),外部通过 D-Bus 调用openImageFile打开图片:图片正常加载,但已有窗口不会还原/置顶/聚焦。修复 / Fix
FileControl新增Q_INVOKABLE activateMainWindow():取第一个可见顶层窗口(排除 Popup);最小化时仅清除WindowMinimized还原(保留最大化/全屏形态),raise()+requestActivate()推迟到下一轮事件循环避免与 WM 竞态;非最小化立即置顶+请求焦点。Wayland 下 xdg-activation 令牌限制已在代码注释说明。ApplicationAdaptor::openImageFile成功分支在 emit 前调用激活;校验不通过分支不激活。验证
openImageFile→ 3/3 轮窗口还原且激活;窗口后台 → 置顶并聚焦;首次启动无回归。详见 fix: activate main window on D-Bus openImageFile #417。Summary by Sourcery
Bug Fixes: