[PC-BSD Commits] r20091 - users/ken/EasyPBI2

svn at pcbsd.org svn at pcbsd.org
Tue Oct 30 16:16:42 PDT 2012


Author: kenmoore
Date: 2012-10-30 23:16:41 +0000 (Tue, 30 Oct 2012)
New Revision: 20091

Modified:
   users/ken/EasyPBI2/mainGUI.cpp
   users/ken/EasyPBI2/mainGUI.h
   users/ken/EasyPBI2/mainGUI.ui
   users/ken/EasyPBI2/modBuild.cpp
Log:
More work on the XDG tab for EasyPBI2, just the write and remove slots to go. LAso fixed a couple bugs with the resources tab and displaying empty menu's on pushbuttons



Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-10-30 19:55:47 UTC (rev 20090)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-10-30 23:16:41 UTC (rev 20091)
@@ -24,6 +24,11 @@
 	  menu_validMenuCats.addAction(cats[i]);
 	  menu_validMenuCatsNew.addAction(cats[i]);
 	}
+	menu_elOpts.addAction("binary");
+	menu_elOpts.addAction("linux");
+	menu_elOpts.addAction("keep");
+	menu_elOpts.addAction("replace");
+	menu_elOpts.addAction("nocrash");
 	//Setup Toolbar
 	ui->actionNew_Module->setIcon(Backend::icon("new"));
 	ui->actionLoad_Module->setIcon(Backend::icon("load"));
@@ -58,9 +63,20 @@
 	connect(ui->list_xdg_files,SIGNAL(itemSelectionChanged()), this, SLOT(slotXdgFileChanged()) );
 	ui->push_xdg_refresh->setIcon(Backend::icon("refresh"));
 	connect(ui->push_xdg_refresh, SIGNAL(clicked()), this, SLOT(slotXdgTypeChanged()) );
+	ui->push_xdg_exec->setIcon(Backend::icon("left"));
+	ui->push_xdg_exec->setMenu(&menu_bins);
+	connect(&menu_bins, SIGNAL(triggered(QAction*)), this, SLOT(slotAddBin(QAction*)) );
+	ui->push_xdg_execnew->setIcon(Backend::icon("left"));
+	ui->push_xdg_execnew->setMenu(&menu_binsnew);
+	connect(&menu_binsnew, SIGNAL(triggered(QAction*)), this, SLOT(slotAddBinNew(QAction*)) );
+
 	ui->push_xdg_savechanges->setIcon(Backend::icon("save"));
 	ui->push_xdg_addmime->setIcon(Backend::icon("left"));
+	ui->push_xdg_addmime->setMenu(&menu_mime);
+	connect(&menu_mime, SIGNAL(triggered(QAction*)), this, SLOT(slotAddMimeType(QAction*)) );
 	ui->push_xdg_addmimenew->setIcon(Backend::icon("left"));
+	ui->push_xdg_addmimenew->setMenu(&menu_mimenew);
+	connect(&menu_mimenew, SIGNAL(triggered(QAction*)), this, SLOT(slotAddMimeTypeNew(QAction*)) );
 	ui->push_xdg_menu->setIcon(Backend::icon("left"));
 	ui->push_xdg_menu->setMenu(&menu_validMenuCats);
 	connect(&menu_validMenuCats,SIGNAL(triggered(QAction*)),this,SLOT(slotAddMenuCat(QAction*)) );
@@ -76,11 +92,6 @@
 	ui->push_el_files->setMenu(&menu_binList);
 	
 	ui->push_el_filetype->setIcon(Backend::icon("left"));
-	menu_elOpts.addAction("binary");
-	menu_elOpts.addAction("linux");
-	menu_elOpts.addAction("keep");
-	menu_elOpts.addAction("replace");
-	menu_elOpts.addAction("nocrash");
 	ui->push_el_filetype->setMenu(&menu_elOpts);
 	//Setup PBI Builder
 	ui->push_build_stop->setIcon(Backend::icon("close"));
@@ -217,6 +228,7 @@
   bool doall = ( (item == "all") || item.isEmpty() );
   bool doeditor = (item == "editor"); //also add a flag to just refresh the editor
   //Refresh the desired tab(s)
+  // ------PBI.CONF------
   if( doall || doeditor || (item == "pbiconf")){
     if(isport){
 	ui->line_progversion->setVisible(FALSE); ui->label_progversion->setVisible(FALSE);
@@ -270,31 +282,33 @@
       menu_addOpt.addAction(opts[i]);
     }
   }
