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

svn at pcbsd.org svn at pcbsd.org
Thu Oct 18 18:55:03 PDT 2012


Author: kenmoore
Date: 2012-10-19 01:55:03 +0000 (Fri, 19 Oct 2012)
New Revision: 19771

Modified:
   users/ken/EasyPBI2/backend.cpp
   users/ken/EasyPBI2/backend.h
   users/ken/EasyPBI2/mainGUI.cpp
   users/ken/EasyPBI2/mainGUI.h
   users/ken/EasyPBI2/mainGUI.ui
   users/ken/EasyPBI2/modBuild.cpp
   users/ken/EasyPBI2/modBuild.h
Log:
Keep working on EasyPBI. Specifically the pbi.conf and resources editor have been nearly finished.



Modified: users/ken/EasyPBI2/backend.cpp
===================================================================
--- users/ken/EasyPBI2/backend.cpp	2012-10-18 20:56:11 UTC (rev 19770)
+++ users/ken/EasyPBI2/backend.cpp	2012-10-19 01:55:03 UTC (rev 19771)
@@ -105,3 +105,20 @@
     qDebug() << " - Paths searched:" << paths;
   }
 }
+
+QString Backend::findPortsDir(){
+    QString ret;
+    QStringList portsLocations;
+    //Set the locations to search for the ports tree
+    portsLocations << "/usr/ports" << QDir::homePath() +"/EasyPBI/ports";
+    //Search the locations
+    for(int i=0; i<portsLocations.size(); i++){
+      if( QDir(portsLocations[i]).exists() ){
+        if( QFile::exists(portsLocations[i]+"/COPYRIGHT") ){
+	  ret=portsLocations[i];
+	}
+      }
+    }
+    //now return the findings;
+    return ret;
+}

Modified: users/ken/EasyPBI2/backend.h
===================================================================
--- users/ken/EasyPBI2/backend.h	2012-10-18 20:56:11 UTC (rev 19770)
+++ users/ken/EasyPBI2/backend.h	2012-10-19 01:55:03 UTC (rev 19771)
@@ -23,6 +23,7 @@
   static void openPortInfo(QString);
   static QIcon icon(QString);
   static void findExternalCommands(QString*,QString*,QString*);
+  static QString findPortsDir();
 
 };
 

Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-10-18 20:56:11 UTC (rev 19770)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-10-19 01:55:03 UTC (rev 19771)
@@ -162,16 +162,24 @@
   
   //Scan for the external utilities needed to build PBI's
   Backend::findExternalCommands(&SU_CMD, &PBIBUILD_CMD, &PBICREATE_CMD);
+  //Determine if the FreeBSD ports tree is available
+  PORTS_DIR = Backend::findPortsDir();
   //Set a couple more internal flags
   PBI_BUILDING_NOW.clear();
   PBI_BUILD_TERMINATED=FALSE;
 }
 
