From c072b0fbd8fd64c8c8a7aac68c42421feb95a680 Mon Sep 17 00:00:00 2001 From: keke <243768648@qq.com> Date: Thu, 15 Sep 2022 16:12:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=AF=E5=8A=A8=E5=99=A8=E4=B8=AD?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=8D=E8=83=BD=E8=AF=86=E5=88=AB=E5=9C=A8?= =?UTF-8?q?/usr/share/applications/=E4=B8=8B=E5=AD=98=E5=9C=A8=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAdesktop=E6=96=87=E4=BB=B6=E7=9A=84=E8=BD=AF=E4=BB=B6?= =?UTF-8?q?=E5=8C=85=EF=BC=88=E5=A6=82vscode=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/job/appmanagerjob.cpp | 22 +++++++++++++++------- src/job/appmanagerjob.h | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/job/appmanagerjob.cpp b/src/job/appmanagerjob.cpp index c1479ff..f7f22c9 100644 --- a/src/job/appmanagerjob.cpp +++ b/src/job/appmanagerjob.cpp @@ -804,9 +804,14 @@ void AppManagerJob::loadPkgInstalledAppInfo(const AM::PkgInfo &pkgInfo) // 获取安装文件路径列表 appInfo->installedPkgInfo.installedFileList = getAppInstalledFileList(appInfo->installedPkgInfo.pkgName); // 获取desktop - appInfo->desktopInfo.desktopPath = getAppDesktopPath(appInfo->installedPkgInfo.installedFileList, - appInfo->installedPkgInfo.pkgName); - appInfo->desktopInfo = getDesktopInfo(appInfo->desktopInfo.desktopPath); + QStringList desktopPathList = getAppDesktopPathList(appInfo->installedPkgInfo.installedFileList, + appInfo->installedPkgInfo.pkgName); + for (QStringList::const_iterator iter = desktopPathList.begin(); iter != desktopPathList.end(); ++iter) { + appInfo->desktopInfo = getDesktopInfo(*iter); + if (!appInfo->desktopInfo.desktopPath.isEmpty()) { + break; + } + } m_mutex.unlock(); // 解锁 } @@ -844,19 +849,22 @@ QStringList AppManagerJob::getAppInstalledFileList(const QString &pkgName) return fileList; } -QString AppManagerJob::getAppDesktopPath(const QStringList &list, const QString &pkgName) +QStringList AppManagerJob::getAppDesktopPathList(const QStringList &list, const QString &pkgName) { + QStringList desktopPathList; for (const QString &path : list) { if (path.startsWith("/usr/share/applications/") && path.endsWith(".desktop")) { - return path; + desktopPathList.append(path); + continue; } if (path.startsWith(QString("/opt/apps/%1/entries/applications/").arg(pkgName)) && path.endsWith(".desktop")) { - return path; + desktopPathList.append(path); + continue; } } - return {}; + return desktopPathList; } DesktopInfo AppManagerJob::getDesktopInfo(const QString &desktop) diff --git a/src/job/appmanagerjob.h b/src/job/appmanagerjob.h index 3c38e3a..4cbed2b 100644 --- a/src/job/appmanagerjob.h +++ b/src/job/appmanagerjob.h @@ -105,7 +105,7 @@ private: void loadAllPkgInstalledAppInfos(); QStringList getAppInstalledFileList(const QString &pkgName); - QString getAppDesktopPath(const QStringList &list, const QString &pkgName); + QStringList getAppDesktopPathList(const QStringList &list, const QString &pkgName); AM::DesktopInfo getDesktopInfo(const QString &desktop); qint64 getUrlFileSize(QString &url, int tryTimes = 3); -- Gitee