source: src-qt4/pc-sysmanager/cmdDialog.cpp @ 8d1c3e0

releng/10.0releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 8d1c3e0 was 8d1c3e0, checked in by Ken Moore <ken@…>, 8 months ago

Clean up all the rest of the compile warnings, and adjust the main UI to specify that it is the PC-BSD source/ports trees.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1#include "cmdDialog.h"
2#include "ui_cmdDialog.h"
3
4CMDDialog::CMDDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CMDDialog){
5  ui->setupUi(this); //load the designer UI file
6  //Setup the backend process class
7  PROC = new gitProc;
8    connect(PROC, SIGNAL(ProcMessage(QString)), this, SLOT(NewMessage(QString)) );
9    connect(PROC, SIGNAL(procFinished(bool)), this, SLOT(Finished(bool)) );
10  //Setup internal flags
11  initPorts = false; initSource = false; //make sure these are both initially disabled
12  connect(ui->push_close, SIGNAL(clicked()), this, SLOT(CloseUI()) );   
13}
14
15CMDDialog::~CMDDialog(){
16  delete PROC; 
17}
18
19void CMDDialog::start(QString cmdtype){
20  if(PROC->isRunning()){
21    qDebug() << "ERROR: Process is already working: please wait until it is finished";
22    return;
23  }
24  ui->push_close->setEnabled(false); //make sure they cannot close this while it is running
25  if(cmdtype.toLower() == "ports"){
26    //Check for if the port tree needs to be initialized first
27    qDebug() << "WARNING: Ports init check still needs to be implemented";
28    bool init = true;
29    if(init){
30      initPorts = true; //set the internal flag
31      ui->textEdit->setPlainText("Starting Ports Tree Initialization....");
32      bool ok = PROC->startInitPorts();
33      if(!ok){ 
34        ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/ports");
35        ui->push_close->setEnabled(true); //they can now close the window
36      }
37    }else{
38      ui->textEdit->setPlainText("Fetching the Ports Tree....");
39      bool ok = PROC->startPorts();
40      if(!ok){ 
41        ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports");
42        ui->push_close->setEnabled(true); //they can now close the window
43      }
44    }
45  }else if(cmdtype.toLower() == "source"){
46    //Check for if the source tree needs to be initialized first
47    qDebug() << "WARNING: Source init check still needs to be implemented";
48    bool init = true;
49    if(init){
50      initSource = true; //set the internal flag
51      ui->textEdit->setPlainText("Starting Source Tree Initialization....");
52      bool ok = PROC->startInitSource();
53      if(!ok){ 
54        ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/src");
55        ui->push_close->setEnabled(true); //they can now close the window
56      }
57    }else{
58      ui->textEdit->setPlainText("Fetching the Source Tree....");
59      bool ok = PROC->startSource();
60      if(!ok){ 
61        ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src");
62        ui->push_close->setEnabled(true); //they can now close the window
63      }
64    }
65  }else{
66    ui->textEdit->setPlainText("Unknown CMD Type: "+cmdtype);
67    ui->push_close->setEnabled(true);
68  }
69}
70
71// =====================
72void CMDDialog::NewMessage(QString msg){
73  ui->textEdit->appendPlainText("\n"+msg); //make sure it is on the next line each time
74}
75
76void CMDDialog::Finished(bool ok){
77  if(!ok){
78    ui->textEdit->appendPlainText("\n=============\nProcess Completed Unsuccessfully");
79    ui->push_close->setEnabled(true); //enabled the close button
80  }else if(initPorts){
81    initPorts = false; //make sure it doesn't fall into this catch again
82    //ports tree initialized successfully - start the fetch process
83    ui->textEdit->appendPlainText("\n=============\nFetching the Ports Tree....");
84    bool ok = PROC->startPorts();
85    if(!ok){ 
86      ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports");
87      ui->push_close->setEnabled(true); //they can now close the window
88    }
89  }else if(initSource){
90    initSource = false; //make sure it doesn't fall into this catch again
91    //Source tree initialized successfully - start the fetch process
92    ui->textEdit->appendPlainText("\n=============\nFetching the Source Tree....");
93    bool ok = PROC->startPorts();
94    if(!ok){ 
95      ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src");
96      ui->push_close->setEnabled(true); //they can now close the window
97    }
98  }else{
99    ui->textEdit->appendPlainText("\n=============\nFinished Successfully");
100  }
101}
102
103void CMDDialog::CloseUI(){
104  this->close();
105}
Note: See TracBrowser for help on using the repository browser.