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

svn at pcbsd.org svn at pcbsd.org
Tue Oct 30 12:55:48 PDT 2012


Author: kenmoore
Date: 2012-10-30 19:55:47 +0000 (Tue, 30 Oct 2012)
New Revision: 20090

Removed:
   users/ken/EasyPBI2/Makefile
Modified:
   users/ken/EasyPBI2/mainGUI.cpp
   users/ken/EasyPBI2/mainGUI.h
   users/ken/EasyPBI2/mainGUI.ui
Log:
Commit some more improvements to the XDG tab for EasyPBI2, just a couple more slots to go



Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-10-30 17:56:03 UTC (rev 20089)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-10-30 19:55:47 UTC (rev 20090)
@@ -17,7 +17,13 @@
 	currentModule = new ModBuild();
 	//Setup the Menu items
 	ui->actionExit->setIcon(Backend::icon(""));
-	//menuList = new QList<QMenu*>;
+	//Setup the pushbutton menu lists
+	QStringList cats;
+	cats <<"AudioVideo"<<"Development"<<"Education"<<"Game"<<"Graphics"<<"Network"<<"Office"<<"Settings"<<"System";
+	for(int i=0; i<cats.length(); i++){
+	  menu_validMenuCats.addAction(cats[i]);
+	  menu_validMenuCatsNew.addAction(cats[i]);
+	}
 	//Setup Toolbar
 	ui->actionNew_Module->setIcon(Backend::icon("new"));
 	ui->actionLoad_Module->setIcon(Backend::icon("load"));
@@ -55,6 +61,12 @@
 	ui->push_xdg_savechanges->setIcon(Backend::icon("save"));
 	ui->push_xdg_addmime->setIcon(Backend::icon("left"));
 	ui->push_xdg_addmimenew->setIcon(Backend::icon("left"));
+	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*)) );
+	ui->push_xdg_menunew->setIcon(Backend::icon("left"));
+	ui->push_xdg_menunew->setMenu(&menu_validMenuCatsNew);
+	connect(&menu_validMenuCatsNew,SIGNAL(triggered(QAction*)),this,SLOT(slotAddMenuCatNew(QAction*)) );
 	// -- Scripts tab --
 	ui->push_scripts_save->setIcon(Backend::icon("save"));
 	ui->list_scripts_file->addItems(QStringList() << "Installation Scripts" << "pre-portmake.sh" << "post-portmake.sh" << "pre-install.sh" << "post-install.sh" << "pre-remove.sh" );
@@ -106,7 +118,6 @@
   PBISETTINGS_FILE= PROG_DIR + "/.savedPBISettings.conf";
   DEFAULTICON_FILE= PROG_DIR + "/defaulticon.png";
   PORTS_DIR = "";
-  VALID_MENU_CATS << "AudioVideo" << "Development" << "Education" << "Game" << "Graphics" << "Network" << "Office" << "Settings" << "System";
   
   //Check for EasyPBI directory structure and create it if it is not there
   if( !QDir(PROG_DIR).exists() ){
@@ -245,8 +256,11 @@
         ui->list_progicon->addItem(QIcon(currentModule->path()+"/resources/"+icons[i]),icons[i]);
       }	    
       int cicon = icons.indexOf(currentModule->readValue("progicon"));
-      if( cicon == -1 ){ ui->list_progicon->setCurrentIndex(0); }
-      else{ ui->list_progicon->setCurrentIndex(cicon); }
+      if( cicon == -1 ){ 
+	      ui->list_progicon->addItem(currentModule->readValue("progicon")); 
+	      cicon = icons.indexOf(currentModule->readValue("progicon"));
+      }
+      ui->list_progicon->setCurrentIndex(cicon);
     }else{
       ui->list_progicon->addItem(currentModule->readValue("progicon"));
     }
