1 // -*- C++ -*- 2 // $Id: processwait.h,v 1.1 2009-07-05 21:14:56 robertl Exp $ 3 //------------------------------------------------------------------------ 4 // 5 // Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>. 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License as 9 // published by the Free Software Foundation; either version 2 of the 10 // License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 // General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, write to the Free Software 19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 20 // USA 21 // 22 //------------------------------------------------------------------------ 23 #ifndef PROCESSWAIT_H 24 #define PROCESSWAIT_H 25 26 27 #include <QProcess> 28 #include <QDialog> 29 #include <vector> 30 #include <string> 31 using std::string; 32 using std::vector; 33 34 class QProgressBar; 35 class QPlainTextEdit; 36 class QDialogButtonBox; 37 class QTimer; 38 //------------------------------------------------------------------------ 39 class ProcessWaitDialog: public QDialog 40 { 41 42 Q_OBJECT 43 44 public: 45 // 46 ProcessWaitDialog(QWidget *parent, QProcess *process); 47 ~ProcessWaitDialog(); 48 49 bool getExitedNormally(); 50 int getExitCode(); 51 QString getErrorString(); getOutputString()52 QString getOutputString() const {return outputString;}; 53 54 protected: 55 void closeEvent (QCloseEvent*event); 56 void appendToText(const char *); 57 QString processErrorString(QProcess::ProcessError err); 58 59 60 private slots: 61 void errorX(QProcess::ProcessError); 62 void finishedX(int exitCode, QProcess::ExitStatus); 63 void readyReadStandardErrorX(); 64 void readyReadStandardOutputX(); 65 void timeoutX(); 66 void stopClickedX(); 67 68 private: 69 vector <int> progressVals; 70 int progressIndex; 71 int stopCount; 72 string bufferedOut; 73 QProcess::ExitStatus estatus; 74 int ecode; 75 QProcess *process; 76 QProgressBar *progressBar; 77 QPlainTextEdit *textEdit; 78 QDialogButtonBox *buttonBox; 79 QTimer *timer; 80 QString errorString; 81 QString outputString; 82 }; 83 84 #endif 85