[PC-BSD Commits] r17489 - pcbsd/current/src-qt4/pc-softwaremanager

svn at pcbsd.org svn at pcbsd.org
Thu Jun 28 10:35:06 PDT 2012


Author: kenmoore
Date: 2012-06-28 17:35:03 +0000 (Thu, 28 Jun 2012)
New Revision: 17489

Modified:
   pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp
   pcbsd/current/src-qt4/pc-softwaremanager/pbi.h
   pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp
Log:
Setup pc-software manager to dynamically update the right-click menu to only display the "add desktop/menu enrtry" if there are desktop/menu entries for that installed PBI.



Modified: pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp	2012-06-28 15:12:14 UTC (rev 17488)
+++ pcbsd/current/src-qt4/pc-softwaremanager/pbi.cpp	2012-06-28 17:35:03 UTC (rev 17489)
@@ -392,3 +392,22 @@
 {
     return progressCaption;
 }
+
+bool PBI::hasDesktopEntries(){
+  QString pbiDir = "/usr/pbi/"+progIndexName.section("-",0,0)+"-"+arch;
+  QDir dir(pbiDir+"/.xdg-desktop");
+  if(!dir.exists()){return FALSE;} //not installed yet
+  QStringList entries = dir.entryList( QStringList("*.desktop"),QDir::Files,QDir::Unsorted );
+  if(entries.isEmpty()){ return FALSE; }
+  else{ return TRUE; }
+}
+
+bool PBI::hasMenuEntries(){
+  QString pbiDir = "/usr/pbi/"+progIndexName.section("-",0,0)+"-"+arch;
+  QDir dir(pbiDir+"/.xdg-menu");
+  if(!dir.exists()){return FALSE;} //not installed yet
+  QStringList entries = dir.entryList( QStringList("*.desktop"),QDir::Files,QDir::Unsorted );
+  if(entries.isEmpty()){ return FALSE; }
+  else{ return TRUE; }
+}
+

Modified: pcbsd/current/src-qt4/pc-softwaremanager/pbi.h
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/pbi.h	2012-06-28 15:12:14 UTC (rev 17488)
+++ pcbsd/current/src-qt4/pc-softwaremanager/pbi.h	2012-06-28 17:35:03 UTC (rev 17489)
@@ -54,6 +54,8 @@
     virtual bool isDirty();
     virtual bool isNewDownload();
     virtual bool isWorking();
+    virtual bool hasDesktopEntries();
+    virtual bool hasMenuEntries();
     virtual int getDownloadAttempts();
     virtual int getWorkingStatus();
     virtual QString getArch();

Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp	2012-06-28 15:12:14 UTC (rev 17488)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp	2012-06-28 17:35:03 UTC (rev 17489)
@@ -476,10 +476,14 @@
 
          if ( ! item->isNewDownload() ) {
            popup->addSeparator();
-           popup->addAction( tr("Install Desktop Icons"), this, SLOT(slotAddDesktopIcons()));
-           popup->addAction( tr("Install Menu Icons"), this, SLOT(slotAddMenuIcons()));
-           popup->addAction( tr("Install Menu Icons (All Users)"), this, SLOT(slotAddMenuIconsRoot()));
-           popup->addSeparator();
+           if(item->hasDesktopEntries()){
+             popup->addAction( tr("Install Desktop Icons"), this, SLOT(slotAddDesktopIcons()));
+	   }
+           if(item->hasMenuEntries()){
+             popup->addAction( tr("Install Menu Icons"), this, SLOT(slotAddMenuIcons()));
+             popup->addAction( tr("Install Menu Icons (All Users)"), this, SLOT(slotAddMenuIconsRoot()));
+           }
+           if(item->hasDesktopEntries() || item->hasMenuEntries() ){ popup->addSeparator(); }
            popup->addAction( tr("Uninstall"), this, SLOT(RemoveButtonSlot()));
            popup->exec( QCursor::pos() );
          } else {



More information about the Commits mailing list