+  // -----RESOURCES--------
   if( doall || doeditor || (item == "resources")){
     //Get the all the current files in the resources category and add them to the list
     QStringList rs = currentModule->filesAvailable("resources");
-    QString cr;
-    if(ui->listw_resources->currentRow() != -1){ cr = ui->listw_resources->currentItem()->text(); }
+    //disconnect the signal/slot connection to make sure we don't get an extra phantom refresh
+    disconnect(ui->listw_resources, SIGNAL(itemSelectionChanged()), this, SLOT(slotResourceChanged()) );
+    //Update the Widget
     ui->listw_resources->clear();
-    //for(int i=0; i<rs.length(); i++){
-      ui->listw_resources->addItems(rs);
-    //}
-    int id = rs.indexOf(cr);
-    if(id != -1){ ui->listw_resources->setCurrentRow(id); }
-    else if(rs.length() > 0){ ui->listw_resources->setCurrentRow(0); }
-    
+    ui->listw_resources->addItems(rs);
+    //re-connect the signal/slot
+    connect(ui->listw_resources, SIGNAL(itemSelectionChanged()), this, SLOT(slotResourceChanged()) );
     //Load the file into the viewers
     slotResourceChanged();
   }
+  //------XDG------
   if( doall || doeditor || (item == "xdg")){
     slotXdgTypeChanged();
   }
+  //------SCRIPTS-----
   if( doall || doeditor || (item == "scripts")){
     //nothing to make visible/invisible here
   }
+  //------EXTERNAL-LINKS------
   if( doall || doeditor || (item == "external-links")){
     //nothing to make visible/invisible here
   }
+  //------FREENAS PLUGINS-------
   if( doall || doeditor || (item == "freenas")){
     //nothing to make visible/invisible here
   }
@@ -538,7 +552,6 @@
   //Get the current file selected
   QString cfile;
   if(ui->listw_resources->currentRow() != -1){ cfile = ui->listw_resources->currentItem()->text(); }
-  
   if(cfile.isEmpty()){ //no item selected
     ui->push_resources_savewrapper->setVisible(FALSE);
     ui->text_resources_script->setVisible(FALSE);
@@ -592,7 +605,11 @@
   //Check that there is something selected  
   if(cfile.isEmpty()){ return; }
   //Remove the resource
-  currentModule->removeResource(cfile);	
+  if(currentModule->removeResource(cfile)){
+      qDebug() << "Removed Resource:" << cfile;
+  }else{
+      qDebug() << "Error: Could not remove resource:"<<cfile;
+  }
   //Refresh the GUI
   refreshGUI("resources");
 }
@@ -633,7 +650,7 @@
     //Set the visibility
         //Current file
 	ui->label_xdg_name->setVisible(TRUE); ui->line_xdg_name->setVisible(TRUE);
-	ui->label_xdg_exec->setVisible(TRUE); ui->line_xdg_exec->setVisible(TRUE);
+	ui->label_xdg_exec->setVisible(TRUE); ui->line_xdg_exec->setVisible(TRUE); ui->push_xdg_exec->setVisible(TRUE);
 	ui->label_xdg_icon->setVisible(TRUE); ui->list_xdg_icon->setVisible(TRUE);
 	ui->label_xdg_menu->setVisible(FALSE); ui->line_xdg_menu->setVisible(FALSE); ui->push_xdg_menu->setVisible(FALSE);
 	ui->check_xdg_nodisplay->setVisible(TRUE);
@@ -643,7 +660,7 @@
 	ui->label_xdg_mimeinfo->setVisible(FALSE); ui->line_xdg_mimeinfo->setVisible(FALSE);
 	//New file
 	ui->label_xdg_namenew->setVisible(TRUE); ui->line_xdg_namenew->setVisible(TRUE);
-	ui->label_xdg_execnew->setVisible(TRUE); ui->line_xdg_execnew->setVisible(TRUE);
+	ui->label_xdg_execnew->setVisible(TRUE); ui->line_xdg_execnew->setVisible(TRUE); ui->push_xdg_execnew->setVisible(TRUE);
 	ui->label_xdg_iconnew->setVisible(TRUE); ui->list_xdg_iconnew->setVisible(TRUE);
 	ui->label_xdg_menunew->setVisible(FALSE); ui->line_xdg_menunew->setVisible(FALSE); ui->push_xdg_menunew->setVisible(FALSE);
 	ui->check_xdg_nodisplaynew->setVisible(TRUE);
@@ -658,7 +675,7 @@
     //Set the visibility
 	//Current file
 	ui->label_xdg_name->setVisible(TRUE); ui->line_xdg_name->setVisible(TRUE);
-	ui->label_xdg_exec->setVisible(TRUE); ui->line_xdg_exec->setVisible(TRUE);
+	ui->label_xdg_exec->setVisible(TRUE); ui->line_xdg_exec->setVisible(TRUE); ui->push_xdg_exec->setVisible(TRUE);
 	ui->label_xdg_icon->setVisible(TRUE); ui->list_xdg_icon->setVisible(TRUE);
 	ui->label_xdg_menu->setVisible(TRUE); ui->line_xdg_menu->setVisible(TRUE); ui->push_xdg_menu->setVisible(TRUE);
 	ui->check_xdg_nodisplay->setVisible(TRUE);
