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

svn at pcbsd.org svn at pcbsd.org
Wed Oct 31 10:21:31 PDT 2012


Author: kenmoore
Date: 2012-10-31 17:21:31 +0000 (Wed, 31 Oct 2012)
New Revision: 20094

Modified:
   users/ken/EasyPBI2/mainGUI.cpp
   users/ken/EasyPBI2/mainGUI.h
   users/ken/EasyPBI2/modBuild.cpp
Log:
Finish up the XDG tab for EasyPBI2, almost done with the module editor in its entirety



Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-10-31 14:51:19 UTC (rev 20093)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-10-31 17:21:31 UTC (rev 20094)
@@ -909,3 +909,145 @@
   //replace the current executable with the new one
   ui->line_xdg_execnew->setText( act->text().section("/",-1) );	
 }
+
+void MainGUI::on_push_xdg_remove_clicked(){
+  //Figure out if a file is selected
+  if( ui->list_xdg_files->currentItem()->text().isEmpty() ){ return; }
+  //Now remove the file
+  bool ok = FALSE;
+  if( ui->radio_xdg_desktop->isChecked() ){
+    ok = currentModule->removeDesktop();
+  }else if( ui->radio_xdg_menu->isChecked() ){
+    ok = currentModule->removeMenu();
+  }else if( ui->radio_xdg_mime->isChecked() ){
+    ok = currentModule->removeMime();
+  }
+  //Now inform the user if there was an error
+  if(!ok){
+    QMessageBox::warning(this, tr("EasyPBI Error"), tr("Could not remove the XDG entry.")+"\n"+tr("Check the file permissions and try again") );
+  }
+  //Now refresh the GUI
+  refreshGUI("xdg");
+  
+}
+
+void MainGUI::on_push_xdg_savechanges_clicked(){
+  //save the current UI settings to the module structure then save the file
+  bool ok = FALSE;
+  if( ui->radio_xdg_desktop->isChecked() ){
+    currentModule->writeValue("desktopname",ui->line_xdg_name->text());
+    currentModule->writeValue("desktopgenericname",ui->line_xdg_name->text().toLower());
+    currentModule->writeValue("desktopexec",ui->line_xdg_exec->text());
+    currentModule->writeValue("desktopicon",ui->list_xdg_icon->currentText());
+    currentModule->writeValue("desktopmimetype",ui->line_xdg_mimetype->text());
+    QString checked = "false";
+    if(ui->check_xdg_terminal->isChecked()){ checked="true"; }
+    currentModule->writeValue("desktopterminal",checked);
+    checked = "false";
+    if(ui->check_xdg_nodisplay->isChecked()){ checked="true"; }
+    currentModule->writeValue("desktopnodisplay",checked);
+    //Now save the file
+    ok = currentModule->writeDesktop();
+    
+  }else if( ui->radio_xdg_menu->isChecked() ){
+    currentModule->writeValue("menuname",ui->line_xdg_name->text());
+    currentModule->writeValue("menugenericname",ui->line_xdg_name->text().toLower());
+    currentModule->writeValue("menuexec",ui->line_xdg_exec->text());
+    currentModule->writeValue("menuicon",ui->list_xdg_icon->currentText());
+    currentModule->writeValue("menumimetype",ui->line_xdg_mimetype->text());
+    currentModule->writeValue("menucategories", ui->line_xdg_menu->text());
+    QString checked = "false";
+    if(ui->check_xdg_terminal->isChecked()){ checked="true"; }
+    currentModule->writeValue("menuterminal",checked);
+    checked = "false";
+    if(ui->check_xdg_nodisplay->isChecked()){ checked="true"; }
+    currentModule->writeValue("menunodisplay",checked);
+    //Now save the file
+    ok = currentModule->writeMenu();    
+  }else if( ui->radio_xdg_mime->isChecked() ){
+    currentModule->writeValue("mimetype",ui->line_xdg_mimetype->text());
+    currentModule->writeValue("mimeinfo",ui->line_xdg_mimeinfo->text());
+    currentModule->writeValue("mimepatterns",ui->line_xdg_mimepatterns->text());
+    //Now save the file
+    ok = currentModule->writeMime();
+  }
+  //Now inform the user if there was an error
+  if(!ok){
+    QMessageBox::warning(this, tr("EasyPBI Error"), tr("Could not save the changes to the XDG entry.")+"\n"+tr("Check the file permissions and try again") );
+  }
+  //Now refresh the GUI
+  refreshGUI("xdg");
+}
+
+void MainGUI::on_push_xdg_savenew_clicked(){
+  //Get the filename we want to save
+  QString filename;
+  //Now check that the filename does not already exist
+  QStringList cFiles;
+  if(ui->radio_xdg_desktop->isChecked() ){
+    filename = ui->line_xdg_execnew->text();
+    cFiles = currentModule->filesAvailable("xdg-desktop").replaceInStrings(".desktop","");
+  }else if(ui->radio_xdg_menu->isChecked() ){
+    filename = ui->line_xdg_execnew->text();
+    cFiles = currentModule->filesAvailable("xdg-menu").replaceInStrings(".desktop","");
+  }else if(ui->radio_xdg_mime->isChecked() ){
+    filename = ui->line_xdg_mimetypenew->text().section("/",-1);
+    cFiles = currentModule->filesAvailable("xdg-mime").replaceInStrings(".xml","");
+  }
+  if(filename.isEmpty()){ return;}
+  
+  if(cFiles.indexOf(filename) != -1){
+    int num = 1;
+    while(cFiles.indexOf(filename+QString::number(num)) != -1){ num++; }
+    filename.append( QString::number(num) );
+  }
+  //save the current UI settings to the module structure then save the file
+  bool ok = FALSE;
+  if( ui->radio_xdg_desktop->isChecked() ){
+    currentModule->loadDesktop(filename+".desktop"); //get the new file ready
+    currentModule->writeValue("desktopname",ui->line_xdg_namenew->text());
+    currentModule->writeValue("desktopgenericname",ui->line_xdg_namenew->text().toLower());
+    currentModule->writeValue("desktopexec",ui->line_xdg_execnew->text());
+    currentModule->writeValue("desktopicon",ui->list_xdg_iconnew->currentText());
+    currentModule->writeValue("desktopmimetype",ui->line_xdg_mimetypenew->text());
+    QString checked = "false";
+    if(ui->check_xdg_terminalnew->isChecked()){ checked="true"; }
+    currentModule->writeValue("desktopterminal",checked);
+    checked = "false";
+    if(ui->check_xdg_nodisplaynew->isChecked()){ checked="true"; }
+    currentModule->writeValue("desktopnodisplay",checked);
+    //Now save the file
+    ok = currentModule->writeDesktop();
+    
+  }else if( ui->radio_xdg_menu->isChecked() ){
+    currentModule->loadMenu(filename+".desktop"); //get the new file ready
+    currentModule->writeValue("menuname",ui->line_xdg_namenew->text());
+    currentModule->writeValue("menugenericname",ui->line_xdg_namenew->text().toLower());
+    currentModule->writeValue("menuexec",ui->line_xdg_execnew->text());
+    currentModule->writeValue("menuicon",ui->list_xdg_iconnew->currentText());
+    currentModule->writeValue("menumimetype",ui->line_xdg_mimetypenew->text());
+    currentModule->writeValue("menucategories", ui->line_xdg_menunew->text());
+    QString checked = "false";
+    if(ui->check_xdg_terminalnew->isChecked()){ checked="true"; }
+    currentModule->writeValue("menuterminal",checked);
+    checked = "false";
+    if(ui->check_xdg_nodisplaynew->isChecked()){ checked="true"; }
+    currentModule->writeValue("menunodisplay",checked);
+    //Now save the file
+    ok = currentModule->writeMenu();    
+  }else if( ui->radio_xdg_mime->isChecked() ){
+    currentModule->loadMime(filename+".xml"); //get the new file ready
+    currentModule->writeValue("mimetype",ui->line_xdg_mimetypenew->text());
+    currentModule->writeValue("mimeinfo",ui->line_xdg_mimeinfonew->text());
+    currentModule->writeValue("mimepatterns",ui->line_xdg_mimepatternsnew->text());
+    //Now save the file
+    ok = currentModule->writeMime();
+  }
+  //Now inform the user if there was an error
+  if(!ok){
+    QMessageBox::warning(this, tr("EasyPBI Error"), tr("Could not save the changes to the XDG entry.")+"\n"+tr("Check the file permissions and try again") );
+  }
+  //Now refresh the GUI
+  refreshGUI("xdg");
+}
+

Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h	2012-10-31 14:51:19 UTC (rev 20093)
+++ users/ken/EasyPBI2/mainGUI.h	2012-10-31 17:21:31 UTC (rev 20094)
@@ -63,6 +63,9 @@
     void slotAddMimeTypeNew(QAction*);
     void slotAddBin(QAction*);
     void slotAddBinNew(QAction*);
