From 457c885e53eab93462fc7321c5b9671edc7212a5 Mon Sep 17 00:00:00 2001 From: wangjinrun Date: Thu, 17 Sep 2026 17:34:40 +0800 Subject: [PATCH] fix: eliminate progressive app loading in windowed launcher AppsModel deferred row insertion for apps whose theme icons were not yet resolvable at startup, causing rows to be inserted one by one after the 3-second polling interval, producing a visible scroll/progressive loading effect. Fix: insert all accepted rows immediately. The waitForIcon() tracking mechanism is preserved (timer + pending queue), but shouldDelaySourceIndex() now always returns false. When a pending icon becomes ready, the pendingAppItemReady handler emits dataChanged(IconNameRole) on the existing row instead of inserting a new one. rebuildRows() no longer skips pending items since they are already in the model. This does not regress bug-347859/371833: apps still display immediately, icons briefly use a fallback and refresh in-place once resolved. Log: Fix progressive loading in windowed launcher by inserting all app rows immediately and updating icons in-place via dataChanged. PMS: BUG-372641 Influence: Windowed launcher now loads all apps at once without progressive scroll; icon fallback may flash briefly before refreshing. --- src/models/appsmodel.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/models/appsmodel.cpp b/src/models/appsmodel.cpp index cebe3b34..38bde061 100644 --- a/src/models/appsmodel.cpp +++ b/src/models/appsmodel.cpp @@ -65,17 +65,12 @@ AppsModel::AppsModel(QObject *parent) const QModelIndex sourceIndex = m_sourceModel->index(sourceRow, 0); if (normalizedDesktopId(sourceData(sourceIndex, DesktopIdRoleName).toString()) != desktopId) continue; - if (!acceptsSourceIndex(sourceIndex)) - return; - const QPersistentModelIndex persistentSourceIndex(sourceIndex); - if (m_rows.contains(persistentSourceIndex)) + const int adapterRow = m_rows.indexOf(persistentSourceIndex); + if (adapterRow < 0) return; - const int adapterRow = adapterRowForSourceRow(sourceRow); - beginInsertRows({}, adapterRow, adapterRow); - m_rows.insert(adapterRow, persistentSourceIndex); - endInsertRows(); + Q_EMIT dataChanged(index(adapterRow, 0), index(adapterRow, 0), { AppsModel::IconNameRole }); return; } }); @@ -405,8 +400,7 @@ void AppsModel::rebuildRows() if (m_sourceModel) { for (int row = 0; row < m_sourceModel->rowCount(); ++row) { const QModelIndex sourceIndex = m_sourceModel->index(row, 0); - const QString desktopId = normalizedDesktopId(sourceData(sourceIndex, DesktopIdRoleName).toString()); - if (acceptsSourceIndex(sourceIndex) && !AppMgr::instance()->isPendingAppItem(desktopId)) + if (acceptsSourceIndex(sourceIndex)) m_rows.append(sourceIndex); } } @@ -417,7 +411,10 @@ bool AppsModel::shouldDelaySourceIndex(const QModelIndex &sourceIndex) const { const QString desktopId = normalizedDesktopId(sourceData(sourceIndex, DesktopIdRoleName).toString()); const QString iconName = sourceData(sourceIndex, IconNameRoleName).toString(); - return AppMgr::instance()->waitForIcon(desktopId, iconName); + // Track the item for icon-readiness polling, but never delay row insertion. + // Rows are inserted immediately; icons update in-place via dataChanged when ready. + AppMgr::instance()->waitForIcon(desktopId, iconName); + return false; } void AppsModel::updateIconData()