@@ -668,7 +685,7 @@
 	ui->label_xdg_mimeinfo->setVisible(FALSE); ui->line_xdg_mimeinfo->setVisible(FALSE);
 	//New file
 	ui->label_xdg_namenew->setVisible(TRUE); ui->line_xdg_namenew->setVisible(TRUE);
-	ui->label_xdg_execnew->setVisible(TRUE); ui->line_xdg_execnew->setVisible(TRUE);
+	ui->label_xdg_execnew->setVisible(TRUE); ui->line_xdg_execnew->setVisible(TRUE); ui->push_xdg_execnew->setVisible(TRUE);
 	ui->label_xdg_iconnew->setVisible(TRUE); ui->list_xdg_iconnew->setVisible(TRUE);
 	ui->label_xdg_menunew->setVisible(TRUE); ui->line_xdg_menunew->setVisible(TRUE); ui->push_xdg_menunew->setVisible(TRUE);
 	ui->check_xdg_nodisplaynew->setVisible(TRUE);
@@ -684,7 +701,7 @@
     //Set the visibility
 	//Current file
 	ui->label_xdg_name->setVisible(FALSE); ui->line_xdg_name->setVisible(FALSE);
-	ui->label_xdg_exec->setVisible(FALSE); ui->line_xdg_exec->setVisible(FALSE);
+	ui->label_xdg_exec->setVisible(FALSE); ui->line_xdg_exec->setVisible(FALSE); ui->push_xdg_exec->setVisible(FALSE);
 	ui->label_xdg_icon->setVisible(FALSE); ui->list_xdg_icon->setVisible(FALSE);
 	ui->label_xdg_menu->setVisible(FALSE); ui->line_xdg_menu->setVisible(FALSE); ui->push_xdg_menu->setVisible(FALSE);
 	ui->check_xdg_nodisplay->setVisible(FALSE);
@@ -694,7 +711,7 @@
 	ui->label_xdg_mimeinfo->setVisible(TRUE); ui->line_xdg_mimeinfo->setVisible(TRUE);
 	//New file
 	ui->label_xdg_namenew->setVisible(FALSE); ui->line_xdg_namenew->setVisible(FALSE);
-	ui->label_xdg_execnew->setVisible(FALSE); ui->line_xdg_execnew->setVisible(FALSE);
+	ui->label_xdg_execnew->setVisible(FALSE); ui->line_xdg_execnew->setVisible(FALSE); ui->push_xdg_execnew->setVisible(FALSE);
 	ui->label_xdg_iconnew->setVisible(FALSE); ui->list_xdg_iconnew->setVisible(FALSE);
 	ui->label_xdg_menunew->setVisible(FALSE); ui->line_xdg_menunew->setVisible(FALSE); ui->push_xdg_menunew->setVisible(FALSE);
 	ui->check_xdg_nodisplaynew->setVisible(FALSE);
@@ -712,6 +729,26 @@
   for(int i=0; i<icons.length(); i++){
     ui->list_xdg_iconnew->addItem(QIcon(currentModule->path()+"/resources/"+icons[i]),icons[i]);
   }	    
+  //Update the buttons that only need a refresh when the type changes (such as menu's)
+  //Available binaries pushbuttons
+  menu_bins.clear(); menu_binsnew.clear();
+  QStringList cBins = currentModule->currentBins;
+  if(!cBins.isEmpty()){
+    for(int i=0; i<cBins.length(); i++){
+      menu_bins.addAction(cBins[i]);
+      menu_binsnew.addAction(cBins[i]);
+    } 
+  }
+  //MIME type pushbuttons
+  menu_mime.clear(); menu_mimenew.clear();
+  QStringList mimetypes = currentModule->currentMimeTypes;
+  if(!mimetypes.isEmpty()){
+    for(int i=0; i<mimetypes.length(); i++){
+      menu_mime.addAction(mimetypes[i]);
+      menu_mimenew.addAction(mimetypes[i]);
+    }
+  }
+    
   //Now update read the currently selected file
   slotXdgFileChanged();
 }
@@ -764,7 +801,7 @@
     chk = currentModule->readValue("desktopnodisplay").toLower();
     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_nodisplay->setChecked(TRUE); }
     else{ ui->check_xdg_nodisplay->setChecked(FALSE); }
-	
+    	
   }else if(ui->radio_xdg_menu->isChecked()){
     //Load the file
     currentModule->loadMenu(file);
@@ -796,7 +833,7 @@
     chk = currentModule->readValue("menunodisplay").toLower();
     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_nodisplay->setChecked(TRUE); }
     else{ ui->check_xdg_nodisplay->setChecked(FALSE); }
