Fix items pinned from launcher

This commit is contained in:
reionwong 2021-08-30 00:12:52 +08:00
parent cdc3ff2a0f
commit 8f887abad6

View file

@ -101,13 +101,17 @@ void ApplicationModel::addItem(const QString &desktopFile)
item->exec = desktopInfo.value("Exec"); item->exec = desktopInfo.value("Exec");
item->desktopPath = desktopFile; item->desktopPath = desktopFile;
item->isPinned = true; item->isPinned = true;
// First use exec as the id of the item.
item->id = desktopInfo.value("Exec");
m_appItems << item; m_appItems << item;
endInsertRows(); endInsertRows();
savePinAndUnPinList();
emit itemAdded(); emit itemAdded();
emit countChanged(); emit countChanged();
savePinAndUnPinList();
} }
void ApplicationModel::removeItem(const QString &desktopFile) void ApplicationModel::removeItem(const QString &desktopFile)
@ -452,10 +456,15 @@ void ApplicationModel::onWindowAdded(quint64 wid)
// Use desktop find // Use desktop find
if (!desktopPath.isEmpty() && desktopItem != nullptr) { if (!desktopPath.isEmpty() && desktopItem != nullptr) {
desktopItem->id = id;
desktopItem->wids.append(wid); desktopItem->wids.append(wid);
// Need to update application active status. // Need to update application active status.
desktopItem->isActive = info.value("active").toBool(); desktopItem->isActive = info.value("active").toBool();
if (desktopItem->id != id) {
desktopItem->id = id;
savePinAndUnPinList();
}
handleDataChangedFromItem(desktopItem); handleDataChangedFromItem(desktopItem);
} }
// Find from id // Find from id