Changeset e49527f


Ignore:
Timestamp:
12/10/13 19:07:19 (9 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
d6345ef
Parents:
0d8df9e (diff), 67122be (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:pcbsd/pcbsd

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pbi-manager/pbi-manager

    rcd20ca3 r67122be  
    33433343        if [ "${PBI_NOHASHDIR}" = "YES" ] ; then return 0 ; fi 
    33443344        if [ ! -e "${1}/${PBI_HASHLIST}" ] ; then return 0; fi 
     3345        local hDir="${1}/local" 
    33453346 
    33463347        if [ "$PBI_VERBOSE" = "YES" ] ; then 
     
    33633364 
    33643365                # Make sure the target file hasnt been removed 
    3365                 if [ ! -e "${1}/${file}" ] ; then continue ; fi 
     3366                if [ ! -e "${hDir}/${file}" ] ; then continue ; fi 
    33663367 
    33673368                # We dont need no stinking sym-links 
    3368                 if [ -h "${1}/${file}" ] ; then continue ; fi 
     3369                if [ -h "${hDir}/${file}" ] ; then continue ; fi 
    33693370 
    33703371                if [ -f "${PBI_HASHDIR}/${hl}" ] ; then 
    3371                         use_hashfile "$hl" "${1}/$file" 
     3372                        use_hashfile "$hl" "${hDir}/$file" 
    33723373                else 
    3373                         mv_ln_hashfile "$hl" "${1}/$file" 
     3374                        mv_ln_hashfile "$hl" "${hDir}/$file" 
    33743375                fi 
    33753376        done < "${1}/${PBI_HASHLIST}" 
  • src-qt4/EasyPBI-devel/Makefile

    r4808ce64 r0d8df9e  
    11############################################################################# 
    22# Makefile for building: EasyPBI 
    3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Dec 10 11:34:10 2013 
     3# Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Dec 10 17:24:04 2013 
    44# Project:  EasyPBI.pro 
    55# Template: app 
     
    219219                backend.h \ 
    220220                config.h \ 
     221                PBIModule.h \ 
     222                ModuleUtils.h \ 
    221223                mainGUI.h 
    222224        /usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) mainGUI.h -o moc_mainGUI.cpp 
     
    286288                modBuild.h \ 
    287289                backend.h \ 
    288                 config.h 
     290                config.h \ 
     291                PBIModule.h \ 
     292                ModuleUtils.h 
    289293        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp 
    290294 
     
    293297                backend.h \ 
    294298                config.h \ 
     299                PBIModule.h \ 
     300                ModuleUtils.h \ 
    295301                ui_mainGUI.h \ 
    296302                newModuleDialog.h \ 
  • src-qt4/EasyPBI-devel/ModuleUtils.cpp

    r69ec30c r0d8df9e  
    77} 
    88 
     9QString ModuleUtils::recommendedXdgCategory(QString portCategory){ 
     10  QString pc = portCategory.toLower(); 
     11  QStringList avcat, devcat, edcat, gamecat, gracat,netcat,offcat,setcat,syscat,scicat; 
     12  avcat << "audio"<<"multimedia"; 
     13  devcat << "devel" << "lang" << "java"; 
     14  edcat << "astro" << "cad" <<"math"; 
     15  scicat <<"biology"<<"science"; 
     16  gamecat << "games"; 
     17  gracat << "graphics"; 
     18  netcat << "ftp"<<"irc"<<"mail"<<"net"<<"net-im"<<"net-p2p"<<"net-mgmt"<<"www"; 
     19  offcat << "editors" << "finance" << "news" << "textproc"; 
     20  setcat << "accessibility"<<"print"; 
     21  syscat << "sysutils" << "benchmarks" << "emulators" << "ports-mgmt"; 
     22   
     23  //Assign the menu category 
     24  QString mc; 
     25  if( avcat.contains(pc) ){ mc="AudioVideo"; } 
     26  else if( devcat.contains(pc) ){ mc="Development"; } 
     27  else if( edcat.contains(pc) ){ mc="Education"; } 
     28  else if( scicat.contains(pc) ){ mc ="Science"; } 
     29  else if( gamecat.contains(pc) ){ mc="Game"; } 
     30  else if( gracat.contains(pc) ){ mc="Graphics"; } 
     31  else if( netcat.contains(pc) ){ mc="Network"; } 
     32  else if( offcat.contains(pc) ){ mc="Office"; } 
     33  else if( setcat.contains(pc) ){ mc="Settings"; } 
     34  else if( syscat.contains(pc) ){ mc="System"; } 
     35  else{ mc = "Utility"; } 
     36   
     37  return mc;     
     38} 
     39 
     40bool ModuleUtils::xdgExecUsesRoot(QString exec){ 
     41  QString first = exec.section(" ",0,0,QString::SectionSkipEmpty); 
     42  return ( (first == "pc-su") || first.contains("sudo") ); 
     43} 
     44 
     45QString ModuleUtils::pruneXdgLine(QString exec){ 
     46  if(exec.contains("%%PBI_EXEDIR%%") || exec.contains("%%PBI_APPDIR%%") ){ 
     47    QString sline = exec.section("%%",2,50); 
     48    if(sline.startsWith("/")){ sline.remove(1); } 
     49    return sline; 
     50  }else{ 
     51    return exec;           
     52  } 
     53} 
     54 
     55QString ModuleUtils::generateXdgExec(QString shortExec, bool useRoot){ 
     56  QString exec = "%%PBI_EXEDIR%%/"+shortExec; 
     57  if(useRoot){ exec.prepend("pc-su "); } 
     58  return exec; 
     59} 
     60 
     61QString ModuleUtils::generateXdgPath(QString shortline){ 
     62  QString line = "%%PBI_APPDIR%%"; 
     63  if(!shortline.isEmpty()){ 
     64    line.append("/"+shortline);    
     65  } 
     66  return line; 
     67} 
     68         
    969void ModuleUtils::compressModule(QString modulePath){ 
    1070  //Compress the module directory 
     
    47107    return MOD; 
    48108  } 
     109  dir.cd(modName); 
     110  //Load the (non-existant) pbi.conf to prep the structure 
     111  MOD.loadModule(dir.canonicalPath()+"/pbi.conf"); 
    49112  //Now try to copy over the icon file into the resources dir 
    50113  if(iconFile.isEmpty() || !QFile::exists(iconFile)){ iconFile = QDir::homePath()+"/EasyPBI/defaulticon.png"; } 
  • src-qt4/EasyPBI-devel/ModuleUtils.h

    r69ec30c r0d8df9e  
    1313public: 
    1414        static QStringList validXdgCategories(); 
     15        static QString recommendedXdgCategory(QString portCategory); 
     16        static bool xdgExecUsesRoot(QString exec); 
     17        static QString pruneXdgLine(QString exec); 
     18        static QString generateXdgExec(QString shortExec, bool useRoot); 
     19        static QString generateXdgPath(QString shortline); 
    1520        static void compressModule(QString modulePath); 
    1621        static PBIModule newModule(QString moduleDir, QString port, QString iconFile); 
  • src-qt4/EasyPBI-devel/PBIModule.cpp

    ra51ecee r0d8df9e  
    1919     // NOTE: These values are hard-coded in the file read/write below due to specific file format 
    2020  mimeValues << "xmlns" << "type" << "pattern";  
    21          
    22   HASH.clear(); //Make sure the hash is currently empty 
    2321} 
    2422 
     
    2624         
    2725// ============== 
    28 //        Initial load 
     26//  Initial load 
    2927// ============== 
    3028bool PBIModule::loadModule(QString confpath){ 
     
    3230  //Get the base Path and make sure it exists 
    3331  basePath = confpath.left(confpath.length()-9); //base directory path 
     32  HASH.clear(); //Make sure we always start with a clean slate when loading a module 
    3433  if(!QFile::exists(basePath)){ basePath.clear(); return false; } 
    35   //This is good to go: now start to load all the different pieces of the module 
    36   this->loadConfig(); //pbi.conf (only piece that is loaded at all times) 
    3734  return true; 
    3835} 
     
    117114         
    118115void PBIModule::loadConfig(){ 
    119 //Read the designated pbi.conf and store the variables 
     116  //Read the designated pbi.conf and store the variables 
    120117  QStringList contents = readFile(basePath+"/pbi.conf"); 
    121118  for(int i=0; i<contents.length(); i++){ 
    122119    //see if the current line conains a desired variable and save it 
    123120    QString line = contents[i]; 
    124     if(!line.startsWith("#") && !line.startsWith("export")){ //Ignore commented out lines 
     121    if(!line.startsWith("#") && !line.startsWith("export") && !line.isEmpty()){ //Ignore commented out lines 
    125122      //Pull apart the variable and the value 
    126123      QString var = line.section("=\"",0,0,QString::SectionSkipEmpty).trimmed(); 
    127124      QString val = line.section("=\"",1,50).section("#",0,0,QString::SectionSkipEmpty).section(";",0,0,QString::SectionSkipEmpty).trimmed(); 
    128         while( !val.endsWith("\"") && i<contents.length() ){ 
     125        while( !val.endsWith("\"") && i<(contents.length()-1) ){ 
    129126          i++; 
    130127          line = contents[i]; 
     
    132129        } 
    133130        if(val.endsWith("\"")){ val.chop(1); } //remove the ending quote 
     131      qDebug() << "var="+var+"\t\tval="+val; 
    134132      //Now check for text/bool/int values 
    135133      if(CTextValues.contains(var)){ HASH.insert(var,val); } 
     
    263261} 
    264262 
     263bool PBIModule::removeResource(QString resourcePath){ 
     264  return createFile(basePath+"/resources/"+resourcePath, QStringList() );        
     265} 
     266 
    265267// ============= 
    266 //           XDG 
     268//      XDG 
    267269// ============= 
    268270QStringList PBIModule::validXdgText(){ 
  • src-qt4/EasyPBI-devel/PBIModule.h

    ra51ecee r0d8df9e  
    5050        QStringList existingResources(); 
    5151        bool addResource(QString filePath, QString resourcePath = ""); 
     52        bool removeResource(QString resourcePath); 
    5253         
    5354        //XDG files 
  • src-qt4/EasyPBI-devel/mainGUI.cpp

    ra51ecee r0d8df9e  
    161161    PBI_BUILDING_NOW.clear(); 
    162162    PBI_BUILD_TERMINATED=FALSE; 
     163     
     164    updateConfigVisibility(); //on first run, always need to do this manually 
    163165} 
    164166 
     
    191193    ui->actionPackage_Module->setEnabled(FALSE); 
    192194    ui->actionRefresh_Module->setEnabled(FALSE); 
     195    ui->tabWidget->setEnabled(false); 
     196    return; 
    193197  }else{  
    194198    ui->actionPackage_Module->setEnabled(TRUE);   
    195199    ui->actionRefresh_Module->setEnabled(TRUE); 
     200    ui->tabWidget->setEnabled(true); 
    196201  } 
    197202  //See if we should refresh everything (default)   
     
    201206  // ------PBI.CONF------ 
    202207  if( doall || doeditor || (item == "pbiconf")){ 
     208    qDebug() << "Update conf tab"; 
    203209    //Update options visibility 
    204210    updateConfigVisibility(); 
    205211    //Now reset the options to the current module values 
     212    qDebug() << "Load config"; 
     213    MODULE.loadConfig(); 
    206214    // -- check boxes 
     215    qDebug() << "Set bool values"; 
    207216    ui->check_requiresroot->setChecked( MODULE.isEnabled("PBI_REQUIRESROOT") ); 
    208217    ui->check_config_nopkg->setChecked( MODULE.isEnabled("PBI_AB_NOPKGBUILD") ); 
    209218    ui->check_config_notmpfs->setChecked( MODULE.isEnabled("PBI_AB_NOTMPFS") ); 
    210219    // -- Text Values 
     220    qDebug() << "Set text values"; 
    211221    ui->line_progname->setText( MODULE.text("PBI_PROGNAME") ); 
    212222    ui->line_progversion->setText( MODULE.text("PBI_PROGVERSION") ); 
     
    218228    ui->line_repoCat->setText( MODULE.text("PBI_CATEGORY") ); 
    219229    ui->line_repoIconURL->setText( MODULE.text("PBI_ICONURL") ); 
    220     // -- Combo Boxes (still text values) 
     230    // -- Combo Boxes (filled with individual items from text) 
     231    qDebug() << "Show mkportafter items"; 
    221232    ui->list_portafter->clear(); 
    222233    ui->list_portafter->addItems( MODULE.text("PBI_MKPORTAFTER").split("\n") ); 
    223234    // -- Integer Values 
     235    qDebug() << "Show number values"; 
    224236    ui->spin_repoBuildKey->setValue( MODULE.number("PBI_BUILDKEY") ); 
    225237    ui->spin_repoPriority->setValue( MODULE.number("PBI_AB_PRIORITY") ); 
    226238    ui->spin_repoRevision->setValue( MODULE.number("PBI_PROGREVISION") ); 
    227 /* 
    228     //Display the variables from the currentModule structure 
    229     // -- check boxes 
    230     //QString chk = currentModule->readValue("requiresroot").toLower(); 
    231     //if( (chk=="true") || (chk=="yes") ){ ui->check_requiresroot->setChecked(TRUE); } 
    232     //else{ ui->check_requiresroot->setChecked(FALSE); } 
    233     // -- line edits 
    234     ui->line_progname->setText(currentModule->readValue("progname")); 
    235     ui->line_progversion->setText(currentModule->readValue("progversion")); 
    236     ui->line_progweb->setText(currentModule->readValue("progweb")); 
    237     ui->line_progauthor->setText(currentModule->readValue("progauthor")); 
    238     //ui->line_progdir->setText(currentModule->readValue("packagedir")); 
    239     ui->line_makeport->setText(currentModule->readValue("makeport")); 
    240     //ui->edit_makeopts->setPlainText(currentModule->readValue("makeoptions")); 
    241     // -- combo boxes (lists) 
    242     //ui->list_portbefore->clear(); ui->list_portafter->clear(); ui->list_progicon->clear(); 
    243     //ui->list_portbefore->addItems( currentModule->readValue("makeportbefore").split(" ") ); 
    244     ui->list_portafter->addItems( currentModule->readValue("makeportafter").split(" ") ); 
    245     */ 
    246     QStringList icons = currentModule->currentIcons; 
     239    // -- Combo Boxes (Select the proper item only) 
     240    qDebug() << "Show Icon list"; 
     241    QStringList icons = MODULE.existingResources().filter(".png"); 
    247242    if(icons.length() > 0){ 
    248243      for(int i=0; i<icons.length(); i++){ 
    249         ui->list_progicon->addItem(QIcon(currentModule->path()+"/resources/"+icons[i]),icons[i]); 
     244        ui->list_progicon->addItem(QIcon(MODULE.basepath()+"/resources/"+icons[i]),icons[i]); 
    250245      }      
    251       int cicon = icons.indexOf(currentModule->readValue("progicon")); 
     246      int cicon = icons.indexOf(MODULE.text("PBI_PROGICON")); 
    252247      if( cicon == -1 ){  
    253               ui->list_progicon->addItem(currentModule->readValue("progicon"));  
    254               cicon = icons.indexOf(currentModule->readValue("progicon")); 
     248              ui->list_progicon->addItem(MODULE.text("PBI_PROGICON"));  
     249              cicon = icons.indexOf(MODULE.text("PBI_PROGICON")); 
    255250      } 
    256251      ui->list_progicon->setCurrentIndex(cicon); 
    257252    }else{ 
    258       ui->list_progicon->addItem(currentModule->readValue("progicon")); 
    259     } 
    260      
     253      ui->list_progicon->addItem( MODULE.text("PBI_PROGICON") ); 
     254    } 
     255    qDebug() << "Done with config"; 
    261256    ui->push_config_save->setEnabled(FALSE);  //disable the save button until something changes 
    262257  } 
    263258  // -----RESOURCES-------- 
    264259  if( doall || doeditor || (item == "resources")){ 
     260    qDebug() << "Update Resources tab"; 
    265261    //Get the all the current files in the resources category and add them to the list 
    266     QStringList rs = currentModule->filesAvailable("resources"); 
     262    QStringList rs = MODULE.existingResources(); //currentModule->filesAvailable("resources"); 
    267263    //disconnect the signal/slot connection to make sure we don't get an extra phantom refresh 
    268264    disconnect(ui->listw_resources, SIGNAL(itemSelectionChanged()), this, SLOT(slotResourceChanged()) ); 
     
    277273  //------XDG------ 
    278274  if( doall || doeditor || (item == "xdg")){ 
     275    qDebug() << "Update XDG tab"; 
    279276    slotXdgTypeChanged(); 
    280277  } 
    281278  //------SCRIPTS----- 
    282279  if( doall || doeditor || (item == "scripts")){ 
     280    qDebug() << "Update Scripts tab"; 
    283281    //Update the list of available scripts and determine if one needs to be read 
    284282    bool loadScript = FALSE; 
    285     QString path = currentModule->path()+"/scripts/"; 
     283    QStringList good = MODULE.existingScripts(); 
    286284    int currentIndex = ui->list_scripts_file->currentIndex(); 
    287285    for(int i=1; i< ui->list_scripts_file->count(); i++){ //Skip the first item (is nothing) 
    288       if( QFile::exists( path+ui->list_scripts_file->itemText(i) ) ){ 
     286      if( good.contains(ui->list_scripts_file->itemText(i) ) ){ 
    289287        if(i == currentIndex){ loadScript = TRUE; } 
    290288        ui->list_scripts_file->setItemIcon(i,Backend::icon("file")); 
     
    296294    if(loadScript){ 
    297295      //Read and display the script 
    298       QStringList contents = ModBuild::readFile(path+ui->list_scripts_file->currentText()); 
     296      QStringList contents = MODULE.readScript(ui->list_scripts_file->currentText()); 
    299297      ui->text_scripts_edit->setPlainText(contents.join("\n")); 
    300298      //Setup display items 
     
    316314  //------EXTERNAL-LINKS------ 
    317315  if( doall || doeditor || (item == "external-links")){ 
     316    qDebug() << "Update external links tab"; 
    318317    //nothing to make visible/invisible here 
    319318    //Load the external-links file 
    320319    ui->tree_el_view->clear(); 
    321     QStringList cLinks = currentModule->externalLinks(); 
    322     QStringList labels; labels << tr("File") << tr("Link To") << tr("File Type"); 
    323     for( int i=0; i<cLinks.length(); i++ ){ 
    324       QStringList link = cLinks[i].split("\t"); 
     320    //QStringList cLinks = currentModule->externalLinks(); 
     321    QStringList files, links, types; 
     322    MODULE.loadExternalLinks(files,links, types); 
     323    //QStringList labels; labels << tr("File") << tr("Link To") << tr("File Type"); 
     324    for( int i=0; i<files.length(); i++ ){ 
     325      QStringList link; link << files[i] << links[i] << types[i]; 
    325326      ui->tree_el_view->addTopLevelItem(new QTreeWidgetItem(link)); 
    326327    } 
     
    331332    //update the available binaries 
    332333    menu_el_bins.clear(); 
    333     QStringList cBins = currentModule->currentBins; 
     334    QStringList cBins; //Not setup yet in the package framework 
    334335    if(!cBins.isEmpty()){ 
    335336      for(int i=0; i<cBins.length(); i++){ 
     
    344345  //------PBI BUILDER-------- 
    345346  if( doall || (item == "pbibuild")){ 
     347    qDebug() << "Update PBI Build tab"; 
    346348    if(PBI_BUILDING_NOW.isEmpty()){ 
    347349      //only change things if there is nothing building at the moment 
     
    353355  //------OVERALL SETTINGS------ 
    354356  if( doall || doeditor ){ 
     357    qDebug() << "Update extra settings"; 
    355358    //Enable/disable the buttons that require the FreeBSD ports tree 
    356359    if( settings->check("isportsavailable") ){ 
     
    364367    } 
    365368    //Check for a 64-bit system to enable the 32-bit build option 
    366     if( settings->check("is64bit") && !currentModule->isLocalPBI ){ ui->check_build_32->setVisible(TRUE); } 
     369    if( settings->check("is64bit") ){ ui->check_build_32->setVisible(TRUE); } 
    367370    else{ ui->check_build_32->setVisible(FALSE); ui->check_build_32->setChecked(FALSE); } 
    368     //Disable tabs that are not used when bulding local PBI's 
    369     if(currentModule->isLocalPBI){ 
    370         ui->tabWidget->setTabEnabled(5,FALSE); 
    371     }else{ 
    372         ui->tabWidget->setTabEnabled(5,TRUE); 
    373     } 
     371     
    374372    //Set the default focus on the "load" button 
    375373    this->setFocus(); 
    376374  } 
     375  qDebug() << "Finished updating GUI"; 
    377376} 
    378377/*---------------------------------- 
     
    400399 
    401400void MainGUI::on_actionPackage_Module_triggered(){ 
    402    currentModule->compressModule(); 
     401   ModuleUtils::compressModule(MODULE.basepath()); //currentModule->compressModule(); 
    403402   QMessageBox::information(this,tr("Success"),tr("A copy of the current module has been successfully packaged  within the module directory.") ); 
    404403 
     
    406405 
    407406void MainGUI::on_actionRefresh_Module_triggered(){ 
    408   QString modSel = currentModule->path(); //re-load the current module 
    409   bool ok = currentModule->loadModule(modSel);  
     407  QString modSel = MODULE.basepath(); //currentModule->path(); //re-load the current module 
     408  bool ok = MODULE.loadModule(modSel+"/pbi.conf");  
    410409  if(ok){  
    411410    qDebug() << "Loaded module:"<<modSel;          
    412     line_module->setText(modSel.replace(QDir::homePath(),"~"));  
    413     //if(currentModule->isLocalPBI){ radio_module_local->toggle(); } 
    414     //else{  
    415       //radio_module_port->toggle(); //Port PBI 
    416       if( settings->check("isportsavailable") ){  
    417         currentModule->readPortInformation(settings->value("portsdir")+"/"+currentModule->readValue("makeport")); 
    418       } 
    419     //} 
     411    line_module->setText(modSel.replace(QDir::homePath(),"~")); 
    420412    refreshGUI("all"); 
    421413  } 
     
    462454    //Now create the new module 
    463455    QString modPath, modType, modBase, oldIconPath; 
    464     modType = dlg->moduleType; 
    465     modBase = dlg->moduleData; 
    466     oldIconPath = dlg->moduleIcon; 
    467     modPath = settings->value("moduledir")+"/"+modBase.section("/",-1).toLower(); 
    468           //modPath ->full path, modType->"local"or "port", modBase->makeport or packagedir 
    469     bool ok = currentModule->createNewModule(modPath,modType,modBase); 
    470     if(!ok){ 
     456    modType = dlg->moduleType; // "local" or "port" 
     457    modBase = dlg->moduleData; //port cat/name 
     458    oldIconPath = dlg->moduleIcon; //PNG icon to use for the program 
     459    modPath = settings->value("moduledir"); //base directory to create modules in 
     460    MODULE = ModuleUtils::newModule(modPath, modBase, oldIconPath); 
     461    if(MODULE.basepath().isEmpty()){ 
    471462      QMessageBox::warning(this,tr("EasyPBI: Permissions Error"), tr("Could not create PBI module. Please check the directory permissions and try again.")); 
    472463    }else{ 
    473       //MODULE CREATED, NOW FILL IT APPROPRIATELY 
    474       //Icon 
    475       currentModule->addResource(FALSE, oldIconPath); //copy the icon file into the module 
    476       currentModule->writeValue("progicon", oldIconPath.section("/",-1) ); 
    477       //Load Port info if appropriate 
    478       if(currentModule->isPortPBI){ 
    479         //radio_module_port->toggle(); 
    480         //Use the port info if possible 
    481         if( settings->check("isportsAvailable") ){ 
    482           currentModule->readPortInformation(settings->value("portsdir")+"/"+modBase); 
    483           //Now save the detected information into the module 
    484           currentModule->writeValue("progname", currentModule->readValue("portname")); 
    485           currentModule->writeValue("progweb", currentModule->readValue("portwebsite")); 
    486           currentModule->writeValue("progauthor", currentModule->readValue("portauthor")); 
    487           currentModule->writePBIconf(); 
    488         } 
    489       }//else if(currentModule->isLocalPBI){ 
    490         //radio_module_local->toggle(); 
    491                
    492       //} 
    493       //Now let the UI reflect the new module  
    494       line_module->setText( currentModule->path().replace(QDir::homePath(),"~") );       
     464      line_module->setText( MODULE.basepath().replace(QDir::homePath(), "~") ); 
    495465    } 
    496466  } 
     
    501471 
    502472void MainGUI::on_actionLoad_Module_triggered(){ 
    503   QString modSel = QFileDialog::getExistingDirectory(this, tr("Select Module"), settings->value("moduledir")); 
     473  QString modSel = QFileDialog::getOpenFileName(this, tr("Select PBI Module Configuration"), settings->value("moduledir"), tr("PBI Configuration (pbi.conf)") ); 
    504474  if(modSel.isEmpty()){return;} //action cancelled or closed 
    505   bool ok = currentModule->loadModule(modSel); 
     475  bool ok = MODULE.loadModule(modSel); 
    506476  if(ok){  
    507     qDebug() << "Loaded module:"<<modSel;          
    508     line_module->setText(modSel.replace(QDir::homePath(),"~"));  
    509     //if(currentModule->isLocalPBI){ radio_module_local->toggle(); } 
    510     //else{  
    511       //radio_module_port->toggle(); //Port PBI 
    512       if( settings->check("isportsavailable") ){  
    513         currentModule->readPortInformation(settings->value("portsdir")+"/"+currentModule->readValue("makeport")); 
    514       } 
    515     //} 
    516     refreshGUI("all"); 
    517   } 
     477    qDebug() << "Loaded module:"<<modSel; 
     478    line_module->setText(MODULE.basepath().replace(QDir::homePath(),"~"));  
     479  } 
     480  refreshGUI("all"); 
    518481} 
    519482 
     
    525488  switch(newtab){ 
    526489    case 0: 
     490            refreshGUI("pbibuild"); break; 
     491    case 1: 
    527492            refreshGUI("pbiconf"); break; 
    528     case 1: 
     493    case 2: 
    529494            refreshGUI("resources"); break; 
    530     case 2: 
     495    case 3: 
    531496            refreshGUI("xdg"); break; 
    532     case 3: 
     497    case 4: 
    533498            refreshGUI("scripts"); break; 
    534     case 4: 
     499    case 5: 
    535500            refreshGUI("external-links"); break; 
    536     case 5: 
     501    case 6: 
    537502            refreshGUI("freenas"); break; 
    538503    default: 
     
    741706           
    742707  }else{ //item selected 
    743     QString path = currentModule->path() + "/resources/"; 
     708    QString path = MODULE.basepath() + "/resources/"; 
    744709    if( cfile.endsWith(".png") || cfile.endsWith(".jpg") ){ 
    745710      //Image file, show full size 
     
    755720    }else{ 
    756721      ui->push_resources_savewrapper->setVisible(TRUE); 
    757       QStringList contents = ModBuild::readFile(path+cfile); 
     722      QStringList contents = PBIModule::readFile(path+cfile); 
    758723      ui->text_resources_script->clear(); 
    759724      ui->text_resources_script->setText(contents.join("\n")); 
     
    775740  //Now add these files to the module 
    776741  for(int i=0; i<iFiles.length(); i++){ 
    777     currentModule->addResource(FALSE,iFiles[i]); 
     742    MODULE.addResource(iFiles[i]); 
    778743  } 
    779744  //Now update the GUI 
     
    788753  if(cfile.isEmpty()){ return; } 
    789754  //Remove the resource 
    790   if(currentModule->removeResource(cfile)){ 
     755  if(MODULE.removeResource(cfile)){ 
    791756      qDebug() << "Removed Resource:" << cfile; 
    792757  }else{ 
     
    804769  if(!ok || cFile.isEmpty()){ return; } 
    805770  //Now create the new file 
    806   currentModule->addResource(TRUE,cFile); 
     771  //currentModule->addResource(TRUE,cFile); 
     772  qDebug() << "Creating default wrapper script is not implemented currently"; 
    807773  //Refresh the GUI 
    808774  refreshGUI("resources"); 
     
    814780  if(ui->listw_resources->currentRow() != -1){ cfile = ui->listw_resources->currentItem()->text(); } 
    815781  if(cfile.isEmpty()){ return; } // do nothing if no file selected 
    816   QString filePath = currentModule->path() + "/resources/" + cfile; 
    817782  //Read the current text for the resource 
    818783  QStringList contents = ui->text_resources_script->toPlainText().split("\n"); 
    819784  //overwrite the resource with the new contents 
    820   ModBuild::createFile(filePath,contents); 
     785  MODULE.writeScript(cfile,contents); 
    821786  ui->push_resources_savewrapper->setEnabled(FALSE); 
    822787} 
     
    834799    //update the files available 
    835800    ui->list_xdg_files->clear(); 
    836     ui->list_xdg_files->addItems(currentModule->filesAvailable("xdg-desktop")); 
     801    ui->list_xdg_files->addItems(MODULE.listXdgDesktopFiles()); 
    837802    //Set the visibility 
    838803        //Current file 
     
    848813    //update the files available 
    849814    ui->list_xdg_files->clear(); 
    850     ui->list_xdg_files->addItems(currentModule->filesAvailable("xdg-menu"));       
     815    ui->list_xdg_files->addItems(MODULE.listXdgMenuFiles());       
    851816    //Set the visibility 
    852817        //Current file 
     
    868833  //Available binaries pushbuttons 
    869834  menu_bins.clear(); 
    870   QStringList cBins = currentModule->currentBins; 
     835  QStringList cBins; //not re-implemented yet 
    871836  if(!cBins.isEmpty()){ 
    872837    for(int i=0; i<cBins.length(); i++){ 
     
    875840  } 
    876841  //Menu categories 
    877   QString recMenu = currentModule->readValue("portmenucategory"); 
    878   QStringList cats = currentModule->validMenuCategories; 
     842  QString recMenu = ModuleUtils::recommendedXdgCategory(MODULE.text("PBI_MAKEPORT").section("/",0,0) ); 
     843  QStringList cats = ModuleUtils::validXdgCategories(); 
    879844  menu_validMenuCats.clear(); 
    880845  for(int i=0; i<cats.length(); i++){ 
     
    895860  //Reset the icon list 
    896861  ui->list_xdg_icon->clear(); 
    897   QStringList icons = currentModule->currentIcons; 
     862  QStringList icons = MODULE.existingResources().filter(".png"); 
    898863  if(icons.length() > 0){ 
    899864      for(int i=0; i<icons.length(); i++){ 
    900         ui->list_xdg_icon->addItem(QIcon(currentModule->path()+"/resources/"+icons[i]),icons[i]); 
     865        ui->list_xdg_icon->addItem(QIcon(MODULE.basepath()+"/resources/"+icons[i]),icons[i]); 
    901866      }      
    902867  } 
     
    915880    ui->push_xdg_savechanges->setEnabled(FALSE); 
    916881    ui->push_xdg_savenew->setEnabled(FALSE); 
    917     //Make sure we don't have any of the structures loaded from previously 
    918     currentModule->loadDesktop(""); 
    919     currentModule->loadMenu(""); 
    920     currentModule->loadMime(""); 
    921882    //Now return 
    922883    return;  
     
    925886  if(ui->radio_xdg_desktop->isChecked()){ 
    926887    //Load the file 
    927     currentModule->loadDesktop(file); 
    928     //update the file info on the GUI 
    929     ui->line_xdg_name->setText( currentModule->readValue("desktopname") ); 
    930     ui->line_xdg_exec->setText( currentModule->readValue("desktopexec") );  
    931     //comboboxes  
    932     int cicon = icons.indexOf(currentModule->readValue("desktopicon")); 
    933     if( cicon == -1 ){  
    934       ui->list_xdg_icon->addItem(currentModule->readValue("desktopicon"));  
    935       cicon = icons.indexOf(currentModule->readValue("desktopicon")); 
    936     } 
    937     ui->list_xdg_icon->setCurrentIndex(cicon); 
    938  
    939     //Checkboxes 
    940     QString chk = currentModule->readValue("desktopterminal").toLower(); 
    941     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_terminal->setChecked(TRUE); } 
    942     else{ ui->check_xdg_terminal->setChecked(FALSE); } 
    943     chk = currentModule->readValue("desktopnodisplay").toLower(); 
    944     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_nodisplay->setChecked(TRUE); } 
    945     else{ ui->check_xdg_nodisplay->setChecked(FALSE); } 
    946     chk = currentModule->readValue("desktoprequiresroot").toLower(); 
    947     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_requiresroot->setChecked(TRUE); } 
    948     else{ ui->check_xdg_requiresroot->setChecked(FALSE); } 
     888    MODULE.loadXdgDesktop(file); 
    949889         
    950890  }else if(ui->radio_xdg_menu->isChecked()){ 
    951891    //Load the file 
    952     currentModule->loadMenu(file); 
    953     //update the file info on the GUI 
    954     ui->line_xdg_name->setText( currentModule->readValue("menuname") ); 
    955     ui->line_xdg_exec->setText( currentModule->readValue("menuexec") );  
    956     ui->line_xdg_menu->setText( currentModule->readValue("menucategories") ); 
    957     //comboboxes 
    958           //icons 
    959     int cicon = icons.indexOf(currentModule->readValue("menuicon")); 
    960     if( cicon == -1 ){  
    961       ui->list_xdg_icon->addItem(currentModule->readValue("menuicon"));  
    962       cicon = icons.indexOf(currentModule->readValue("menuicon")); 
    963     } 
    964     ui->list_xdg_icon->setCurrentIndex(cicon); 
    965      
    966     //Checkboxes 
    967     QString chk = currentModule->readValue("menuterminal").toLower(); 
    968     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_terminal->setChecked(TRUE); } 
    969     else{ ui->check_xdg_terminal->setChecked(FALSE); } 
    970     chk = currentModule->readValue("menunodisplay").toLower(); 
    971     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_nodisplay->setChecked(TRUE); } 
    972     else{ ui->check_xdg_nodisplay->setChecked(FALSE); } 
    973     chk = currentModule->readValue("menurequiresroot").toLower(); 
    974     if( (chk == "true") || (chk=="yes") ){ ui->check_xdg_requiresroot->setChecked(TRUE); } 
    975     else{ ui->check_xdg_requiresroot->setChecked(FALSE); } 
     892    MODULE.loadXdgMenu(file); 
    976893     
    977894    //Load the XDG-MIME file associations 
    978     QString mime = currentModule->readValue("menumimetype"); 
    979     QStringList mimeavailable = currentModule->filesAvailable("xdg-mime"); 
     895    QString mime = MODULE.xdgText("MimeType"); 
     896    QStringList mimeavailable = MODULE.listMimeFiles(); 
    980897    bool found = FALSE; 
    981898    for( int i=0; i<mimeavailable.length(); i++){ 
    982       currentModule->loadMime(mimeavailable[i]); 
    983       if(currentModule->readValue("mimetype") == mime){ 
     899      MODULE.loadMimeFile(mimeavailable[i]); 
     900      if(MODULE.mimeText("type") == mime){ 
    984901        found = TRUE; 
    985902        break; 
     
    988905    //qDebug() << "mimetype detected:" << mime; 
    989906    if(found){ 
    990       ui->line_xdg_mimepatterns->setText( currentModule->readValue("mimepatterns") );  
     907      ui->line_xdg_mimepatterns->setText( MODULE.mimeText("pattern") );  
    991908    }else{ 
    992       currentModule->loadMime(""); //Make sure we don't have any mime file loaded 
     909      MODULE.clearMimeData(); //Make sure we don't have any mime file loaded 
    993910      ui->line_xdg_mimepatterns->clear(); 
    994911    } 
    995912     
    996913  }else{ 
    997     //do nothing, unknown radio button selected (or none) 
    998   } 
     914    MODULE.clearXdgData(); //do nothing, unknown radio button selected (or none) 
     915  } 
     916  //update the file info on the GUI 
     917  ui->line_xdg_name->setText( MODULE.xdgText("Name") ); 
     918  ui->line_xdg_exec->setText( ModuleUtils::pruneXdgLine(MODULE.xdgText("Exec")) ); 
     919  ui->line_xdg_menu->setText( MODULE.xdgText("Categories") ); 
     920  //comboboxes  
     921  QString icon = ModuleUtils::pruneXdgLine(MODULE.xdgText("Icon")); 
     922  int cicon = icons.indexOf(icon); 
     923  if( cicon == -1 ){  
     924    ui->list_xdg_icon->addItem(icon);  
     925    cicon = icons.indexOf(icon); 
     926  } 
     927  ui->list_xdg_icon->setCurrentIndex(cicon); 
     928 
     929  //Checkboxes 
     930  ui->check_xdg_terminal->setChecked( MODULE.xdgEnabled("Terminal") ); 
     931  ui->check_xdg_nodisplay->setChecked( MODULE.xdgEnabled("NoDisplay") ); 
     932  ui->check_xdg_requiresroot->setChecked( ModuleUtils::xdgExecUsesRoot(MODULE.xdgText("Exec")) ); 
     933     
     934     
    999935  ui->push_xdg_savechanges->setEnabled(FALSE); 
    1000936  ui->push_xdg_savenew->setEnabled(FALSE); 
  • src-qt4/EasyPBI-devel/mainGUI.h

    ra51ecee r0d8df9e  
    2121#include "config.h" 
    2222#include "PBIModule.h" 
     23#include "ModuleUtils.h" 
    2324 
    2425namespace Ui { 
Note: See TracChangeset for help on using the changeset viewer.