+bool MainGUI::CheckForPorts(){
+  bool ok=FALSE;
+  if( !PORTS_DIR.isEmpty()  && QFile::exists(PORTS_DIR) ){ ok = TRUE; }
+  return ok;
+}
+
 void MainGUI::refreshGUI(QString item){
   //Enable/disable the interface appropriately
   
   //Stupid check to make sure that a module is actually loaded
-  if( line_module->text().isEmpty() ){ 
+  if( currentModule->path().isEmpty() ){ 
     if(PBI_BUILDING_NOW.isEmpty() ){ui->toolBox->setEnabled(FALSE); return; }
     else{ 
       ui->toolBox->setItemEnabled(0,FALSE);
@@ -204,7 +212,8 @@
     }
     //Display the variables from the currentModule structure
     // -- check boxes
-    if(currentModule->readValue("requiresroot").toLower() == "true"){ ui->check_requiresroot->setChecked(TRUE); }
+    QString chk = currentModule->readValue("requiresroot").toLower();
+    if( (chk=="true") || (chk=="yes") ){ ui->check_requiresroot->setChecked(TRUE); }
     else{ ui->check_requiresroot->setChecked(FALSE); }
     // -- line edits
     ui->line_progname->setText(currentModule->readValue("progname"));
@@ -221,7 +230,7 @@
     QStringList icons = currentModule->currentIcons;
     if(icons.length() > 0){
       for(int i=0; i<icons.length(); i++){
-        ui->list_progicon->addItem(QIcon(line_module->text()+"/resources/"+icons[i]),icons[i]);
+        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); }
@@ -337,14 +346,12 @@
 }
 
 void MainGUI::on_actionLoad_Module_triggered(){
-  qDebug() << "Load Module triggered";
   QString modSel = QFileDialog::getExistingDirectory(this, tr("Select Module"), MODOUT_DIR);
-  //QString modSel = MODOUT_DIR+"/agame";
-  qDebug() << "done with dialog";
   if(modSel.isEmpty()){return;} //action cancelled or closed
   bool ok = currentModule->loadModule(modSel);
   if(ok){ 
-    line_module->setText(modSel); 
+    qDebug() << "Loaded module:"<<modSel;	  
+    line_module->setText(modSel.replace(QDir::homePath(),"~")); 
     if(currentModule->isLocalPBI){ radio_module_local->toggle(); }
     else{ radio_module_port->toggle(); }
     refreshGUI("all");
@@ -370,6 +377,57 @@
   }	  
 }
 
+void MainGUI::on_push_change_makeport_clicked(){
+  if( !CheckForPorts() ){
+    //No ports tree available
+    QMessageBox::warning(this,tr("EasyPBI: No FreeBSD Ports"), tr("The FreeBSD Ports tree could not be found on your system. You may fetch the ports tree through the EasyPBI menu or manually set the path to the port tree in the EasyPBI preferences if it is installed in a non-standard location."));
+  }
+  //Prompt for a new port
+  QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), PORTS_DIR);
+  if(portSel.isEmpty()){return;} //action cancelled or closed	
+  //Check if the port is valid
+  qDebug() << "Still need to add a check for port validity in on_push_change_makeport_clicked()";
+  //Save the port info to the GUI
+  ui->line_makeport->setText(portSel.remove(PORTS_DIR));
+}
+
+void MainGUI::on_push_config_save_clicked(){
+  //Save the current settings to the backend structures
+    //global settings for all modules
+    currentModule->writeValue("progname",ui->line_progname->text());
+    currentModule->writeValue("progweb",ui->line_progweb->text());
+    currentModule->writeValue("progauthor",ui->line_progauthor->text());
+    currentModule->writeValue("progicon",ui->list_progicon->currentText());
+    if(ui->check_requiresroot->isChecked()){ currentModule->writeValue("requiresroot", "true"); }
+    else{ currentModule->writeValue("requiresroot","false"); }
+    //Module-dependant settings
+    if( radio_module_port->isChecked() ){ //FreeBSD port module
+	currentModule->writeValue("makeport",ui->line_makeport->text());
+	currentModule->writeValue("makeoptions",ui->line_makeopts->text());
+	QString tmp;
+	for(int i=0; i < ui->list_portbefore->count(); i++){
+	  tmp.append(" "+ui->list_portbefore->itemText(i) );
+	}
+	currentModule->writeValue("makeportbefore",tmp.simplified());
+	tmp.clear();
+	for(int i=0; i < ui->list_portafter->count(); i++){
+	  tmp.append(" "+ui->list_portafter->itemText(i) );
+	}
+	currentModule->writeValue("makeportafter",tmp.simplified());
+	
+    }else{ //local sources module
+	currentModule->writeValue("packagedir",ui->line_progdir->text());
+	currentModule->writeValue("progversion",ui->line_progversion->text());
+    }
+  //save the new settings to pbi.conf
+  bool ok = currentModule->writePBIconf();
+  if(!ok){
+    //Display a warning that the file could not be saved
+    qDebug() << "Error: pbi.conf could not be written:" << currentModule->path()+"/pbi.conf";
+    QMessageBox::warning(this,tr("EasyPBI Error"), tr("The PBI configuration file could not be saved. Please check your file permissions before trying again."));
+  }
+}
+
 void MainGUI::slotResourceChanged(){
   //Get the current file selected
   QString cfile;
@@ -382,7 +440,7 @@
     ui->label_resources_icon->setVisible(FALSE);
 	  
   }else{ //item selected
-    QString path = line_module->text() + "/resources/";
+    QString path = currentModule->path() + "/resources/";
     if( cfile.endsWith(".png") || cfile.endsWith(".jpg") ){
       //Image file, show full size
       QPixmap img(path+cfile);
@@ -413,7 +471,7 @@
   QString cfile;
   if(ui->listw_resources->currentRow() != -1){ cfile = ui->listw_resources->currentItem()->text(); }
   if(cfile.isEmpty()){ return; } // do nothing if no file selected
-  QString filePath = line_module->text() + "/resources/" + cfile;
+  QString filePath = currentModule->path() + "/resources/" + cfile;
   //Read the current text for the resource
   QStringList contents = ui->text_resources_script->toPlainText().split("\n");
   //overwrite the resource with the new contents

Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h	2012-10-18 20:56:11 UTC (rev 19770)
+++ users/ken/EasyPBI2/mainGUI.h	2012-10-19 01:55:03 UTC (rev 19771)
@@ -31,12 +31,19 @@
 
 
 private slots:
+    //general purpose functions
     void slotSingleInstance();
     void refreshGUI(QString);
+    //menubar functions
     void on_actionExit_triggered();
     void on_actionNew_Module_triggered();
     void on_actionLoad_Module_triggered();
+    //editor functions
     void slotModTabChanged(int);
+    //pbi.conf functions
+    void on_push_change_makeport_clicked();
+    void on_push_config_save_clicked();
+    //resources functions
     void slotResourceChanged();
     void slotResourceScriptSaved();
 
@@ -53,8 +60,8 @@
     QProcess *p;
 
     void SetupDefaults();
+    bool CheckForPorts();
 
-
 };
 
 #endif // MAINGUI_H

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

Modified: users/ken/EasyPBI2/modBuild.cpp
===================================================================
--- users/ken/EasyPBI2/modBuild.cpp	2012-10-18 20:56:11 UTC (rev 19770)
+++ users/ken/EasyPBI2/modBuild.cpp	2012-10-19 01:55:03 UTC (rev 19771)
@@ -252,11 +252,11 @@
   }
   // -- Server & Other Info
   contents << "# -- Require Root Permissions to Install PBI --";