@@ -611,11 +625,6 @@
   -------------------------------------------------
 */
 void MainGUI::slotXdgTypeChanged(){
-  //Refresh the icon/menu items
-  ui->list_xdg_icon->clear();
-  ui->list_xdg_icon->addItems(currentModule->currentIcons);
-  ui->list_xdg_menu->clear();
-  ui->list_xdg_menu->addItems(VALID_MENU_CATS);
   //Update the file list appropriately
   if(ui->radio_xdg_desktop->isChecked()){
     //update the files available
@@ -626,20 +635,22 @@
 	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_icon->setVisible(TRUE); ui->list_xdg_icon->setVisible(TRUE);
-	ui->label_xdg_menu->setVisible(FALSE); ui->list_xdg_menu->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(TRUE);
 	ui->check_xdg_terminal->setVisible(TRUE);
 	ui->push_xdg_addmime->setVisible(TRUE);
 	ui->label_xdg_mimepatterns->setVisible(FALSE); ui->line_xdg_mimepatterns->setVisible(FALSE);
+	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_iconnew->setVisible(TRUE); ui->list_xdg_iconnew->setVisible(TRUE);
-	ui->label_xdg_menunew->setVisible(FALSE); ui->list_xdg_menunew->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(TRUE);
 	ui->check_xdg_terminalnew->setVisible(TRUE);
 	ui->push_xdg_addmimenew->setVisible(TRUE);
 	ui->label_xdg_mimepatternsnew->setVisible(FALSE); ui->line_xdg_mimepatternsnew->setVisible(FALSE);
+	ui->label_xdg_mimeinfonew->setVisible(FALSE); ui->line_xdg_mimeinfonew->setVisible(FALSE);
   }else if(ui->radio_xdg_menu->isChecked()){
     //update the files available
     ui->list_xdg_files->clear();
@@ -649,20 +660,22 @@
 	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_icon->setVisible(TRUE); ui->list_xdg_icon->setVisible(TRUE);
-	ui->label_xdg_menu->setVisible(TRUE); ui->list_xdg_menu->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);
 	ui->check_xdg_terminal->setVisible(TRUE);
 	ui->push_xdg_addmime->setVisible(TRUE);
 	ui->label_xdg_mimepatterns->setVisible(FALSE); ui->line_xdg_mimepatterns->setVisible(FALSE);
+	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_iconnew->setVisible(TRUE); ui->list_xdg_iconnew->setVisible(TRUE);
-	ui->label_xdg_menunew->setVisible(TRUE); ui->list_xdg_menunew->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);
 	ui->check_xdg_terminalnew->setVisible(TRUE);
 	ui->push_xdg_addmimenew->setVisible(TRUE);
 	ui->label_xdg_mimepatternsnew->setVisible(FALSE); ui->line_xdg_mimepatternsnew->setVisible(FALSE);
+	ui->label_xdg_mimeinfonew->setVisible(FALSE); ui->line_xdg_mimeinfonew->setVisible(FALSE);
 
   }else if(ui->radio_xdg_mime->isChecked()){
     //update the files available
@@ -673,37 +686,49 @@
 	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_icon->setVisible(FALSE); ui->list_xdg_icon->setVisible(FALSE);
-	ui->label_xdg_menu->setVisible(FALSE); ui->list_xdg_menu->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);
 	ui->check_xdg_terminal->setVisible(FALSE);
 	ui->push_xdg_addmime->setVisible(FALSE);
 	ui->label_xdg_mimepatterns->setVisible(TRUE); ui->line_xdg_mimepatterns->setVisible(TRUE);
+	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_iconnew->setVisible(FALSE); ui->list_xdg_iconnew->setVisible(FALSE);
-	ui->label_xdg_menunew->setVisible(FALSE); ui->list_xdg_menunew->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);
 	ui->check_xdg_terminalnew->setVisible(FALSE);
 	ui->push_xdg_addmimenew->setVisible(FALSE);
 	ui->label_xdg_mimepatternsnew->setVisible(TRUE); ui->line_xdg_mimepatternsnew->setVisible(TRUE);
