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

svn at pcbsd.org svn at pcbsd.org
Wed Nov 7 10:12:11 PST 2012


Author: kenmoore
Date: 2012-11-07 18:12:10 +0000 (Wed, 07 Nov 2012)
New Revision: 20131

Removed:
   users/ken/EasyPBI2/mainwindow.cpp
   users/ken/EasyPBI2/mainwindow.h
   users/ken/EasyPBI2/mainwindow.ui
Modified:
   users/ken/EasyPBI2/EasyPBI.pro
   users/ken/EasyPBI2/mainGUI.cpp
   users/ken/EasyPBI2/newModuleDialog.cpp
   users/ken/EasyPBI2/newModuleDialog.h
   users/ken/EasyPBI2/newModuleDialog.ui
Log:
Get the new module functionality for EasyPBI2 working. It supports both port and local modules, and seems to work great.



Modified: users/ken/EasyPBI2/EasyPBI.pro
===================================================================
--- users/ken/EasyPBI2/EasyPBI.pro	2012-11-07 17:24:58 UTC (rev 20130)
+++ users/ken/EasyPBI2/EasyPBI.pro	2012-11-07 18:12:10 UTC (rev 20131)
@@ -15,13 +15,16 @@
 SOURCES += main.cpp\
         mainGUI.cpp \
         modBuild.cpp \
-	backend.cpp
+	backend.cpp \
+	newModuleDialog.cpp
 
 HEADERS  += mainGUI.h \
             modBuild.h \
-	    backend.cpp
+	    backend.h \
+	    newModuleDialog.h
 
-FORMS    += mainGUI.ui
+FORMS    += mainGUI.ui \
+	    newModuleDialog.ui
 
 RESOURCES+= EasyPBI.qrc
 

Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-11-07 17:24:58 UTC (rev 20130)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-11-07 18:12:10 UTC (rev 20131)
@@ -2,7 +2,7 @@
 #include "ui_mainGUI.h"
 #include "modBuild.h"
 #include "backend.h"
-#include <QDebug>
+#include "newModuleDialog.h"
 
 MainGUI::MainGUI(QWidget *parent) :
     QMainWindow(parent),
@@ -379,7 +379,7 @@
     }
     //Check for a 64-bit system to enable the 32-bit build option
     if(isSixtyFourBitOS){ ui->check_build_32->setVisible(TRUE); }
