fix: 修复任务栏应用强制退出后图标没有移除的问题

在强制退出应用后,发送应用移除的信号

Log:
Influence: 打开一个应用,鼠标右键-强制退出,观察应用图标是否在任务栏上
Bug: https://pms.uniontech.com/bug-view-172223.html
Change-Id: Iac05ff938ab452cc806d7295af8b06d8ba522331
This commit is contained in:
donghualin 2022-11-18 08:49:21 +00:00
parent e70b17eea1
commit 8b31d63212
3 changed files with 28 additions and 23 deletions

View File

@ -1135,29 +1135,8 @@ void Dock::detachWindow(WindowInfoBase *info)
if (!entry) if (!entry)
return; return;
bool needRemove = entry->detachWindow(info); if (entry->detachWindow(info))
if (needRemove) { removeEntryFromDock(entry);
// 如果是最近打开应用
if (m_entries->shouldInRecent()) {
// 更新entry的导出窗口信息
entry->updateExportWindowInfos();
// 更新entry的右键菜单的信息
entry->updateMenu();
// 更新entry的当前窗口的信息
entry->setCurrentWindowInfo(nullptr);
// 移除应用后,同时更新最近打开的应用
updateRecentApps();
// 如果是高效模式,则发送消息或者关闭了显示最近应用的功能,则从任务栏移除
if (SETTING->getDisplayMode() == DisplayMode::Efficient
|| !m_showRecent) {
Q_EMIT entryRemoved(entry->getId());
}
} else {
removeAppEntry(entry);
// 移除应用后,同时更新最近打开的应用
updateRecentApps();
}
}
} }
/** /**
@ -1265,6 +1244,30 @@ void Dock::updateRecentApps()
SETTING->setRecentApps(unDockedApps); SETTING->setRecentApps(unDockedApps);
} }
void Dock::removeEntryFromDock(Entry *entry)
{
// 如果是最近打开应用
if (m_entries->shouldInRecent()) {
// 更新entry的导出窗口信息
entry->updateExportWindowInfos();
// 更新entry的右键菜单的信息
entry->updateMenu();
// 更新entry的当前窗口的信息
entry->setCurrentWindowInfo(nullptr);
// 移除应用后,同时更新最近打开的应用
updateRecentApps();
// 如果是高效模式,则发送消息或者关闭了显示最近应用的功能,则从任务栏移除
if ((SETTING->getDisplayMode() == DisplayMode::Efficient
|| !m_showRecent) && !entry->getIsDocked()) {
Q_EMIT entryRemoved(entry->getId());
}
} else {
removeAppEntry(entry);
// 移除应用后,同时更新最近打开的应用
updateRecentApps();
}
}
void Dock::onShowRecentChanged(bool visible) void Dock::onShowRecentChanged(bool visible)
{ {
if (m_showRecent == visible) if (m_showRecent == visible)

View File

@ -145,6 +145,7 @@ public:
void setPluginSettings(QString jsonStr); void setPluginSettings(QString jsonStr);
void mergePluginSettings(QString jsonStr); void mergePluginSettings(QString jsonStr);
void removePluginSettings(QString pluginName, QStringList settingkeys); void removePluginSettings(QString pluginName, QStringList settingkeys);
void removeEntryFromDock(Entry *entry);
Q_SIGNALS: Q_SIGNALS:
void serviceRestarted(); void serviceRestarted();

View File

@ -642,6 +642,7 @@ void Entry::forceQuit()
m_windowInfoMap.clear(); m_windowInfoMap.clear();
// 退出所有的进程后,及时更新当前剩余的窗口数量 // 退出所有的进程后,及时更新当前剩余的窗口数量
updateExportWindowInfos(); updateExportWindowInfos();
m_dock->removeEntryFromDock(this);
} }
void Entry::presentWindows() void Entry::presentWindows()