+	ui->label_xdg_mimeinfonew->setVisible(TRUE); ui->line_xdg_mimeinfonew->setVisible(TRUE);
 	  
   }
+  //Select the first file in the list if one is available
+  if( ui->list_xdg_files->count() > 0){ ui->list_xdg_files->setCurrentRow(0); }
+  //Update the program icon list for new entries
+  QStringList icons = currentModule->currentIcons;
+  ui->list_xdg_iconnew->clear();
+  for(int i=0; i<icons.length(); i++){
+    ui->list_xdg_iconnew->addItem(QIcon(currentModule->path()+"/resources/"+icons[i]),icons[i]);
+  }	    
   //Now update read the currently selected file
   slotXdgFileChanged();
 }
 
-void MainGUI::slotXdgFileChanged(){
-  qDebug() <<"XDG file changed";	
+void MainGUI::slotXdgFileChanged(){	
   if(ui->list_xdg_files->currentRow() == -1){ return; }
+  //Make sure the proper tab is visible
+  ui->tabWidget_xdg->setCurrentIndex(0); //show the "current entry" tab
+  //Clear the icon list
+  ui->list_xdg_icon->clear();
   //Get the selected file
   QString file = ui->list_xdg_files->currentItem()->text();
   if(file.isEmpty()){
     //Clear the UI lines
     ui->line_xdg_name->clear();
     ui->line_xdg_exec->clear();
-    ui->list_xdg_icon->clear();
-    ui->list_xdg_menu->clear();
+    ui->line_xdg_menu->clear();
     ui->line_xdg_mimetype->clear();
     ui->line_xdg_mimepatterns->clear();
     //Now return
@@ -718,13 +743,27 @@
     ui->line_xdg_exec->setText( currentModule->readValue("desktopexec") ); 
     ui->line_xdg_mimetype->setText( currentModule->readValue("desktopmimetype") );
     //comboboxes
-    QString text = currentModule->readValue("desktopicon");
-    int index = ui->list_xdg_icon->findText( text );
-    if(index == -1){ 
-      ui->list_xdg_icon->addItem(text);
-      index = ui->list_xdg_icon->findText( text ); //reset the index value
+    QStringList icons = currentModule->currentIcons;
+    if(icons.length() > 0){
+      for(int i=0; i<icons.length(); i++){
+        ui->list_xdg_icon->addItem(QIcon(currentModule->path()+"/resources/"+icons[i]),icons[i]);
+      }	    
+      int cicon = icons.indexOf(currentModule->readValue("desktopicon"));
+      if( cicon == -1 ){ 
+	      ui->list_xdg_icon->addItem(currentModule->readValue("desktopicon")); 
+	      cicon = icons.indexOf(currentModule->readValue("desktopicon"));
+      }
+      ui->list_xdg_icon->setCurrentIndex(cicon);
+    }else{
+      ui->list_xdg_icon->addItem(currentModule->readValue("desktopicon"));
     }
-    ui->list_xdg_icon->setCurrentIndex( index );	  
+    //Checkboxes
+    QString chk = currentModule->readValue("desktopterminal").toLower();
+    if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_terminal->setChecked(TRUE); }
+    else{ ui->check_xdg_terminal->setChecked(FALSE); }
+    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
@@ -733,22 +772,69 @@
     ui->line_xdg_name->setText( currentModule->readValue("menuname") );
     ui->line_xdg_exec->setText( currentModule->readValue("menuexec") ); 
     ui->line_xdg_mimetype->setText( currentModule->readValue("menumimetype") );
+    ui->line_xdg_menu->setText( currentModule->readValue("menucategories") );
     //comboboxes
-    QString text = currentModule->readValue("menuicon");
-    int index = ui->list_xdg_icon->findText( text );
-    if(index == -1){ 
-      ui->list_xdg_icon->addItem(text);
-      index = ui->list_xdg_icon->findText( text ); //reset the index value
+	  //icons
+    QStringList icons = currentModule->currentIcons;
+    if(icons.length() > 0){
+      for(int i=0; i<icons.length(); i++){
+        ui->list_xdg_icon->addItem(QIcon(currentModule->path()+"/resources/"+icons[i]),icons[i]);
+      }	    
+      int cicon = icons.indexOf(currentModule->readValue("menuicon"));
+      if( cicon == -1 ){ 
+	      ui->list_xdg_icon->addItem(currentModule->readValue("menuicon")); 
+	      cicon = icons.indexOf(currentModule->readValue("menuicon"));
+      }
+      ui->list_xdg_icon->setCurrentIndex(cicon);
+    }else{
+      ui->list_xdg_icon->addItem(currentModule->readValue("menuicon"));
     }
-    ui->list_xdg_icon->setCurrentIndex( index );
-    index = ui->list_xdg_menu->findText(currentModule->readValue("menucategories") );
-    if(index == -1){ index = 0; }
-    ui->list_xdg_menu->setCurrentIndex(index);
+    //Checkboxes
+    QString chk = currentModule->readValue("menuterminal").toLower();
+    if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_terminal->setChecked(TRUE); }
+    else{ ui->check_xdg_terminal->setChecked(FALSE); }
+    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);
+    //update the file info on the GUI
+    ui->line_xdg_mimetype->setText( currentModule->readValue("mimetype") );
+    ui->line_xdg_mimeinfo->setText( currentModule->readValue("mimeinfo") ); 
+    ui->line_xdg_mimepatterns->setText( currentModule->readValue("mimepatterns") ); 
   }else{
 	  
   }
 }
 
