// create and fill "recent" section at first void PanelKMenu::createRecentMenuItems() { RecentlyLaunchedApps::the().m_nNumMenuItems = 0; QStringList RecentApps; RecentlyLaunchedApps::the().getRecentApps(RecentApps); if (RecentApps.count() > 0) { bool bSeparator = KickerSettings::showMenuTitles(); int nId = serviceMenuEndId() + 1; int nIndex = KickerSettings::showMenuTitles() ? 1 : 0; for (QValueList<QString>::ConstIterator it = RecentApps.fromLast(); /*nop*/; --it) { KService::Ptr s = KService::serviceByDesktopPath(*it); if (!s) { RecentlyLaunchedApps::the().removeItem(*it); } else { if (bSeparator) { bSeparator = false; int id = insertItem( new PopupMenuTitle( RecentlyLaunchedApps::the().caption(), font()), serviceMenuEndId(), 0); setItemEnabled( id, false ); } insertMenuItem(s, nId++, nIndex); RecentlyLaunchedApps::the().m_nNumMenuItems++; } if (it == RecentApps.begin()) { break; } } if (!KickerSettings::showMenuTitles()) { insertSeparator(RecentlyLaunchedApps::the().m_nNumMenuItems); } } }
void PanelKMenu::updateRecent() { if (!RecentlyLaunchedApps::self().m_bNeedToUpdate) { return; } RecentlyLaunchedApps::self().m_bNeedToUpdate = false; int nId = serviceMenuEndId() + 1; // remove previous items if (RecentlyLaunchedApps::self().m_nNumMenuItems > 0) { // -1 --> menu title int i = KickerSettings::showMenuTitles() ? -1 : 0; for (; i < RecentlyLaunchedApps::self().m_nNumMenuItems; i++) { removeItem(nId + i); entryMap_.remove(nId + i); } RecentlyLaunchedApps::self().m_nNumMenuItems = 0; if (!KickerSettings::showMenuTitles()) { removeItemAt(0); } } // insert new items QStringList RecentApps; RecentlyLaunchedApps::self().getRecentApps(RecentApps); if (RecentApps.count() > 0) { bool bNeedSeparator = KickerSettings::showMenuTitles(); for (QList<QString>::iterator it = RecentApps.fromLast(); /*nop*/; --it) { KService::Ptr s = KService::serviceByDesktopPath(*it); if (!s) { RecentlyLaunchedApps::self().removeItem(*it); } else { if (bNeedSeparator) { bNeedSeparator = false; addSeparator(); /* FIXME: no more titles! int id = insertTitle( RecentlyLaunchedApps::self().caption(), nId - 1, 0); setItemEnabled( id, false ); */ } insertMenuItem(s, nId++, KickerSettings::showMenuTitles() ? 1 : 0); RecentlyLaunchedApps::self().m_nNumMenuItems++; } if (it == RecentApps.begin()) break; } if (!KickerSettings::showMenuTitles()) { insertSeparator(RecentlyLaunchedApps::self().m_nNumMenuItems); } } }