fix: 修复新装应用没有排列在首位的问题
问题背景: 本地存在deb包格式应用A或者存在linglong包格式应用A时,新装应用没有排列在小窗口-所有应用列表-首位的问题 修改思路: 遍历时使用desktop全路径作为键值对的key,而不是用二进制的应用名称 Log: Influence: 启动器-新装应用-在小窗口所有应用列表中排列在首位 Bug: https://pms.uniontech.com/bug-view-150623.html Change-Id: I29a2c9d0c68f0fcf65e864c2048515e12009341f
This commit is contained in:
parent
288f7ab65f
commit
e70b17eea1
@ -531,42 +531,40 @@ void Launcher::onCheckDesktopFile(const QString &filePath, int type)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(type);
|
Q_UNUSED(type);
|
||||||
|
|
||||||
QString appId = getAppIdByFilePath(filePath, appDirs);
|
if (filePath.isEmpty()) {
|
||||||
if (appId.isEmpty())
|
qWarning() << "Desktop path is empty. ";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DesktopInfo info(filePath.toStdString());
|
DesktopInfo info(filePath.toStdString());
|
||||||
if (info.isValidDesktop()) {
|
if (info.isValidDesktop()) {
|
||||||
Item newItem = NewItemWithDesktopInfo(info);
|
Item newItem = NewItemWithDesktopInfo(info);
|
||||||
newItem.info.id = getAppIdByFilePath(newItem.info.path, appDirs);
|
|
||||||
bool shouldShow = info.shouldShow() &&
|
bool shouldShow = info.shouldShow() &&
|
||||||
!isDeepinCustomDesktopFile(newItem.info.path) &&
|
!isDeepinCustomDesktopFile(newItem.info.path) &&
|
||||||
!appsHidden.contains(newItem.info.id);
|
!appsHidden.contains(newItem.info.id);
|
||||||
|
|
||||||
// update item
|
if (m_desktopAndItemMap.find(filePath) != m_desktopAndItemMap.end()) {
|
||||||
if (itemsMap.find(appId) != itemsMap.end()) {
|
|
||||||
if (shouldShow) {
|
if (shouldShow) {
|
||||||
|
// update item
|
||||||
addItem(newItem);
|
addItem(newItem);
|
||||||
emitItemChanged(&newItem, appStatusModified);
|
emitItemChanged(&newItem, appStatusModified);
|
||||||
} else {
|
} else {
|
||||||
itemsMap.remove(appId);
|
// hide item
|
||||||
emitItemChanged(&newItem, appStatusDeleted);
|
emitItemChanged(&newItem, appStatusDeleted);
|
||||||
}
|
}
|
||||||
} else if (shouldShow){ // add item
|
} else if (shouldShow) {
|
||||||
if (info.isExecutableOk()) {
|
if (info.isExecutableOk()) {
|
||||||
|
// add item
|
||||||
addItem(newItem);
|
addItem(newItem);
|
||||||
emitItemChanged(&newItem, appStatusCreated);
|
emitItemChanged(&newItem, appStatusCreated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (itemsMap.find(appId) != itemsMap.end()) {
|
if (m_desktopAndItemMap.find(filePath) != m_desktopAndItemMap.end()) {
|
||||||
Item item = itemsMap[appId];
|
// remove item
|
||||||
|
const Item &item = itemsMap[filePath];
|
||||||
|
removeDesktop(filePath);
|
||||||
emitItemChanged(&item, appStatusDeleted);
|
emitItemChanged(&item, appStatusDeleted);
|
||||||
itemsMap.remove(appId);
|
|
||||||
|
|
||||||
// 移除桌面上对应文件
|
|
||||||
QFile file(QDir::homePath() + "/Desktop" + appId + ".desktop");
|
|
||||||
file.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -623,13 +621,13 @@ void Launcher::handleAppHiddenChanged()
|
|||||||
if (itemsMap.find(appId) == itemsMap.end())
|
if (itemsMap.find(appId) == itemsMap.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DesktopInfo info = DesktopInfo(appId.toStdString());
|
DesktopInfo info = DesktopInfo(itemsMap[appId].info.path.toStdString());
|
||||||
if (!info.isValidDesktop()) {
|
if (!info.isValidDesktop()) {
|
||||||
qInfo() << "appId " << appId << "is invalid app";
|
qWarning() << "invalid Desktop Path";
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = NewItemWithDesktopInfo(info);
|
Item item = NewItemWithDesktopInfo(info);
|
||||||
item.info.id = getAppIdByFilePath(item.info.path, appDirs);
|
|
||||||
|
|
||||||
if (!(info.shouldShow() && !isDeepinCustomDesktopFile(info.getFileName().c_str())))
|
if (!(info.shouldShow() && !isDeepinCustomDesktopFile(info.getFileName().c_str())))
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user