fix: 修复控制中心发送应用到任务栏不显示的问题

当应用打开的时候移除驻留,该应用作为最近打开应用,在取消驻留的时候,只是停止了服务,并未从列表中移除;下次驻留的时候,没有启动服务,导致任务栏图标没有驻留

Log: 修复控制中心无法发送应用到任务栏的问题
Influence: 从任务栏打开一个已经驻留的应用,对这个应用取消驻留,关闭应用,打开启动器,把这个应用发送到任务栏,观察任务栏是否有这个应用
Bug: https://pms.uniontech.com/bug-view-165891.html
Change-Id: I89fdaad6c33388dab67eb9c7d41dd372d36582bd
This commit is contained in:
donghualin 2022-10-28 03:19:47 +00:00
parent 873a642f06
commit 6c06ed86b7
4 changed files with 29 additions and 21 deletions

View File

@ -187,7 +187,7 @@ bool Dock::dockEntry(Entry *entry, bool moveToEnd)
if (moveToEnd && SETTING->getDisplayMode() == DisplayMode::Fashion)
m_entries->moveEntryToLast(entry);
entry->setPropIsDocked(true);
entry->setIsDocked(true);
entry->updateMenu();
entry->updateMode();
return true;
@ -255,7 +255,7 @@ void Dock::undockEntry(Entry *entry, bool moveToEnd)
m_entries->moveEntryToLast(entry);
entry->updateIcon();
entry->setPropIsDocked(false);
entry->setIsDocked(false);
entry->updateName();
entry->updateMenu();
} else {
@ -528,20 +528,15 @@ bool Dock::requestDock(QString desktopFile, int index)
return false;
}
bool newCreated = false;
Entry *entry = m_entries->getByInnerId(app->getInnerId());
if (!entry) {
newCreated = true;
if (!entry)
entry = new Entry(this, app, app->getInnerId());
}
if (!dockEntry(entry))
return false;
if (newCreated) {
entry->startExport();
m_entries->append(entry);
}
entry->startExport();
m_entries->append(entry);
saveDockedApps();
return true;

View File

@ -52,6 +52,10 @@ Entry *Entries::getByInnerId(QString innerId)
void Entries::append(Entry *entry)
{
// 如果当前应用在列表中存在(通常是该应用为最近打开应用但是关闭了最近打开应用的接口或者当前为高效模式)
if (m_items.contains(entry))
m_items.removeOne(entry);
insert(entry, -1);
}
@ -276,10 +280,10 @@ void Entries::removeLastRecent()
if (unDockCount >= MAX_UNOPEN_RECENT_COUNT && unDockEntrys.size() > 0) {
// 只有当最近使用区域的图标大于等于某个数值3的时候并且存在没有子窗口的Entry那么就移除该Entry
Entry *entry = unDockEntrys[0];
m_items.removeOne(entry);
removeEntrys << entry;
}
for (Entry *entry : removeEntrys) {
m_items.removeOne(entry);
removeCb(entry);
delete entry;
}

View File

@ -40,6 +40,7 @@ Entry::Entry(Dock *_dock, AppInfo *_app, QString _innerId, QObject *parent)
, m_isActive(false)
, m_isDocked(false)
, m_innerId(_innerId)
, m_adapterEntry(nullptr)
, m_current(nullptr)
, m_currentWindow(0)
, m_winIconPreferred(false)
@ -210,7 +211,12 @@ void Entry::startExport()
return;
}
new DBusAdaptorEntry(this); // export dbus by Adaptor
if (m_adapterEntry) {
qWarning() << "service " << getName() << " is running";
return;
}
m_adapterEntry = new DBusAdaptorEntry(this); // export dbus by Adaptor
QDBusConnection con = QDBusConnection::sessionBus();
if (!con.registerService(dbusService)) {
qWarning() << "register service Dock1 error:" << con.lastError().message();
@ -230,8 +236,16 @@ void Entry::stopExport()
return;
}
if (!m_adapterEntry) {
qWarning() << "serice " << getName() << "is not running";
return;
}
QDBusConnection con = QDBusConnection::sessionBus();
con.unregisterObject(path());
m_adapterEntry->deleteLater();
m_adapterEntry = nullptr;
}
void Entry::setMenu(AppMenu *_menu)
@ -348,14 +362,6 @@ WindowInfoBase *Entry::getWindowInfoByWinId(XWindow windowId)
return nullptr;
}
void Entry::setPropIsDocked(bool docked)
{
if (m_isDocked != docked) {
m_isDocked = docked;
Q_EMIT isDockedChanged(docked);
}
}
void Entry::setPropIcon(QString value)
{
if (value != m_icon) {

View File

@ -37,6 +37,8 @@
// 单个应用类
class Dock;
class DBusAdaptorEntry;
class Entry: public QObject
{
Q_OBJECT
@ -67,7 +69,6 @@ public:
void updateIsActive();
WindowInfoBase *getWindowInfoByPid(int pid);
WindowInfoBase *getWindowInfoByWinId(XWindow windowId);
void setPropIsDocked(bool docked);
void setPropIcon(QString value);
void setPropName(QString value);
void setPropIsActive(bool active);
@ -145,6 +146,8 @@ private:
QString m_innerId;
QString m_desktopFile;
DBusAdaptorEntry *m_adapterEntry;
// Dbus属性直接放到interface上
QMap<XWindow, WindowInfoBase *> m_windowInfoMap; // 该应用所有窗口
WindowInfoMap m_exportWindowInfos; // 该应用导出的窗口属性