-    else{ ui->check_build_32->setVisible(FALSE); }
+    else{ ui->check_build_32->setVisible(FALSE); ui->check_build_32->setChecked(FALSE); }
   }
 }
 /*----------------------------------
@@ -398,24 +398,48 @@
 void MainGUI::on_actionNew_Module_triggered(){
   qDebug() << "New Module triggered";
   //Create and run the new dialog
-  newModuleDialog dlg(this);
-  dlg.setModal(TRUE);
-  dlg.exec();
+  NewModuleDialog* dlg = new NewModuleDialog(this, PORTS_DIR);
+  //dlg.setModal(TRUE);
+  dlg->exec();
   //Determine if the action was cancelled
-  if( dlg.isAccepted ){
+  if( dlg->isAccepted ){
     //Now create the new module
     QString modPath, modType, modBase, oldIconPath;
-    dlg.getUserInput(&modType, &modBase, &oldIconPath);
+    modType = dlg->moduleType;
+    modBase = dlg->moduleData;
+    oldIconPath = dlg->moduleIcon;
+    modPath = MODOUT_DIR+"/"+modBase.section("/",-1).toLower();
 	  //modPath ->full path, modType->"local"or "port", modBase->makeport or packagedir
     bool ok = currentModule->createNewModule(modPath,modType,modBase);
     if(!ok){
       QMessageBox::warning(this,tr("EasyPBI: Permissions Error"), tr("Could not create PBI module. Please check the directory permissions and try again."));
     }else{
-      currentModule->addResource(oldIconPath);
+      //MODULE CREATED, NOW FILL IT APPROPRIATELY
+      //Icon
+      currentModule->addResource(FALSE, oldIconPath); //copy the icon file into the module
+      currentModule->writeValue("progicon", oldIconPath.section("/",-1) );
+      //Load Port info if appropriate
+      if(currentModule->isPortPBI){
+        radio_module_port->toggle();
+	//Use the port info if possible
+	if( !PORTS_DIR.isEmpty() ){
+	  currentModule->readPortInformation(PORTS_DIR+"/"+modBase);
+	  //Now save the detected information into the module
+	  currentModule->writeValue("progname", currentModule->readValue("portname"));
+	  currentModule->writeValue("progweb", currentModule->readValue("portwebsite"));
+	  currentModule->writeValue("progauthor", currentModule->readValue("portauthor"));
+	}
+      }else if(currentModule->isLocalPBI){
+	radio_module_local->toggle();
+	      
+      }
+      //Now let the UI reflect the new module 
+      line_module->setText( currentModule->path().replace(QDir::homePath(),"~") );      
     }
   }
   //Refresh the UI
   refreshGUI("all");
+  delete dlg;
 }
 
 void MainGUI::on_actionLoad_Module_triggered(){

Modified: users/ken/EasyPBI2/newModuleDialog.cpp
===================================================================
--- users/ken/EasyPBI2/newModuleDialog.cpp	2012-11-07 17:24:58 UTC (rev 20130)
+++ users/ken/EasyPBI2/newModuleDialog.cpp	2012-11-07 18:12:10 UTC (rev 20131)
@@ -2,32 +2,93 @@
 #include "ui_newModuleDialog.h"
 #include <QDebug>
 
-newModuleDialog::newModuleDialog(QWidget *parent) :
+NewModuleDialog::NewModuleDialog(QWidget *parent, QString portsDir) :
     QDialog(parent),
-    ui(new Ui::newModuleDialog)
+    ui(new Ui::NewModuleDialog)
 {
 	
        //Setup Initial state of GUI objects and connect signal/slots
        ui->setupUi(this);  //load the main UI from designer
        isAccepted = FALSE;
-      
+       PORTS_DIR = portsDir;
+	//Connect up the type changed slot
+       connect(ui->radio_port, SIGNAL(clicked()), this, SLOT(slotTypeChanged()) );
+       connect(ui->radio_local, SIGNAL(clicked()), this, SLOT(slotTypeChanged()) );
+	//now run the slot to properly setup the UI elements
+	slotTypeChanged();
 }
 
-newModuleDialog::~newModuleDialog(){
+NewModuleDialog::~NewModuleDialog(){
 }
 
 
-void newModuleDialog::on_buttonBox_accepted(){
+void NewModuleDialog::on_buttonBox_accepted(){
   isAccepted=TRUE;
+  //Now set the public variables
+  if(ui->radio_port->isChecked()){
+    moduleType = "port";
+    moduleData = ui->line_port->text();
+  }else if(ui->radio_local->isChecked() ){
+    moduleType="local";
+    moduleData = ui->line_sources->text();
+  }else{
+    moduleType.clear(); moduleData.clear();
+  }
+  moduleIcon = ui->line_icon->text();
+  //Now close the UI
   this->close();
 }
 
-void newModuleDialog::on_buttonBox_rejected(){
+void NewModuleDialog::on_buttonBox_rejected(){
   isAccepted=FALSE;
+  moduleType.clear();
+  moduleData.clear();
+  moduleIcon.clear();
   this->close();
 }
 
-void newModuleDialog::getUserInput(QString* modType, QString* modBase, QString* currentIconPath){
-    //Get the UI values and return them
-	
-}
\ No newline at end of file
+void NewModuleDialog::slotTypeChanged(){
+  if(ui->radio_port->isChecked()){
+    ui->label_port->setVisible(TRUE); ui->line_port->setVisible(TRUE); ui->push_port->setVisible(TRUE);
+    ui->label_sources->setVisible(FALSE); ui->line_sources->setVisible(FALSE); ui->push_sources->setVisible(FALSE);
+  }else if(ui->radio_local->isChecked()){
+    ui->label_port->setVisible(FALSE); ui->line_port->setVisible(FALSE); ui->push_port->setVisible(FALSE);
+    ui->label_sources->setVisible(TRUE); ui->line_sources->setVisible(TRUE); ui->push_sources->setVisible(TRUE);
+  }else{
+    ui->label_port->setVisible(FALSE); ui->line_port->setVisible(FALSE); ui->push_port->setVisible(FALSE);
+    ui->label_sources->setVisible(FALSE); ui->line_sources->setVisible(FALSE); ui->push_sources->setVisible(FALSE);
+  }
+  if(PORTS_DIR.isEmpty()){ ui->push_port->setEnabled(FALSE); }
+}
+
+void NewModuleDialog::on_push_port_clicked(){
+  if( PORTS_DIR.isEmpty() ){
+    //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."));
+    return;
+  }
+  //Prompt for a new port
+  QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), PORTS_DIR);
+  if(portSel.isEmpty()){return;} //action cancelled or closed	
+  else{
+    ui->line_port->setText(portSel.remove(PORTS_DIR+"/"));
+  }
+}
+
+void NewModuleDialog::on_push_sources_clicked(){
+  //Prompt for a new selection
+  QString Sel = QFileDialog::getExistingDirectory(this, tr("Select Package Directory"), QDir::homePath());
+  if(Sel.isEmpty()){return;} //action cancelled or closed	
+  else{
+    ui->line_sources->setText(Sel);
+  }
+}
+
+void NewModuleDialog::on_push_icon_clicked(){
+//Prompt for a new selection
+  QString Sel = QFileDialog::getOpenFileName(this, tr("Select PNG Icon"), QDir::homePath(), tr("PNG icon (*.png)") );
+  if(Sel.isEmpty()){return;} //action cancelled or closed	
+  else{
+    ui->line_icon->setText(Sel);
+  }
+}

Modified: users/ken/EasyPBI2/newModuleDialog.h
===================================================================
--- users/ken/EasyPBI2/newModuleDialog.h	2012-11-07 17:24:58 UTC (rev 20130)
+++ users/ken/EasyPBI2/newModuleDialog.h	2012-11-07 18:12:10 UTC (rev 20131)
@@ -1,33 +1,41 @@
-#ifndef MAINGUI_H
-#define MAINGUI_H
+#ifndef NEW_MODULE_DIALOG_H
+#define NEW_MODULE_DIALOG_H
 
 #include <QDialog>
 #include <QFileDialog>
 #include <QString>
+#include <QDir>
+#include <QMessageBox>
+#include "ui_newModuleDialog.h"
 
+
 namespace Ui {
-    class newModuleDialog;
+    class NewModuleDialog;
 }
 
-class newModuleDialog : public QDialog
+class NewModuleDialog : public QDialog
 {
     Q_OBJECT
 
 public:
-    explicit newModuleDialog(QWidget *parent = 0);
-    ~newModuleDialog();
+    explicit NewModuleDialog(QWidget *parent = 0, QString portsDir = "");
+    virtual ~NewModuleDialog();
 
     bool isAccepted;
-    void getUserInput(QString*, QString*, QString*);
+    QString moduleType, moduleIcon, moduleData, PORTS_DIR;
 
 
 private slots:
     void on_buttonBox_accepted();
     void on_buttonBox_rejected();
+    void slotTypeChanged();
+    void on_push_port_clicked();
+    void on_push_sources_clicked();
+    void on_push_icon_clicked();
 
 private:
-    Ui::newModuleDialog *ui;
+    Ui::NewModuleDialog *ui;
 
 };
 
-#endif // MAINGUI_H
+#endif

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



More information about the Commits mailing list