From 9a2f1699f971d5e76d4906fb558865aefc98e8fd Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Tue, 27 Oct 2026 19:04:27 +0800 Subject: [PATCH] fix(thumbnail): pass file URL when opening snapshot via DBus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass file:// URL to imageViewer/movie DBus interface instead of a bare path, because image viewer matches the file against a URL list. Fall back to command-line launch when imageViewer returns false. 通过DBus打开缩略图文件时传file://形式的URL而非裸路径, 看图内部按URL列表匹配文件;看图返回false时回退命令行启动。 Log: 修复相机缩略图打开图片时看图不显示图片的问题 PMS: BUG-381089 Influence: 相机右下角缩略图打开图片可正常显示,视频打开不受影响 --- src/src/imageitem.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/src/imageitem.cpp b/src/src/imageitem.cpp index 0630d07e..daf4653f 100644 --- a/src/src/imageitem.cpp +++ b/src/src/imageitem.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -27,6 +27,7 @@ #include #include #include +#include #include extern "C" { @@ -417,11 +418,16 @@ void ImageItem::openFile() //用看图打开 QDBusMessage message = QDBusMessage::createMethodCall("com.deepin.imageViewer", "/", "com.deepin.imageViewer", "openImageFile"); - message << filePath; + //看图内部按 URL 列表匹配文件,需传 file:// 形式路径 + message << QUrl::fromLocalFile(filePath).toString(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(message), this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, openWithBackup]() { const QDBusMessage retMessage = watcher->reply(); + bool ok = false; if (retMessage.type() != QDBusMessage::ErrorMessage) { + ok = retMessage.arguments().value(0).toBool(); + } + if (ok) { qDebug() << "Successfully opened image with deepin-image-viewer via DBus"; } else { qWarning() << "Failed to open image with deepin-image-viewer via DBus:" << retMessage.errorMessage(); @@ -442,7 +448,8 @@ void ImageItem::openFile() ret = myProcess->startDetached(program, arguments); #else QDBusMessage message = QDBusMessage::createMethodCall("com.deepin.movie", "/", "com.deepin.movie", "openFile"); - message << filePath; + //与图片分支保持一致,传 file:// 形式路径 + message << QUrl::fromLocalFile(filePath).toString(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(message), this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, openWithBackup]() { const QDBusMessage retMessage = watcher->reply();