+void MainGUI::slotAddMenuCat(QAction* act){
+  //get the selected menu category
+  QString newcat = act->text();
+  //Read the current categories
+  QStringList oldcats = ui->line_xdg_menu->text().split(";", QString::SkipEmptyParts);
+  for(int i=0; i<oldcats.length(); i++){
+    oldcats[i] = oldcats[i].simplified();
+    if(oldcats[i] == newcat){return;} //category already in the list, do nothing
+  }
+  //Add the item
+  oldcats << newcat;
+  //Now replace the line onto the GUI
+  ui->line_xdg_menu->setText(oldcats.join("; "));
+}
+
+void MainGUI::slotAddMenuCatNew(QAction* act){
+  //get the selected menu category
+  QString newcat = act->text();
+  //Read the current categories
+  QStringList oldcats = ui->line_xdg_menunew->text().split(";", QString::SkipEmptyParts);
+  for(int i=0; i<oldcats.length(); i++){
+    oldcats[i] = oldcats[i].simplified();
+    if(oldcats[i] == newcat){return;} //category already in the list, do nothing
+  }
+  //Add the item
+  oldcats << newcat;
+  //Now replace the line onto the GUI
+  ui->line_xdg_menunew->setText(oldcats.join("; "));
+}

Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h	2012-10-30 17:56:03 UTC (rev 20089)
+++ users/ken/EasyPBI2/mainGUI.h	2012-10-30 19:55:47 UTC (rev 20090)
@@ -57,17 +57,18 @@
     //XDG functions
     void slotXdgTypeChanged();
     void slotXdgFileChanged();
+    void slotAddMenuCat(QAction*);
+    void slotAddMenuCatNew(QAction*);
 
 private:
     Ui::MainGUI *ui;
     ModBuild *currentModule;
     QLineEdit *line_module;
     QRadioButton *radio_module_port, *radio_module_local;
-    QMenu menu_addOpt, menu_binList, menu_elOpts;
+    QMenu menu_addOpt, menu_binList, menu_elOpts, menu_validMenuCats, menu_validMenuCatsNew;
 
     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;
-    QStringList VALID_MENU_CATS;
     bool PBI_BUILD_TERMINATED;
     QProcess *p;
 

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



More information about the Commits mailing list