From 3f7c41cee444f40e4c6f6800df9e65d61363909f Mon Sep 17 00:00:00 2001 From: keke <243768648@qq.com> Date: Wed, 27 Sep 2023 21:17:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=93=E5=BC=80=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=AE=9A=E4=BD=8D=E5=88=B0=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appmanagermodel.cpp | 18 ++++++++++++++++++ src/appmanagermodel.h | 7 +++++++ src/common/appmanagercommon.h | 4 ++++ src/dlg/pkgdownloaddlg.cpp | 10 +++++++++- src/job/appmanagerjob.cpp | 2 +- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/appmanagermodel.cpp b/src/appmanagermodel.cpp index ff6e6ab..e3d6cb2 100644 --- a/src/appmanagermodel.cpp +++ b/src/appmanagermodel.cpp @@ -224,6 +224,24 @@ void AppManagerModel::startDetachedDesktopExec(const QString &exec) proc.close(); } +void AppManagerModel::showFileItemInFileManager(const QString &urlPath) +{ + if (DSysInfo::isDeepin()) { + QProcess proc; + proc.startDetached("dde-file-manager", {"-n", "--show-item", urlPath}); + proc.close(); + return; + } + + QDBusInterface dbusIface("org.freedesktop.FileManager1" + , "/org/freedesktop/FileManager1" + , "org.freedesktop.FileManager1" + , QDBusConnection::sessionBus()); + if (dbusIface.isValid()) { + dbusIface.call("ShowItems", QStringList{urlPath}, ""); + } +} + void AppManagerModel::onAppInstalled(const AppInfo &appInfo) { popupNormalSysNotify("ccc-app-manager", QString("软件包 %1 已安装").arg(appInfo.pkgName)); diff --git a/src/appmanagermodel.h b/src/appmanagermodel.h index f5e55e0..f10949d 100644 --- a/src/appmanagermodel.h +++ b/src/appmanagermodel.h @@ -3,8 +3,13 @@ #include "common/appmanagercommon.h" #include "job/appmanagerjob.h" +#include + #include #include +#include + +DCORE_USE_NAMESPACE class QStandardItemModel; @@ -38,6 +43,8 @@ public: // 运行desktop执行命令 void startDetachedDesktopExec(const QString &exec); + void showFileItemInFileManager(const QString &urlPath); + Q_SIGNALS: void runningStatusChanged(RunningStatus status); diff --git a/src/common/appmanagercommon.h b/src/common/appmanagercommon.h index eb6b495..7caa491 100644 --- a/src/common/appmanagercommon.h +++ b/src/common/appmanagercommon.h @@ -3,6 +3,7 @@ #include #include +#include #define ONLY_SHOW_IN_VALUE_DEEPIN "Deepin" #define X_DEEPIN_VENDOR_STR "deepin" @@ -27,6 +28,9 @@ // 时间格式化字符串 #define DATE_TIME_FORMAT_STR "yyyy-MM-dd HH:mm:ss.zzz" +// 包名格式化字符串 +#define PKG_NAME_FORMAT_STR "%1_%2_%3.deb" + namespace AM { // 运行状态 enum RunningStatus { diff --git a/src/dlg/pkgdownloaddlg.cpp b/src/dlg/pkgdownloaddlg.cpp index 681e8fb..6243b50 100644 --- a/src/dlg/pkgdownloaddlg.cpp +++ b/src/dlg/pkgdownloaddlg.cpp @@ -231,7 +231,15 @@ void PkgDownloadDlg::initConnection() // 打开目录 connect(m_openDirBtn, &QPushButton::clicked, this, [this](bool) { - QDesktopServices::openUrl(m_model->getDownloadDirPath()); + QString fileName = QString(PKG_NAME_FORMAT_STR) + .arg(m_selectedPkgInfo.pkgName) + .arg(m_selectedPkgInfo.version) + .arg(m_selectedPkgInfo.arch); + + QString path = QString("%1/%2") + .arg(m_model->getDownloadDirPath()) + .arg(fileName); + m_model->showFileItemInFileManager(path); }); connect(m_model, &AppManagerModel::pkgFileDownloadProgressChanged, this, &PkgDownloadDlg::onFileDownloadProgressChanged); diff --git a/src/job/appmanagerjob.cpp b/src/job/appmanagerjob.cpp index 79a4e7b..7e95fce 100644 --- a/src/job/appmanagerjob.cpp +++ b/src/job/appmanagerjob.cpp @@ -378,7 +378,7 @@ void AppManagerJob::downloadFile(const QString &url) qint64 endOffset = fileSize; // 创建下载路径 - QString fileName = QString("%1_%2_%3.deb") + QString fileName = QString(PKG_NAME_FORMAT_STR) .arg(m_downloadingPkgInfo.pkgName) .arg(m_downloadingPkgInfo.version) .arg(m_downloadingPkgInfo.arch); -- Gitee