Changeset 8f95077


Ignore:
Timestamp:
01/07/14 12:57:47 (16 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
8a4c7a0
Parents:
1f0325a
Message:

Large update to the new GIT usage for the system manager. It should be almost finished, it still just needs the proper branch detection for source checkouts (and maybe ports checkouts, but I think we always want the master branch for ports by default).

Location:
src-qt4/pc-sysmanager
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-sysmanager/cmdDialog.cpp

    ra4325b4 r8f95077  
    88    connect(PROC, SIGNAL(ProcMessage(QString)), this, SLOT(NewMessage(QString)) ); 
    99    connect(PROC, SIGNAL(ProcFinished()), this, SLOT(Finished()) ); 
    10   //Setup internal flags 
    11   connect(ui->push_close, SIGNAL(clicked()), this, SLOT(CloseUI()) );    
     10  //Setup internal connections 
     11  connect(ui->push_close, SIGNAL(clicked()), this, SLOT(CloseUI()) ); 
     12  connect(ui->push_stop, SIGNAL(clicked()), this, SLOT(stopProcess()) ); 
    1213} 
    1314 
     
    2526  QStringList cmds, dirs, info; //For generating the necessary input to the backend 
    2627  if(cmdtype.toLower() == "ports"){ 
     28    this->setWindowTitle(tr("Getting PC-BSD Ports Tree")); 
    2729    //Check for if the port tree needs to be initialized first 
    2830    qDebug() << "WARNING: Ports init check still needs to be implemented"; 
     
    3234      ui->textEdit->setPlainText("Starting Ports Tree Initialization...."); 
    3335      if(QFile::exists("/usr/ports")){ 
    34         cmds << "rm -rf /usr/ports/*"; info << "Removing the old ports tree"; dirs << ""; //Clean the old ports tree 
     36        cmds << "rm -rf /usr/ports/* /usr/ports/.g*"; info << "Removing the old ports tree"; dirs << ""; //Clean the old ports tree 
    3537      }else{ 
    36         cmds << "mkdir /usr/ports"; info << "Creating the ports tree"; dirs << ""; //Create the source tree 
     38        cmds << "mkdir /usr/ports"; info << "Creating the ports tree"; dirs << ""; //Create the ports tree 
    3739      } 
    3840      cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/ports"; //setup git 
     41      cmds << "git remote remove origin"; info << ""; dirs <<"/usr/ports"; 
    3942      cmds << "git remote add origin https://www.github.com/pcbsd/freebsd-ports.git"; info << ""; dirs << "/usr/ports/.git"; //setup PC-BSD git repo 
    4043    }else{ 
     
    4245    } 
    4346    //Now create the git update commands 
    44     cmds << "git fetch --depth=1"; info << "Fetch new GIT info"; dirs << "/usr/ports/.git"; 
    45     cmds << "git checkout -t origin/master"; info << "Checkout the tree"; dirs << "/usr/ports/.git";  
     47    cmds << "git fetch --depth=1"; info << "Fetch new GIT info (this may take a while)"; dirs << "/usr/ports/.git"; 
     48    cmds << "git checkout master"; info << "Checkout the tree"; dirs << "/usr/ports";  
    4649 
    4750  }else if(cmdtype.toLower() == "source"){ 
     51    this->setWindowTitle(tr("Getting PC-BSD Sources")); 
    4852    //Check for if the source tree needs to be initialized first 
    4953    qDebug() << "WARNING: Source init check still needs to be implemented"; 
     
    5357      ui->textEdit->setPlainText("Starting Source Tree Initialization...."); 
    5458      if(QFile::exists("/usr/src")){ 
    55         cmds << "rm -rf /usr/src/*"; info << "Removing the old source tree"; dirs << ""; //Clean the old source tree 
     59        cmds << "rm -rf /usr/src/* /usr/src/.g*"; info << "Removing the old source tree"; dirs << ""; //Clean the old source tree 
    5660      }else{ 
    57         cmds << "mkdir /usr/src"; info << "Creating the source tree"; dirs << ""; //Create the source tree 
     61        cmds << "mkdir /usr/src"; info << "Creating the source tree"; dirs << ""; //Create the source tree 
    5862      } 
    5963      cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/src"; //setup git 
     64      cmds << "git remote remove origin"; info << ""; dirs <<"/usr/src"; 
    6065      cmds << "git remote add origin https://www.github.com/pcbsd/freebsd.git"; info << ""; dirs << "/usr/src/.git"; //setup PC-BSD git repo 
    6166    }else{ 
     
    6368    } 
    6469    //Now create the git update commands 
    65     cmds << "git fetch --depth=1"; info << "Fetch new GIT info"; dirs << "/usr/src/.git"; 
    66     cmds << "git checkout -t origin/master"; info << "Checkout the tree"; dirs << "/usr/src/.git";  
     70    cmds << "git fetch --depth=1"; info << "Fetch new GIT info (this may take a while)"; dirs << "/usr/src/.git"; 
     71    cmds << "git checkout master"; info << "Checkout the right version of the tree"; dirs << "/usr/src";  
    6772  }else{ 
    6873    ui->textEdit->setPlainText("Unknown CMD Type: "+cmdtype); 
    6974    ui->push_close->setEnabled(true); 
     75    ui->push_stop->setEnabled(false); 
    7076    return; 
    7177  } 
    7278  PROC->startCMDs(cmds, dirs, info); 
     79  ui->push_stop->setEnabled(PROC->isRunning()); 
    7380} 
    7481 
     82bool CMDDialog::isRunning(){ 
     83  return PROC->isRunning(); 
     84} 
    7585// ===================== 
    7686void CMDDialog::NewMessage(QString msg){ 
    77   ui->textEdit->appendPlainText("\n"+msg); //make sure it is on the next line each time  
     87  if(!msg.isEmpty()){ 
     88    //if(!msg.startsWith("\n")){ msg.prepend("\n"); } //make sure it is on a new line 
     89    ui->textEdit->appendPlainText(msg); //make sure it is on the next line each time     
     90  } 
    7891} 
    7992 
    8093void CMDDialog::Finished(){ 
    81     ui->push_close->setEnabled(true); //enabled the close button 
     94    ui->push_close->setEnabled(true); //enable the close button 
     95    ui->push_stop->setEnabled(PROC->isRunning()); 
    8296} 
    8397 
     
    8599  this->close(); 
    86100} 
     101 
     102void CMDDialog::stopProcess(){ 
     103  PROC->stopProc(); 
     104  //PROC should emit the finished signal once done stopping 
     105} 
     106 
     107void CMDDialog::closeEvent(QCloseEvent *event){ 
     108  //Make sure the user does not close this window while a process is running 
     109  event->ignore(); 
     110  if(!ui->push_close->isEnabled()){ 
     111    QMessageBox::warning(this, tr("Process Running"), tr("Please stop the current process before closing this window.") ); 
     112  }else{ 
     113    //Make sure this window is only hidden (pbsystemtab needs to make sure it always exists for checks); 
     114    this->hide(); 
     115  } 
     116} 
  • src-qt4/pc-sysmanager/cmdDialog.h

    ra4325b4 r8f95077  
    55#include <QString> 
    66#include <QWidget> 
     7#include <QMessageBox> 
    78 
    89#include "longProc.h" 
     
    1920 
    2021        void start(QString cmdtype); 
     22        bool isRunning(); 
    2123 
    2224private: 
     
    2830        void Finished(); 
    2931        void CloseUI(); 
     32        void stopProcess(); 
     33 
     34protected: 
     35        void closeEvent(QCloseEvent *event); 
    3036}; 
    3137#endif 
  • src-qt4/pc-sysmanager/cmdDialog.ui

    r6d7b1e6 r8f95077  
    1616  <layout class="QVBoxLayout" name="verticalLayout"> 
    1717   <item> 
    18     <widget class="QPlainTextEdit" name="textEdit"/> 
     18    <widget class="QPlainTextEdit" name="textEdit"> 
     19     <property name="readOnly"> 
     20      <bool>true</bool> 
     21     </property> 
     22    </widget> 
    1923   </item> 
    2024   <item> 
    2125    <layout class="QHBoxLayout" name="horizontalLayout"> 
     26     <item> 
     27      <widget class="QPushButton" name="push_stop"> 
     28       <property name="text"> 
     29        <string>Stop</string> 
     30       </property> 
     31      </widget> 
     32     </item> 
    2233     <item> 
    2334      <spacer name="horizontalSpacer"> 
     
    4455  </layout> 
    4556 </widget> 
    46  <resources/> 
     57 <resources> 
     58  <include location="PBSystem.qrc"/> 
     59 </resources> 
    4760 <connections/> 
    4861</ui> 
  • src-qt4/pc-sysmanager/longProc.cpp

    r1f0325a r8f95077  
    88  connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(parseUpdate()) ); 
    99  connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(procDone()) ); 
    10   running = false; 
     10  running = false; stopped = false; 
    1111  cmdList.clear(); dirList.clear(); infoList.clear(); 
     12  timer = new QTimer(); 
     13        timer->setSingleShot(true); 
     14        timer->setInterval(10000); //10 second ping to make sure user knows it is still running 
     15  connect(timer, SIGNAL(timeout()), this, SLOT(procTimeout()) ); 
    1216} 
    1317 
     
    3438  if( !infoList[currentItem].isEmpty() ){ emit ProcMessage("--- "+infoList[currentItem]+" ---"); } 
    3539  if( !dirList[currentItem].isEmpty() && QFile::exists(dirList[currentItem]) ){ process->setWorkingDirectory(dirList[currentItem]); } 
     40  timer->start(); 
    3641  process->start(cmdList[currentItem]); 
    3742  running = true; 
     
    3944} 
    4045 
     46void LongProc::stopProc(){ 
     47  stopped = true; 
     48  process->terminate(); 
     49} 
    4150// ==================== 
    4251//   STATIC PUBLIC FUNCTIONS 
     
    6170    emit ProcMessage(output); 
    6271  } 
     72  timer->start(); //reset the timer 
    6373} 
    6474 
     
    6676  //Start the next command if there is one 
    6777  bool success = (process->exitCode() == 0); 
    68   if( currentItem+1 < cmdList.length() && success){ 
     78  if( currentItem+1 < cmdList.length() && success && !stopped){ 
    6979    currentItem++; 
    7080    if( !infoList[currentItem].isEmpty() ){ emit ProcMessage("\n--- "+infoList[currentItem]+" ---"); } 
    7181    if( !dirList[currentItem].isEmpty() && QFile::exists(dirList[currentItem]) ){ process->setWorkingDirectory(dirList[currentItem]); } 
    7282    process->start(cmdList[currentItem]); 
     83    timer->start(); //reset timer 
    7384  }else{ 
    7485    //All finished 
    75     if(success){ 
    76       emit ProcMessage(" ---- FINISHED ----"); 
     86    if(stopped){ 
     87      emit ProcMessage("\n ---- KILLED ----"); 
     88      stopped=false; //reset flag 
     89    }else if(success){ 
     90      emit ProcMessage("\n ---- FINISHED ----"); 
    7791    }else{ 
    78       emit ProcMessage(" ---- ERROR ----"); 
     92      emit ProcMessage("\n ---- ERROR ----"); 
    7993    } 
    8094    running = false; 
    8195    emit ProcFinished(); 
     96    timer->stop(); 
    8297  } 
    8398} 
     99 
     100void LongProc::procTimeout(){ 
     101  emit ProcMessage("."); //just to make sure that a quiet and long process still looks active to the user 
     102  timer->start(); //restart the timer 
     103} 
  • src-qt4/pc-sysmanager/longProc.h

    r1f0325a r8f95077  
    99#include <QCoreApplication> 
    1010#include <QDebug> 
     11#include <QTimer> 
    1112 
    1213class LongProc : public QObject{ 
     
    1920        //Quick-start functions for specific tasks 
    2021        bool startCMDs(QStringList cmds, QStringList dirs, QStringList info); 
    21          
     22        void stopProc(); 
     23 
    2224        //Information functions 
    2325        bool isRunning(){ return running; } //so you can double check whether it is still running 
     
    2830private: 
    2931        QProcess *process; 
    30         bool running; 
     32        bool running, stopped; 
    3133        QStringList cmdList, infoList, dirList; 
    3234        int currentItem; 
     35        QTimer *timer; 
    3336 
    3437private slots: 
    3538        void parseUpdate(); //New process message from internal worker 
    3639        void procDone(); //internal worker finished 
     40        void procTimeout(); //internal timeout signal 
    3741 
    3842signals: 
  • src-qt4/pc-sysmanager/pbsystemtab.cpp

    ra4325b4 r8f95077  
    6969    connect(fetchSourceBut, SIGNAL( clicked() ), this, SLOT( fetchSourcePressed() ) ); 
    7070    connect(fetchPortsBut, SIGNAL( clicked() ), this, SLOT( fetchPortsPressed() ) ); 
     71     
     72    cmdDlg = new CMDDialog(this); 
     73    cmdDlg->hide(); 
    7174} 
    7275 
     
    207210void PBSystemTab::fetchSourcePressed() 
    208211{ 
    209     portsnapUI = new CMDDialog(this); 
    210     portsnapUI->start("source"); //Version not implemented yet 
    211     portsnapUI->show(); 
     212    if(cmdDlg->isRunning() ){ 
     213      QMessageBox::warning(this, tr("Process Already Running"), tr("You already have a process running. Please wait for that one to finish first.") ); 
     214    }else{ 
     215      cmdDlg->start("source"); //Version not implemented yet 
     216      cmdDlg->show(); 
     217    } 
    212218} 
    213219 
    214220void PBSystemTab::fetchPortsPressed() 
    215221{ 
    216     portsnapUI = new CMDDialog(this); 
    217     portsnapUI->start("ports"); //Version not implemented yet 
    218     portsnapUI->show(); 
     222    if(cmdDlg->isRunning() ){ 
     223      QMessageBox::warning(this, tr("Process Already Running"), tr("You already have a process running. Please wait for that one to finish first.") ); 
     224    }else{ 
     225      cmdDlg->start("ports"); //Version not implemented yet 
     226      cmdDlg->show(); 
     227    } 
    219228} 
    220229 
     
    372381  QNetworkProxy::setApplicationProxy(proxy); 
    373382} 
     383 
     384void PBSystemTab::closeEvent(QCloseEvent *event){ 
     385    if(cmdDlg->isRunning()){ 
     386      //Process Running - minimize the main window instead 
     387      event->ignore(); 
     388      this->showMinimized(); 
     389    } 
     390} 
  • src-qt4/pc-sysmanager/pbsystemtab.h

    r7cd7e8f r8f95077  
    1212#include <QTextStream> 
    1313#include <QTimer> 
     14#include <QCloseEvent> 
    1415 
    1516#include <pcbsd-utils.h> 
     
    7576    QProcess *GetPBVer; 
    7677    QProcess *GetUname; 
    77     CMDDialog *portsnapUI; 
     78    CMDDialog *cmdDlg; 
    7879    QString username; 
    7980    bool miscChanged; 
     
    140141    metaWidget *pkgWidget; 
    141142 
     143protected: 
     144        void closeEvent(QCloseEvent *event); 
    142145 
    143146signals: 
Note: See TracChangeset for help on using the changeset viewer.