fix: 修复卸载wine应用,桌面残留应用的问题
1. 卸载应用,从桌面移除应用的路径有误,导致文件残留 2. 缓存应用信息时,如果应用是desktop文件全路径是软连接,则获取其实际文件路径 Log: Influence: 启动器-卸载wine应用时,桌面不残留应用图标 Bug: https://pms.uniontech.com/bug-view-180665.html Change-Id: I2d1e3d3bea9aaeed940c4abeca5cc083015b94ae
This commit is contained in:
parent
3a9c1f4952
commit
f93a522546
@ -38,6 +38,7 @@
|
|||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
#include <QDBusConnectionInterface>
|
#include <QDBusConnectionInterface>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include <DSysInfo>
|
#include <DSysInfo>
|
||||||
#include <DDesktopServices>
|
#include <DDesktopServices>
|
||||||
@ -288,16 +289,18 @@ bool Launcher::requestSendToDesktop(QString appId)
|
|||||||
*/
|
*/
|
||||||
void Launcher::requestUninstall(const QString &desktop)
|
void Launcher::requestUninstall(const QString &desktop)
|
||||||
{
|
{
|
||||||
|
QString appDesktopPath = desktop;
|
||||||
|
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
for (const Item &item : m_desktopAndItemMap.values()) {
|
for (const Item &item : m_desktopAndItemMap.values()) {
|
||||||
if (item.info.path == desktop) {
|
if (item.info.path == appDesktopPath) {
|
||||||
exist = true;
|
exist = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exist) {
|
if (!exist) {
|
||||||
qWarning() << QString(" %1 uninstall faill ...").arg(desktop);
|
qWarning() << QString(" %1 uninstall faill ...").arg(appDesktopPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,16 +314,21 @@ void Launcher::requestUninstall(const QString &desktop)
|
|||||||
QString result = QString::fromUtf8(process.readAllStandardOutput());
|
QString result = QString::fromUtf8(process.readAllStandardOutput());
|
||||||
process.close();
|
process.close();
|
||||||
if (result != launcherExe) {
|
if (result != launcherExe) {
|
||||||
qWarning() << result << " has no right to uninstall " << desktop;
|
qWarning() << result << " has no right to uninstall " << appDesktopPath;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_desktopAndItemMap.keys().contains(desktop)) {
|
if (!m_desktopAndItemMap.keys().contains(appDesktopPath)) {
|
||||||
qWarning() << QString("can't find desktopPath: %1").arg(desktop);
|
QFileInfo fileInfo(appDesktopPath);
|
||||||
|
if (!fileInfo.isSymLink()) {
|
||||||
|
qWarning() << QString("can't find desktopPath: %1").arg(appDesktopPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Item &item = m_desktopAndItemMap[desktop];
|
appDesktopPath = fileInfo.symLinkTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
const Item &item = m_desktopAndItemMap[appDesktopPath];
|
||||||
DesktopInfo info(item.info.path.toStdString());
|
DesktopInfo info(item.info.path.toStdString());
|
||||||
if (!info.isValidDesktop()) {
|
if (!info.isValidDesktop()) {
|
||||||
qWarning() << QString("%1 desktop file is invalid...").arg(item.info.name);
|
qWarning() << QString("%1 desktop file is invalid...").arg(item.info.name);
|
||||||
@ -729,8 +737,14 @@ void Launcher::addItem(Item &item)
|
|||||||
|
|
||||||
item.info.categoryId = qint64(queryCategoryId(&item));
|
item.info.categoryId = qint64(queryCategoryId(&item));
|
||||||
itemsMap[item.info.id] = item;
|
itemsMap[item.info.id] = item;
|
||||||
|
|
||||||
|
QFileInfo desktopInfo(item.info.path);
|
||||||
|
if (desktopInfo.isSymLink()) {
|
||||||
|
m_desktopAndItemMap[desktopInfo.symLinkTarget()] = item;
|
||||||
|
} else {
|
||||||
m_desktopAndItemMap[item.info.path] = item;
|
m_desktopAndItemMap[item.info.path] = item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Categorytype Launcher::queryCategoryId(const Item *item)
|
Categorytype Launcher::queryCategoryId(const Item *item)
|
||||||
{
|
{
|
||||||
@ -1123,13 +1137,20 @@ void Launcher::uninstallApp(const QString &name, const QString &pkg)
|
|||||||
*/
|
*/
|
||||||
void Launcher::removeDesktop(const QString &desktop)
|
void Launcher::removeDesktop(const QString &desktop)
|
||||||
{
|
{
|
||||||
QFile file(desktop);
|
QFileInfo fileInfo(desktop);
|
||||||
|
const QString &curDesktop = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||||
|
const QString &appDesktopPath = curDesktop + "/" + fileInfo.fileName();
|
||||||
|
|
||||||
|
QFile file(appDesktopPath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
qDebug() << "file not exist...item info: " << desktop;
|
qDebug() << "file not exist...item info: " << desktop;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除应用列表中的数据
|
||||||
m_desktopAndItemMap.remove(desktop);
|
m_desktopAndItemMap.remove(desktop);
|
||||||
|
|
||||||
|
// 删除发送到桌面的应用
|
||||||
file.remove();
|
file.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,9 +1183,12 @@ void Launcher::notifyUninstallDone(const Item &item, bool result)
|
|||||||
|
|
||||||
void Launcher::removeAutoStart(const QString &desktop)
|
void Launcher::removeAutoStart(const QString &desktop)
|
||||||
{
|
{
|
||||||
QFile file(desktop);
|
QFileInfo fileInfo(desktop);
|
||||||
|
const QString &autostartPath = BaseDir::userAutoStartDir().c_str() + fileInfo.fileName();
|
||||||
|
|
||||||
|
QFile file(autostartPath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
qDebug() << QString("desktop file %1 doesn't exist...").arg(desktop);
|
qDebug() << QString("desktop file %1 doesn't exist...").arg(autostartPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user