From aa64ef84cd104cc9364ebf480117174540f69a88 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 31 Aug 2017 21:59:44 -0400 Subject: Some more cleanup on Lumina2: 1) Get the JsonMenu plugin up and running again for the context menu 2) Get the LIconCache integrated into the context menu (replacing the old LXDG::findIcon calls). 3) Get the window property events working!!! (finally) 4) Start getting some automatic window-verification put in place (for snapping windows to various places and such). --- src-qt5/core/libLumina/LIconCache.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src-qt5/core/libLumina/LIconCache.cpp') diff --git a/src-qt5/core/libLumina/LIconCache.cpp b/src-qt5/core/libLumina/LIconCache.cpp index 70c360fb..84428546 100644 --- a/src-qt5/core/libLumina/LIconCache.cpp +++ b/src-qt5/core/libLumina/LIconCache.cpp @@ -184,6 +184,27 @@ void LIconCache::loadIcon(QLabel *label, QString icon, bool noThumb){ if(needload){ startReadFile(icon, idata.fullpath); } } +void LIconCache::loadIcon(QMenu *action, QString icon, bool noThumb){ + if(icon.isEmpty()){ return; } + if(isThemeIcon(icon)){ + action->setIcon( iconFromTheme(icon)); + return ; + } + //See if the icon has already been loaded into the HASH + bool needload = !HASH.contains(icon); + if(!needload){ + if(!noThumb && !HASH[icon].thumbnail.isNull()){ action->setIcon( HASH[icon].thumbnail ); return; } + else if(!HASH[icon].icon.isNull()){ action->setIcon( HASH[icon].icon ); return; } + } + //Need to load the icon + icon_data idata; + if(HASH.contains(icon)){ idata = HASH.value(icon); } + else { idata = createData(icon); } + idata.pendingMenus << QPointer(action); //save this button for later + HASH.insert(icon, idata); + if(needload){ startReadFile(icon, idata.fullpath); } +} + void LIconCache::clearIconTheme(){ //use when the icon theme changes to refresh all requested icons QStringList keys = HASH.keys(); @@ -282,6 +303,8 @@ void LIconCache::startReadFile(QString id, QString path){ idat.pendingLabels.clear(); for(int i=0; isetIcon(idat.icon); } } idat.pendingActions.clear(); + for(int i=0; isetIcon(idat.icon); } } + idat.pendingMenus.clear(); //Now update the hash and let the world know it is available now HASH.insert(id, idat); this->emit IconAvailable(id); -- cgit