-  contents << "PBI_REQUIRESROOT=\""+serverStruct[0].remove("\"")+"\"\n";
+  contents << "PBI_REQUIRESROOT=\""+checkYesNo(serverStruct[0].remove("\""))+"\"";
   contents << "# -- Auto-build Configuration Options --";
   contents << "PBI_BUILDKEY=\""+serverStruct[1].remove("\"")+"\"";
   contents << "PBI_AB_PRIORITY=\""+serverStruct[2].remove("\"")+"\"";
-  contents << "PBI_AB_NOTMPFS=\""+serverStruct[3].remove("\"")+"\"\n";
+  contents << "PBI_AB_NOTMPFS=\""+checkYesNo(serverStruct[3].remove("\""))+"\"\n";
   exportLine.append(" PBI_REQUIRESROOT PBI_BUILDKEY PBI_AB_PRIORITY PBI_NOTMPFS");
   // --Export all the variables used
   contents << exportLine;
@@ -1173,3 +1173,10 @@
   //Return the result status
   return success;
 }
+
+QString ModBuild::checkYesNo(QString chk){
+  QString ret = "NO";
+  chk = chk.toLower();
+  if( (chk=="true") || (chk=="yes") ){ ret = "YES"; }
+  return ret;
+}

Modified: users/ken/EasyPBI2/modBuild.h
===================================================================
--- users/ken/EasyPBI2/modBuild.h	2012-10-18 20:56:11 UTC (rev 19770)
+++ users/ken/EasyPBI2/modBuild.h	2012-10-19 01:55:03 UTC (rev 19771)
@@ -22,6 +22,7 @@
   int readMakeFile(QString);
   static bool emptyDirectory(QString);
   QString getFilenameFromPath(QString);
+  QString checkYesNo(QString);
 
 public:
   ModBuild(QWidget* parent =0);
@@ -58,6 +59,7 @@
   bool addResource(QString, QString);
   bool removeResource(QString);
    //General purpose functions
+  QString path(){ return modulePath; } //get the current module path
   QString readValue(QString); //get a variable from the module
   bool writeValue(QString,QString); //set a variable in the module
   QStringList filesAvailable(QString); //get the available files per category



More information about the Commits mailing list