[PC-BSD Commits] r19988 - users/ken/EasyPBI2
svn at pcbsd.org
svn at pcbsd.org
Sat Oct 27 11:35:28 PDT 2012
Author: kenmoore
Date: 2012-10-27 18:35:28 +0000 (Sat, 27 Oct 2012)
New Revision: 19988
Modified:
users/ken/EasyPBI2/Makefile
users/ken/EasyPBI2/mainGUI.cpp
users/ken/EasyPBI2/mainGUI.h
users/ken/EasyPBI2/modBuild.cpp
users/ken/EasyPBI2/modBuild.h
Log:
FInish up the resources tab for EasyPBI2
Modified: users/ken/EasyPBI2/Makefile
===================================================================
--- users/ken/EasyPBI2/Makefile 2012-10-27 09:19:44 UTC (rev 19987)
+++ users/ken/EasyPBI2/Makefile 2012-10-27 18:35:28 UTC (rev 19988)
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: EasyPBI
-# Generated by qmake (2.01a) (Qt 4.8.2) on: Wed Oct 17 18:55:50 2012
+# Generated by qmake (2.01a) (Qt 4.8.2) on: Sat Oct 27 12:13:49 2012
# Project: EasyPBI.pro
# Template: app
# Command: /usr/local/bin/qmake-qt4 -o Makefile EasyPBI.pro
Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp 2012-10-27 09:19:44 UTC (rev 19987)
+++ users/ken/EasyPBI2/mainGUI.cpp 2012-10-27 18:35:28 UTC (rev 19988)
@@ -614,6 +614,43 @@
}
+void MainGUI::on_push_resources_add_clicked(){
+ //Get the desired file
+ QStringList iFiles = QFileDialog::getOpenFileNames(this, tr("Select Resources"), QDir::homePath() );
+ //Check that there were file selected
+ if(iFiles.isEmpty()){ return; }
+ //Now add these files to the module
+ for(int i=0; i<iFiles.length(); i++){
+ currentModule->addResource(FALSE,iFiles[i]);
+ }
+ //Now update the GUI
+ refreshGUI("resources");
+}
+
+void MainGUI::on_push_resources_remove_clicked(){
+ //Get the currently selected resource
+ QString cfile;
+ if(ui->listw_resources->currentRow() != -1){ cfile = ui->listw_resources->currentItem()->text(); }
+ //Check that there is something selected
+ if(cfile.isEmpty()){ return; }
+ //Remove the resource
+ currentModule->removeResource(cfile);
+ //Refresh the GUI
+ refreshGUI("resources");
+}
+
+void MainGUI::on_push_resources_mkwrapper_clicked(){
+ //Get the desired filename for the wrapper script
+ bool ok;
+ QString cFile = QInputDialog::getText(this, tr("New Wrapper Script"), tr("Filename")+":", QLineEdit::Normal, "",&ok);
+ //Check for a valid input
+ if(!ok || cFile.isEmpty()){ return; }
+ //Now create the new file
+ currentModule->addResource(TRUE,cFile);
+ //Refresh the GUI
+ refreshGUI("resources");
+}
+
void MainGUI::slotResourceScriptSaved(){
//get the current file and path
QString cfile;
Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h 2012-10-27 09:19:44 UTC (rev 19987)
+++ users/ken/EasyPBI2/mainGUI.h 2012-10-27 18:35:28 UTC (rev 19988)
@@ -50,6 +50,9 @@
void on_push_config_save_clicked();
//resources functions
void slotResourceChanged();
+ void on_push_resources_add_clicked();
+ void on_push_resources_remove_clicked();
+ void on_push_resources_mkwrapper_clicked();
void slotResourceScriptSaved();
private:
Modified: users/ken/EasyPBI2/modBuild.cpp
===================================================================
--- users/ken/EasyPBI2/modBuild.cpp 2012-10-27 09:19:44 UTC (rev 19987)
+++ users/ken/EasyPBI2/modBuild.cpp 2012-10-27 18:35:28 UTC (rev 19988)
@@ -709,33 +709,32 @@
}
}
-bool ModBuild::addResource(QString resourceType, QString resourcePath){
+bool ModBuild::addResource(bool isNewWrapper, QString resourcePath){
if(resourcePath.isEmpty()){
qDebug() << "Warning: no resource selected";
return TRUE; // Do not flag this as an error in the function
}
- //resourcePath *MUST* be an absolute path (start with "/")
- if( !resourcePath.startsWith("/") ){
- qDebug() << "Error: Path to desired resource is not an absolute path!";
- return FALSE;
- }
- //Check that the desired resource exists
- if( !QFile::exists(resourcePath) ){
- qDebug() << "Error: Desired resource does not exist: " << resourcePath;
- return FALSE;
- }
//Determine the type of file that is being added
- bool isWrapper=FALSE;
bool isIcon=FALSE;
- if(resourceType.toLower()=="wrapper"){ isWrapper = TRUE; }
- else if(resourceType.toLower()=="icon"){ isIcon = TRUE; }
+ if(resourcePath.endsWith(".png") && !isNewWrapper){ isIcon = TRUE; }
//Create the full path to the location within the module
QString newResourcePath = modulePath + "/resources/";
- if(isWrapper){
+ if(isNewWrapper){
newResourcePath.append("bin/");
//Make sure the "bin" directory exists
QDir dir(newResourcePath);
if(!dir.exists()){ dir.cdUp(); dir.mkdir("bin"); }
+ }else{
+ //resourcePath *MUST* be an absolute path (start with "/")
+ if( !resourcePath.startsWith("/") ){
+ qDebug() << "Error: Path to desired resource is not an absolute path!";
+ return FALSE;
+ }
+ //Check that the desired resource exists
+ if( !QFile::exists(resourcePath) ){
+ qDebug() << "Error: Desired resource does not exist: " << resourcePath;
+ return FALSE;
+ }
}
QString resource = getFilenameFromPath(resourcePath);
newResourcePath.append(resource);
@@ -746,14 +745,28 @@
}
//Copy the resource into the module
bool status=FALSE;
- if( !QFile::copy(resourcePath,newResourcePath) ){
- qDebug() << "Error copying resource into the module";
+ if(isNewWrapper){
+ //Create a standard wrapper script in the module
+ QStringList form;
+ form << "#!/bin/sh";
+ form << "#This is a sample wrapper script form layout";
+ form << "PROGDIR=CHANGEME #this will point to the base PBI directory";
+ form << "APPBINARY=bin/sample #application binarn";
+ form << "#--- DO SOMETHING HERE ---\n";
+ form << "#Now start the main application";
+ form << "${PROGDIR}/${APPBINARY} $@";
+ status = createFile(newResourcePath,form);
}else{
- status=TRUE;
+ //Copy the given file into the module
+ if( !QFile::copy(resourcePath,newResourcePath) ){
+ qDebug() << "Error copying resource into the module";
+ }else{
+ status=TRUE;
+ }
}
//Add the item to the appropriate lists
if(status && isIcon){ currentIcons << resource; currentIcons.removeDuplicates();}
- else if(status && isWrapper){ currentBins << "bin/"+resource; currentBins.removeDuplicates();}
+ else if(status && isNewWrapper){ currentBins << "bin/"+resource; currentBins.removeDuplicates();}
return status;
}
@@ -852,7 +865,10 @@
QStringList subdirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
for(int i=0; i<subdirs.length(); i++){
dir.cd(subdirs[i]);
- fileList = fileList + dir.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden);
+ QStringList dirL = dir.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden);
+ for(int j=0; j<dirL.length(); j++){
+ fileList << subdirs[i]+"/"+dirL[j];
+ }
dir.cdUp();
}
}else if(group=="xdg-desktop"){
Modified: users/ken/EasyPBI2/modBuild.h
===================================================================
--- users/ken/EasyPBI2/modBuild.h 2012-10-27 09:19:44 UTC (rev 19987)
+++ users/ken/EasyPBI2/modBuild.h 2012-10-27 18:35:28 UTC (rev 19988)
@@ -56,7 +56,7 @@
void addExternalLink(QString, QString, QStringList);
void removeExternalLink(QString, QString);
//resources functions
- bool addResource(QString, QString);
+ bool addResource(bool, QString);
bool removeResource(QString);
//General purpose functions
QString path(){ return modulePath; } //get the current module path
More information about the Commits
mailing list