+    void on_push_xdg_remove_clicked();
+    void on_push_xdg_savechanges_clicked();
+    void on_push_xdg_savenew_clicked();
 
 
 private:

Modified: users/ken/EasyPBI2/modBuild.cpp
===================================================================
--- users/ken/EasyPBI2/modBuild.cpp	2012-10-31 14:51:19 UTC (rev 20093)
+++ users/ken/EasyPBI2/modBuild.cpp	2012-10-31 17:21:31 UTC (rev 20094)
@@ -441,17 +441,17 @@
   contents << "GenericName="+menuStruct[1];
   contents << "Exec=%%PBI_EXEDIR%%/"+getFilenameFromPath(menuStruct[2]);
   contents << "Path=%%PBI_APPDIR%%";
-  contents << "Icon=%%PBI_APPDIR%%/"+getFilenameFromPath(menuStruct[4]);
+  contents << "Icon=%%PBI_APPDIR%%/"+getFilenameFromPath(menuStruct[3]);
   contents << "StartupNotify=true";
-  if(menuStruct[5].toLower()=="yes" || menuStruct[5].toLower()=="true"){
+  if(menuStruct[4].toLower()=="yes" || menuStruct[4].toLower()=="true"){
     contents << "NoDisplay=true";
   }
-  if(menuStruct[6].toLower()=="yes" || menuStruct[6].toLower()=="true"){
+  if(menuStruct[5].toLower()=="yes" || menuStruct[5].toLower()=="true"){
     contents << "Terminal=true";
   }
-  contents << "Categories="+menuStruct[7];
-  if(!menuStruct[8].isEmpty()){
-    contents << "MimeType="+menuStruct[8];
+  contents << "Categories="+menuStruct[6];
+  if(!menuStruct[7].isEmpty()){
+    contents << "MimeType="+menuStruct[7];
   }
   //Save the contents to the file
   bool status;
@@ -532,7 +532,7 @@
   if(desktopStruct[4].toLower()=="yes" || desktopStruct[4].toLower()=="true"){
     contents << "NoDisplay=true";
   }
-  if(desktopStruct[5].toLower()=="yes" || menuStruct[5].toLower()=="true"){
+  if(desktopStruct[5].toLower()=="yes" || desktopStruct[5].toLower()=="true"){
     contents << "Terminal=true";
   }
   if(!desktopStruct[6].isEmpty()){
@@ -594,7 +594,7 @@
   //Stupid check to make sure there is actually file patterns to be saved
   if(mimeStruct[2].isEmpty()){ return FALSE; }
   //Get the path to the file
-  QString fileName = modulePath + "/xdg-menu/" + saveMimeFile;
+  QString fileName = modulePath + "/xdg-mime/" + saveMimeFile;
   //Set a default mime-info if none given  
   if(mimeStruct[0].isEmpty()){
     mimeStruct[0] = "http://www.freedesktop.org/standards/shared-mime-info";
@@ -911,44 +911,44 @@
   QString val;
   QString var = variable.toLower();
   if(var=="progname"){ val = progStruct[0] ;}
-  else if(variable=="progweb"){ val = progStruct[1]; }
-  else if(variable=="progauthor"){ val = progStruct[2]; }
-  else if(variable=="progicon"){ val = progStruct[3]; }
-  else if(variable=="progversion"){ val = progStruct[4]; }
-  else if(variable=="packagedir"){ val = progStruct[5]; }
-  else if(variable=="makeport"){ val = mkStruct[0]; }
-  else if(variable=="makeportbefore"){ val = mkStruct[1]; }
-  else if(variable=="makeportafter"){ val = mkStruct[2]; }
-  else if(variable=="makeoptions"){ val = mkStruct[3]; }
-  else if(variable=="requiresroot"){ val = serverStruct[0]; }
-  else if(variable=="buildkey"){ val = serverStruct[1]; }
-  else if(variable=="priority"){ val = serverStruct[2]; }
-  else if(variable=="notmpfs"){ val = serverStruct[3]; }
-  else if(variable=="menuname"){ val = menuStruct[0]; }
-  else if(variable=="menugenericname"){ val = menuStruct[1]; }
-  else if(variable=="menuexec"){ val = menuStruct[2]; }
-  else if(variable=="menuicon"){ val = menuStruct[3]; }
-  else if(variable=="menunodisplay"){ val = menuStruct[4] ;}
-  else if(variable=="menuterminal"){ val = menuStruct[5]; }
-  else if(variable=="menucategories"){ val = menuStruct[6]; }
-  else if(variable=="menumimetype"){ val = menuStruct[7]; }
-  else if(variable=="desktopname"){ val = desktopStruct[0]; }
-  else if(variable=="desktopgenericname"){ val = desktopStruct[1]; }
-  else if(variable=="desktopexec"){ val = desktopStruct[2]; }
-  else if(variable=="desktopicon"){ val = desktopStruct[3]; }
-  else if(variable=="desktopnodisplay"){ val = desktopStruct[4]; }
-  else if(variable=="desktopterminal"){ val = desktopStruct[5]; }
-  else if(variable=="desktopmimetype"){ val = desktopStruct[6]; }
-  else if(variable=="mimeinfo"){ val = mimeStruct[0]; }
-  else if(variable=="mimetype"){ val = mimeStruct[1]; }
-  else if(variable=="mimepatterns"){ val = mimeStruct[2]; }
-  else if(variable=="portname"){ val = portStruct[0]; }
-  else if(variable=="portauthor"){ val = portStruct[1]; }
-  else if(variable=="portwebsite"){ val = portStruct[2]; }
-  else if(variable=="portoptions"){ val = portStruct[3]; }
-  else if(variable=="portbinaries"){ val = portStruct[4]; }
-  else if(variable=="portmenucategory"){ val = portStruct[5]; }
-  else if(variable=="portisgraphical"){ val = portStruct[6]; }
+  else if(var=="progweb"){ val = progStruct[1]; }
+  else if(var=="progauthor"){ val = progStruct[2]; }
+  else if(var=="progicon"){ val = progStruct[3]; }
+  else if(var=="progversion"){ val = progStruct[4]; }
+  else if(var=="packagedir"){ val = progStruct[5]; }
+  else if(var=="makeport"){ val = mkStruct[0]; }
+  else if(var=="makeportbefore"){ val = mkStruct[1]; }
+  else if(var=="makeportafter"){ val = mkStruct[2]; }
+  else if(var=="makeoptions"){ val = mkStruct[3]; }
+  else if(var=="requiresroot"){ val = serverStruct[0]; }
+  else if(var=="buildkey"){ val = serverStruct[1]; }
+  else if(var=="priority"){ val = serverStruct[2]; }
+  else if(var=="notmpfs"){ val = serverStruct[3]; }
+  else if(var=="menuname"){ val = menuStruct[0]; }
+  else if(var=="menugenericname"){ val = menuStruct[1]; }
+  else if(var=="menuexec"){ val = menuStruct[2]; }
+  else if(var=="menuicon"){ val = menuStruct[3]; }
+  else if(var=="menunodisplay"){ val = menuStruct[4] ;}
+  else if(var=="menuterminal"){ val = menuStruct[5]; }
+  else if(var=="menucategories"){ val = menuStruct[6]; }
+  else if(var=="menumimetype"){ val = menuStruct[7]; }
+  else if(var=="desktopname"){ val = desktopStruct[0]; }
+  else if(var=="desktopgenericname"){ val = desktopStruct[1]; }
+  else if(var=="desktopexec"){ val = desktopStruct[2]; }
+  else if(var=="desktopicon"){ val = desktopStruct[3]; }
+  else if(var=="desktopnodisplay"){ val = desktopStruct[4]; }
+  else if(var=="desktopterminal"){ val = desktopStruct[5]; }
+  else if(var=="desktopmimetype"){ val = desktopStruct[6]; }
+  else if(var=="mimeinfo"){ val = mimeStruct[0]; }
+  else if(var=="mimetype"){ val = mimeStruct[1]; }
+  else if(var=="mimepatterns"){ val = mimeStruct[2]; }
+  else if(var=="portname"){ val = portStruct[0]; }
+  else if(var=="portauthor"){ val = portStruct[1]; }
+  else if(var=="portwebsite"){ val = portStruct[2]; }
+  else if(var=="portoptions"){ val = portStruct[3]; }
+  else if(var=="portbinaries"){ val = portStruct[4]; }
+  else if(var=="portmenucategory"){ val = portStruct[5]; }
+  else if(var=="portisgraphical"){ val = portStruct[6]; }
   else{
     qDebug() << "Error: Invalid variable name to read";
   }
@@ -964,37 +964,37 @@
 //mimeStruct=[ info, type, patterns] (patterns is a " "-delimited list)
   QString var = variable.toLower();
   if(var=="progname"){ progStruct[0] = value; }
-  else if(variable=="progweb"){ progStruct[1] = value; }
-  else if(variable=="progauthor"){ progStruct[2] = value; }
-  else if(variable=="progicon"){ progStruct[3] = value; }
-  else if(variable=="progversion"){ progStruct[4] = value; }
-  else if(variable=="packagedir"){ progStruct[5] = value; }
-  else if(variable=="makeport"){ mkStruct[0] = value; }
-  else if(variable=="makeportbefore"){ mkStruct[1] = value; }
-  else if(variable=="makeportafter"){ mkStruct[2] = value; }
-  else if(variable=="makeoptions"){ mkStruct[3] = value; }
-  else if(variable=="requiresroot"){ serverStruct[0] = value; }
-  else if(variable=="buildkey"){ serverStruct[1] = value; }
-  else if(variable=="priority"){ serverStruct[2] = value; }
-  else if(variable=="notmpfs"){ serverStruct[3] = value; }
-  else if(variable=="menuname"){ menuStruct[0] = value; }
-  else if(variable=="menugenericname"){ menuStruct[1] = value; }
-  else if(variable=="menuexec"){ menuStruct[2] = value; }
-  else if(variable=="menuicon"){ menuStruct[3] = value; }
-  else if(variable=="menunodisplay"){ menuStruct[4] = value; }
-  else if(variable=="menuterminal"){ menuStruct[5] = value; }
-  else if(variable=="menucategories"){ menuStruct[6] = value; }
-  else if(variable=="menumimetype"){ menuStruct[7] = value; }
-  else if(variable=="desktopname"){ desktopStruct[0] = value; }
-  else if(variable=="desktopgenericname"){ desktopStruct[1] = value; }
-  else if(variable=="desktopexec"){ desktopStruct[2] = value; }
-  else if(variable=="desktopicon"){ desktopStruct[3] = value; }
-  else if(variable=="desktopnodisplay"){ desktopStruct[4] = value; }
-  else if(variable=="desktopterminal"){ desktopStruct[5] = value; }
-  else if(variable=="desktopmimetype"){ desktopStruct[6] = value; }
-  else if(variable=="mimeinfo"){ mimeStruct[0] = value; }
-  else if(variable=="mimetype"){ mimeStruct[1] = value; }
-  else if(variable=="mimepatterns"){ mimeStruct[2] = value; }
+  else if(var=="progweb"){ progStruct[1] = value; }
+  else if(var=="progauthor"){ progStruct[2] = value; }
+  else if(var=="progicon"){ progStruct[3] = value; }
+  else if(var=="progversion"){ progStruct[4] = value; }
+  else if(var=="packagedir"){ progStruct[5] = value; }
+  else if(var=="makeport"){ mkStruct[0] = value; }
+  else if(var=="makeportbefore"){ mkStruct[1] = value; }
+  else if(var=="makeportafter"){ mkStruct[2] = value; }
+  else if(var=="makeoptions"){ mkStruct[3] = value; }
+  else if(var=="requiresroot"){ serverStruct[0] = value; }
+  else if(var=="buildkey"){ serverStruct[1] = value; }
+  else if(var=="priority"){ serverStruct[2] = value; }
+  else if(var=="notmpfs"){ serverStruct[3] = value; }
+  else if(var=="menuname"){ menuStruct[0] = value; }
+  else if(var=="menugenericname"){ menuStruct[1] = value; }
+  else if(var=="menuexec"){ menuStruct[2] = value; }
+  else if(var=="menuicon"){ menuStruct[3] = value; }
+  else if(var=="menunodisplay"){ menuStruct[4] = value; }
+  else if(var=="menuterminal"){ menuStruct[5] = value; }
+  else if(var=="menucategories"){ menuStruct[6] = value; }
+  else if(var=="menumimetype"){ menuStruct[7] = value; }
+  else if(var=="desktopname"){ desktopStruct[0] = value; }
+  else if(var=="desktopgenericname"){ desktopStruct[1] = value; }
+  else if(var=="desktopexec"){ desktopStruct[2] = value; }
+  else if(var=="desktopicon"){ desktopStruct[3] = value; }
+  else if(var=="desktopnodisplay"){ desktopStruct[4] = value; }
+  else if(var=="desktopterminal"){ desktopStruct[5] = value; }
+  else if(var=="desktopmimetype"){ desktopStruct[6] = value; }
+  else if(var=="mimeinfo"){ mimeStruct[0] = value; }
+  else if(var=="mimetype"){ mimeStruct[1] = value; }
+  else if(var=="mimepatterns"){ mimeStruct[2] = value; }
   else{
     qDebug() << "Error: Invalid variable name to read";
     return FALSE;



More information about the Commits mailing list