From 8f887abad6c6b241e3f674c5460664f0bdda79af Mon Sep 17 00:00:00 2001 From: reionwong Date: Mon, 30 Aug 2021 00:12:52 +0800 Subject: [PATCH] Fix items pinned from launcher --- src/applicationmodel.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/applicationmodel.cpp b/src/applicationmodel.cpp index 2d860e0..9d0910e 100644 --- a/src/applicationmodel.cpp +++ b/src/applicationmodel.cpp @@ -101,13 +101,17 @@ void ApplicationModel::addItem(const QString &desktopFile) item->exec = desktopInfo.value("Exec"); item->desktopPath = desktopFile; item->isPinned = true; + + // First use exec as the id of the item. + item->id = desktopInfo.value("Exec"); + m_appItems << item; endInsertRows(); + savePinAndUnPinList(); + emit itemAdded(); emit countChanged(); - - savePinAndUnPinList(); } void ApplicationModel::removeItem(const QString &desktopFile) @@ -452,10 +456,15 @@ void ApplicationModel::onWindowAdded(quint64 wid) // Use desktop find if (!desktopPath.isEmpty() && desktopItem != nullptr) { - desktopItem->id = id; desktopItem->wids.append(wid); // Need to update application active status. desktopItem->isActive = info.value("active").toBool(); + + if (desktopItem->id != id) { + desktopItem->id = id; + savePinAndUnPinList(); + } + handleDataChangedFromItem(desktopItem); } // Find from id