[PC-BSD Commits] r19617 - users/ken/EasyPBI2
svn at pcbsd.org
svn at pcbsd.org
Mon Oct 8 15:18:15 PDT 2012
Author: kenmoore
Date: 2012-10-08 22:18:14 +0000 (Mon, 08 Oct 2012)
New Revision: 19617
Modified:
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:
Another checkpoint for easyPBI2, starting to add in the functions that connect the GUI to the backend
Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp 2012-10-08 20:47:26 UTC (rev 19616)
+++ users/ken/EasyPBI2/mainGUI.cpp 2012-10-08 22:18:14 UTC (rev 19617)
@@ -42,6 +42,8 @@
ui->push_config_save->setIcon(Backend::icon("save"));
// -- resources tab --
ui->push_resources_savewrapper->setIcon(Backend::icon("save"));
+ connect(ui->listw_resources, SIGNAL(itemSelectionChanged()), this, SLOT(slotResourceChanged()) );
+ connect(ui->push_resources_savewrapper, SIGNAL(clicked()), this, SLOT(slotResourceScriptSaved()) );
// -- XDG entries tab --
ui->push_xdg_refresh->setIcon(Backend::icon("refresh"));
ui->push_xdg_savechanges->setIcon(Backend::icon("save"));
@@ -168,8 +170,15 @@
//Enable/disable the interface appropriately
//Stupid check to make sure that a module is actually loaded
- if( line_module->text().isEmpty() ){ ui->toolBox->setEnabled(FALSE); }
- else{ ui->toolBox->setEnabled(TRUE); }
+ if( line_module->text().isEmpty() ){
+ if(PBI_BUILDING_NOW.isEmpty() ){ui->toolBox->setEnabled(FALSE); return; }
+ else{
+ ui->toolBox->setItemEnabled(0,FALSE);
+ ui->toolBox->setItemEnabled(1,TRUE);
+ ui->toolBox->setCurrentIndex(1);
+ item="pbibuild";
+ }
+ }else{ ui->toolBox->setEnabled(TRUE); }
//Figure out the type of module that is loaded
bool isport = radio_module_port->isChecked();
//See if we should refresh everything (default)
@@ -192,9 +201,50 @@
ui->list_portbefore->setVisible(FALSE); ui->push_addportbefore->setVisible(FALSE); ui->push_rmportbefore->setVisible(FALSE);ui->label_portbefore->setVisible(FALSE);
ui->list_portafter->setVisible(FALSE); ui->push_addportafter->setVisible(FALSE); ui->push_rmportafter->setVisible(FALSE); ui->label_portafter->setVisible(FALSE);
}
+ //Display the variables from the currentModule structure
+ // -- check boxes
+ if(currentModule->readValue("requiresroot").toLower() == "true"){ ui->check_requiresroot->setChecked(TRUE); }
+ else{ ui->check_requiresroot->setChecked(FALSE); }
+ // -- line edits
+ ui->line_progname->setText(currentModule->readValue("progname"));
+ ui->line_progversion->setText(currentModule->readValue("progversion"));
+ ui->line_progweb->setText(currentModule->readValue("progweb"));
+ ui->line_progauthor->setText(currentModule->readValue("progauthor"));
+ ui->line_progdir->setText(currentModule->readValue("packagedir"));
+ ui->line_makeport->setText(currentModule->readValue("makeport"));
+ ui->line_makeopts->setText(currentModule->readValue("makeoptions"));
+ // -- combo boxes (lists)
+ ui->list_portbefore->clear(); ui->list_portafter->clear(); ui->list_progicon->clear();
+ ui->list_portbefore->addItems( currentModule->readValue("makeportbefore").split(" ") );
+ ui->list_portafter->addItems( currentModule->readValue("makeportafter").split(" ") );
+ 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]);
+ }
+ int cicon = icons.indexOf(currentModule->readValue("progicon"));
+ if( cicon == -1 ){ ui->list_progicon->setCurrentIndex(0); }
+ else{ ui->list_progicon->setCurrentIndex(cicon); }
+ }else{
+ ui->list_progicon->addItem(currentModule->readValue("progicon"));
+ }
+
}
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(); }
+ 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); }
+ //Load the file into the viewers
+ slotResourceChanged();
}
if( doall || doeditor || (item == "xdg")){
bool isDesktop = ui->radio_xdg_desktop->isChecked();
@@ -277,6 +327,7 @@
}
void MainGUI::on_actionExit_triggered(){
+ qDebug() << "Close EasyPBI requested";
close();
}
@@ -286,16 +337,60 @@
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";
+ //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);
- if(currentModule->pbiType() == "local"){ radio_module_local->toggle(); }
+ if(currentModule->isLocalPBI){ radio_module_local->toggle(); }
else{ radio_module_port->toggle(); }
refreshGUI("all");
}
}
+void MainGUI::slotResourceChanged(){
+ //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);
+ ui->label_resources_description->setVisible(FALSE);
+ ui->label_resources_icon->setVisible(FALSE);
+ return;
+ }else{
+ QString path = line_module->text() + "/resources/";
+ if( cfile.endsWith(".png") || cfile.endsWith(".jpg") ){
+ //Image file, show full size
+ ui->label_resources_icon->setPixmap(QPixmap(path+cfile));
+ ui->label_resources_icon->setVisible(TRUE);
+ //hide the other widgets
+ ui->push_resources_savewrapper->setVisible(FALSE);
+ ui->text_resources_script->setVisible(FALSE);
+ }else{
+ ui->push_resources_savewrapper->setVisible(TRUE);
+ QStringList contents = ModBuild::readFile(path+cfile);
+ ui->text_resources_script->clear();
+ ui->text_resources_script->setText(contents.join("\n"));
+ ui->text_resources_script->setVisible(TRUE);
+ //hide the other widgets
+ ui->label_resources_description->setVisible(FALSE);
+ ui->label_resources_icon->setVisible(FALSE);
+ }
+ }
+
+}
+
+void MainGUI::slotResourceScriptSaved(){
+ //get the current file and path
+ 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;
+ //Read the current text for the resource
+ QStringList contents = ui->text_resources_script->toPlainText().split("\n");
+ //overwrite the resource with the new contents
+ ModBuild::createFile(filePath,contents);
+}
Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h 2012-10-08 20:47:26 UTC (rev 19616)
+++ users/ken/EasyPBI2/mainGUI.h 2012-10-08 22:18:14 UTC (rev 19617)
@@ -36,6 +36,8 @@
void on_actionExit_triggered();
void on_actionNew_Module_triggered();
void on_actionLoad_Module_triggered();
+ void slotResourceChanged();
+ void slotResourceScriptSaved();
private:
Ui::MainGUI *ui;
Modified: users/ken/EasyPBI2/mainGUI.ui
===================================================================
(Binary files differ)
Modified: users/ken/EasyPBI2/modBuild.cpp
===================================================================
--- users/ken/EasyPBI2/modBuild.cpp 2012-10-08 20:47:26 UTC (rev 19616)
+++ users/ken/EasyPBI2/modBuild.cpp 2012-10-08 22:18:14 UTC (rev 19617)
@@ -707,6 +707,28 @@
return TRUE;
}
+QStringList ModBuild::readFile(QString filePath){
+ QStringList contents;
+ //Check that the file exists first
+ if(!QFile::exists(filePath)){
+ qDebug() << "Error: file to read does not exist:" << filePath;
+ return contents;
+ }
+ //Open the file for reading
+ QFile file(filePath);
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
+ qDebug() << "Error: file could not be opened for reading:"<< filePath;
+ return contents;
+ }
+ QTextStream in(&file);
+ //Save the contents as a QStringList
+ while(!in.atEnd()){
+ contents << in.readLine();
+ }
+ //Return the contents (one entry per line)
+ return contents;
+}
+
QStringList ModBuild::filesAvailable(QString group){
QStringList fileList;
//Check to make sure that a module has been selected first
@@ -1151,9 +1173,3 @@
//Return the result status
return success;
}
-
-QString ModBuild::pbiType(){
- if(isLocalPBI){ return "local"; }
- else if(isPortPBI){ return "port"; }
- else{ return "unknown"; }
-}
\ No newline at end of file
Modified: users/ken/EasyPBI2/modBuild.h
===================================================================
--- users/ken/EasyPBI2/modBuild.h 2012-10-08 20:47:26 UTC (rev 19616)
+++ users/ken/EasyPBI2/modBuild.h 2012-10-08 22:18:14 UTC (rev 19617)
@@ -16,8 +16,6 @@
//Internal variables
QStringList progStruct, mkStruct, serverStruct, menuStruct, desktopStruct, mimeStruct, linksStruct, portStruct;
QString modulePath, saveMenuFile, saveDesktopFile, saveMimeFile, savePortDir;
- QStringList currentBins, currentMimeTypes, currentIcons;
- bool isPortPBI, isLocalPBI;
//Internal functions
bool isGoodPort(QString, bool);
QString assignPortMenuCategory(QString);
@@ -28,6 +26,10 @@
public:
ModBuild(QWidget* parent =0);
~ModBuild();
+ //Public variables
+ QStringList currentBins, currentMimeTypes, currentIcons;
+ bool isPortPBI, isLocalPBI;
+
// --Regular functions--
//Module startup functions
bool createNewModule(QString, QString, QString);
@@ -61,10 +63,10 @@
QStringList filesAvailable(QString); //get the available files per category
void compressModule(); //package the module for distribution
bool createModuleDir(); //Create/overwrite module directory structure
- QString pbiType(); //get the current PBI type the module creates (local, port, etc).
// --Static functions--
static bool createFile(QString,QStringList);
+ static QStringList readFile(QString);
QStringList getPortInfo(QString, QString, bool forceRead = FALSE);
More information about the Commits
mailing list