Task 390571 add panel file manager dock plugin#3934
Conversation
Implement a new dde-shell dock panel plugin that provides file browsing capabilities directly from the dock panel, featuring directory navigation, icon view modes and color theme support. 新增dde-shell任务栏文件管理面板插件,支持目录浏览、图标视图 模式切换和颜色主题配置。 Log: 新增任务栏文件管理面板插件 PMS: TASK-390571 Influence: 用户可以从任务栏面板直接浏览文件目录,提升文件访问效率。
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos 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 |
|
Warning
|
|
Note
详情{
"debian/control": [
{
"line": "Homepage: http://www.deepin.org",
"line_number": 59,
"rule": "S35",
"reason": "Url link | 6fe814dfb7"
}
]
} |
Implement a new dde-shell dock panel plugin (org.deepin.ds.filemanager) that provides file browsing capabilities directly from the taskbar dock panel. The plugin displays real file thumbnails in a 2x2 grid on the dock icon and a popup file browser with thumbnail previews. Changes: - Add PinnedItemIcon and TaskIcon QML components for dock icon rendering - Integrate DThumbnailProvider for async file thumbnail generation - Replace Canvas 2D hand-drawn icons with real file icon previews - Add OpacityMask rounded-corner thumbnail rendering in popup views - Add DirectoryModel with thumbnailUrl role and async refresh signal - Add previewIconNames property for dock icon composite preview - Remove colorTheme/gridCount properties and right-click color menu - Package as separate deb: dde-file-manager-dock-plugin 新增dde-shell任务栏文件管理面板插件,支持从任务栏直接浏览文件目录, 显示真实文件缩略图预览,提供网格/列表视图切换功能。 Log: 新增任务栏文件管理面板插件 PMS: TASK-390571 Influence: 用户可以从任务栏面板直接浏览文件目录,提升文件访问效率。
912c17f to
9f15254
Compare
|
Warning
|
|
Note
详情{
"debian/control": [
{
"line": "Homepage: http://www.deepin.org",
"line_number": 59,
"rule": "S35",
"reason": "Url link | 6fe814dfb7"
}
]
} |
deepin pr auto review★ 总体评分:55分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // filemanagerplugin.cpp - 修复 openFile 函数
void FileManagerPlugin::openFile(const QString &filePath)
{
QFileInfo fileInfo(filePath);
if (!fileInfo.exists() || !fileInfo.isReadable()) {
qCWarning(fileManagerPluginLog) << "File does not exist or not readable:" << filePath;
return;
}
if (filePath.endsWith(QLatin1String(".desktop"), Qt::CaseInsensitive)) {
// 安全检查:验证 .desktop 文件是否位于可信应用目录
static const QStringList trustedPaths = {
QStringLiteral("/usr/share/applications/"),
QStringLiteral("/usr/local/share/applications/"),
QDir::homePath() + QStringLiteral("/.local/share/applications/")
};
const QString canonicalPath = fileInfo.canonicalFilePath();
bool isTrusted = false;
for (const auto &trustedPath : trustedPaths) {
if (canonicalPath.startsWith(trustedPath)) {
isTrusted = true;
break;
}
}
if (!isTrusted) {
qCWarning(fileManagerPluginLog) << "Refusing to launch untrusted .desktop file:" << canonicalPath;
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
return;
}
QString appId = fileInfo.completeBaseName();
// 转义 DBus 对象路径中的非法字符(. -> _2e, - -> _2d)
QString escapedAppId = appId;
escapedAppId.replace(QLatin1Char('.'), QLatin1String("_2e"));
escapedAppId.replace(QLatin1Char('-'), QLatin1String("_2d"));
QString objectPath = QStringLiteral("/org/desktopspec/ApplicationManager1/%1")
.arg(escapedAppId);
QDBusInterface iface(
QStringLiteral("org.desktopspec.ApplicationManager1"),
objectPath,
QStringLiteral("org.desktopspec.ApplicationManager1.Application"),
QDBusConnection::sessionBus());
if (iface.isValid()) {
QVariantMap options {
{ QStringLiteral("_launch_type"), QStringLiteral("dde-file-manager") }
};
QDBusReply<void> reply = iface.call(QStringLiteral("Launch"),
filePath,
QStringList(),
options);
if (reply.isValid())
return;
qCWarning(fileManagerPluginLog) << "AM1 Launch failed:" << reply.error().message()
<< "falling back to openUrl";
}
}
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}
// filemanagerplugin.h - 添加 URL 解析方法
// 在 public 部分添加:
Q_INVOKABLE QString urlToLocalPath(const QString &urlString) const;
// filemanagerplugin.cpp - 实现 URL 解析
QString FileManagerPlugin::urlToLocalPath(const QString &urlString) const
{
QUrl url(urlString);
if (url.isLocalFile())
return url.toLocalFile();
return urlString;
}
// directorymodel.h - 修复 Entry 结构体初始化
struct Entry {
QString name;
QString path;
QString iconName;
QString iconUrl;
bool isDir = false; // 添加默认初始化
FileType fileType = GenericFile;
QString thumbnailUrl;
};
// directorymodel.cpp - 添加 iconToDataUrl 缓存
QString DirectoryModel::iconToDataUrl(const QString &iconName, int size)
{
static QHash<QString, QString> cache;
const QString cacheKey = QStringLiteral("%1_%2").arg(iconName).arg(size);
auto it = cache.constFind(cacheKey);
if (it != cache.constEnd())
return it.value();
QIcon icon;
if (iconName.startsWith(QLatin1Char('/')))
icon = QIcon(iconName);
if (icon.isNull())
icon = QIcon::fromTheme(iconName);
if (icon.isNull())
icon = QIcon::fromTheme(QStringLiteral("text-x-generic"));
if (icon.isNull()) {
cache.insert(cacheKey, QString());
return QString();
}
QPixmap pm = icon.pixmap(size, size);
if (pm.isNull()) {
cache.insert(cacheKey, QString());
return QString();
}
QByteArray ba;
QBuffer buf(&ba);
buf.open(QIODevice::WriteOnly);
pm.save(&buf, "PNG");
QString result = QStringLiteral("data:image/png;base64,") + ba.toBase64();
cache.insert(cacheKey, result);
return result;
}// filemanager.qml - 修复 onDropped 中的 URL 解析
onDropped: function (drop) {
dragHovering = false
if (drop.urls.length === 0)
return
// 使用 C++ 端的 QUrl::toLocalFile 正确解析路径
var localPath = Applet.urlToLocalPath(drop.urls[0].toString())
if (!localPath)
return
if (Applet.isDirectory(localPath) || Applet.isFile(localPath)) {
var dir = Applet.isDirectory(localPath) ? localPath
: localPath.substring(0, localPath.lastIndexOf("/"))
if (dir)
Applet.navigateTo(dir)
}
drop.accepted = true
} |
|
@add-uos: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
| Package: dde-file-manager-dock-plugin | ||
| Architecture: any |
| usr/share/applications/dde-computer.desktop | ||
| usr/share/applications/dde-trash.desktop | ||
| usr/share/applications/dde-home.desktop | ||
| usr/share/dde-shell/*/*.json |
There was a problem hiding this comment.
桌面插件org.deepin.ds.desktop.so匹配不了吧
No description provided.