fix: 玲珑应用功能适配

v23环境下,玲珑应用和普通应用的desktop文件名相同, 两种类型的应用都安装的情况下只显示一个.
修复方案: 删除去重处理, 补充desktop全路径校验

Log:
Influence: 启动器-应用列表中可以获取到所有应用
Task: https://pms.uniontech.com/task-view-152805.html
Change-Id: I9eeed5e87de2cbaf7e44d75f81c40f00af344b6a
This commit is contained in:
songwentao 2022-07-22 15:17:43 +08:00
parent 20a2642e74
commit 2f7f467857
5 changed files with 14 additions and 25 deletions

View File

@ -22,7 +22,7 @@
bool LauncherItemInfo::operator!=(const LauncherItemInfo &itemInfo)
{
return itemInfo.id != id;
return itemInfo.path != path;
}
QDBusArgument &operator<<(QDBusArgument &argument, const LauncherItemInfo &itemInfo)

View File

@ -371,7 +371,6 @@ std::map<std::string, bool> AppsDir::getAppNames()
// 获取所有应用信息
std::vector<DesktopInfo> AppsDir::getAllDesktopInfos()
{
std::map<std::string, bool> recoder;
std::vector<DesktopInfo> desktopInfos;
for (auto dir : BaseDir::appDirs()) {
@ -381,19 +380,13 @@ std::vector<DesktopInfo> AppsDir::getAllDesktopInfos()
continue;
for (const auto &iter : appNames) {
if (recoder.find(iter.first) != recoder.end())
continue;
std::string filePath = dir + iter.first;
DesktopInfo desktopInfo(filePath);
if (!desktopInfo.isValidDesktop())
if (!DFile::isExisted(filePath) || !desktopInfo.isValidDesktop() || !desktopInfo.shouldShow())
continue;
if (!desktopInfo.shouldShow())
continue;
desktopInfos.push_back(std::move(desktopInfo));
recoder[iter.first] = true;
desktopInfos.push_back(desktopInfo);
}
}

View File

@ -140,11 +140,11 @@ void Launcher::setFullscreen(bool isFull)
*/
LauncherItemInfoList Launcher::getAllItemInfos()
{
LauncherItemInfoList ret;
for (auto item : itemsMap) {
ret.push_back(item.info);
}
return ret;
LauncherItemInfoList allItemList;
for (auto item : m_desktopAndItemMap)
allItemList.push_back(item.info);
return allItemList;
}
/**
@ -686,6 +686,7 @@ void Launcher::addItem(Item item)
item.info.categoryId = qint64(queryCategoryId(&item));
itemsMap[item.info.id] = item;
m_desktopAndItemMap[item.info.path] = item;
}
Categorytype Launcher::queryCategoryId(const Item *item)
@ -967,8 +968,6 @@ bool Launcher::doUninstall(DesktopInfo &info, const Item &item)
case (AppType::Default):
ret = removeDesktop(item);
break;
default:
break;
}
return ret;

View File

@ -147,14 +147,16 @@ private:
void notifyUninstallDone(const Item &item, bool result);
private:
QMap<QString, Item> itemsMap; // appKey, Item
QMap<QString, Item> itemsMap; // appId, Item
QMap<QString, QString> desktopPkgMap;
QMap<QString, Categorytype> pkgCategoryMap;
QMap<QString, QString> nameMap;
QMap<QString, QString> nameMap; // appId, Name
QMap<QString, int> noPkgItemIds;
QVector<QString> appsHidden;
QStringList appDirs;
QMap<QString, Item> m_desktopAndItemMap; // desktoppath,Item
};
#endif // LAUNCHER_H

View File

@ -96,11 +96,6 @@ int main(int argc, char *argv[])
QDBusConnection::sessionBus().registerObject(app->path().path(), "org.desktopspec.Application", app.get());
}
for (const QSharedPointer<Application> &app : apps) {
qInfo() << "appId - " << app->id();
qInfo() << "appFilePath - " << app->filePath();
}
ApplicationManager::instance()->addApplication(apps);
ApplicationManager::instance()->launchAutostartApps();