-    
+   
   }else if(ui->radio_xdg_mime->isChecked()){
     //Load the file
     currentModule->loadMime(file);
@@ -838,3 +875,23 @@
   //Now replace the line onto the GUI
   ui->line_xdg_menunew->setText(oldcats.join("; "));
 }
+
+void MainGUI::slotAddMimeType(QAction* act){
+  //replace the current mime type with the selected one
+  ui->line_xdg_mimetype->setText(act->text() );
+}
+
+void MainGUI::slotAddMimeTypeNew(QAction* act){
+  //replace the current mime type with the selected one
+  ui->line_xdg_mimetypenew->setText(act->text());
+}
+
+void MainGUI::slotAddBin(QAction* act){
+  //replace the current executable with the new one
+  ui->line_xdg_exec->setText(act->text().section("/",-1) );	
+}
+
+void MainGUI::slotAddBinNew(QAction* act){
+  //replace the current executable with the new one
+  ui->line_xdg_execnew->setText( act->text().section("/",-1) );	
+}

Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h	2012-10-30 19:55:47 UTC (rev 20090)
+++ users/ken/EasyPBI2/mainGUI.h	2012-10-30 23:16:41 UTC (rev 20091)
@@ -59,13 +59,18 @@
     void slotXdgFileChanged();
     void slotAddMenuCat(QAction*);
     void slotAddMenuCatNew(QAction*);
+    void slotAddMimeType(QAction*);
+    void slotAddMimeTypeNew(QAction*);
+    void slotAddBin(QAction*);
+    void slotAddBinNew(QAction*);
 
+
 private:
     Ui::MainGUI *ui;
     ModBuild *currentModule;
     QLineEdit *line_module;
     QRadioButton *radio_module_port, *radio_module_local;
-    QMenu menu_addOpt, menu_binList, menu_elOpts, menu_validMenuCats, menu_validMenuCatsNew;
+    QMenu menu_addOpt, menu_binList, menu_elOpts, menu_validMenuCats, menu_validMenuCatsNew, menu_mime, menu_mimenew, menu_bins, menu_binsnew;
 
     QString PROG_DIR, PORTS_DIR, PBIOUT_DIR, MODOUT_DIR, CACHE_DIR, PROGVERSION, PBISETTINGS_FILE, DEFAULTICON_FILE;
     QString SU_CMD, PBIBUILD_CMD, PBICREATE_CMD, PBI_BUILDING_NOW;

Modified: users/ken/EasyPBI2/mainGUI.ui
===================================================================
(Binary files differ)

Modified: users/ken/EasyPBI2/modBuild.cpp
===================================================================
--- users/ken/EasyPBI2/modBuild.cpp	2012-10-30 19:55:47 UTC (rev 20090)
+++ users/ken/EasyPBI2/modBuild.cpp	2012-10-30 23:16:41 UTC (rev 20091)
@@ -77,7 +77,7 @@
   currentBins.clear(); currentIcons.clear(); currentMimeTypes.clear();
   //Reset the XDG file structures	
   loadDesktop(""); loadMenu(""); //Just clear these structures
-  QStringList tmp = filesAvailable("mime");
+  QStringList tmp = filesAvailable("xdg-mime");
   for(int i=0; i<tmp.length(); i++){
     loadMime(tmp[i]); //This will fill up the currentMimeTypes structure;
   }
@@ -95,7 +95,7 @@
     loadExternalLinks();
   }
   //Reset the ports structure
-  readPortInformation("");
+  readPortInformation(""); //should fill up the currentBins structure
   return TRUE;
 }
 
@@ -196,10 +196,12 @@
     QStringList tmp = portStruct[3].split("###");
     tmp.removeDuplicates();
     portStruct[3] = tmp.join(" ");
-    tmp = portStruct[4].split("###");
+    tmp = portStruct[4].split("###", QString::SkipEmptyParts);
     tmp.removeDuplicates();
+    currentBins << tmp;     //Add the detected binaries to the currently available binaries
+    currentBins.removeDuplicates();
     portStruct[4] = tmp.join(" ");
-    
+
     //For debugging display all info
     qDebug() << " - Make Options:" << portStruct[3].split(" ");
     qDebug() << " - Binaries:" << portStruct[4].split(" ");
@@ -788,7 +790,14 @@
   }
   //Remove the item from the appropriate lists
   if(status && isIcon){ currentIcons.removeAll(filePath); }
-  else if(status && isWrapper){ currentBins.removeAll(filePath); }
+  else if(status && isWrapper){ 
+    currentBins.removeAll(filePath); 
+    dir.cd("bin");
+    if(dir.entryList(QDir::Files | QDir::NoDotAndDotDot).isEmpty() ){ 
+      dir.cdUp();
+      dir.rmdir("bin");
+    }	    
+  }
   
   return status;
 }



More information about the Commits mailing list