avrOutputDialog::avrOutputDialog(QWidget *parent, QString prog, QStringList arg, QString wTitle, int closeBehaviour) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), ui(new Ui::avrOutputDialog) { ui->setupUi(this); if(wTitle.isEmpty()) setWindowTitle(tr("AVRDUDE result")); else setWindowTitle(tr("AVRDUDE - ") + wTitle); cmdLine = prog; foreach(QString str, arg) cmdLine.append(" " + str); closeOpt = closeBehaviour; lfuse = 0; hfuse = 0; efuse = 0; process = new QProcess(this); connect(process,SIGNAL(readyReadStandardError()), this, SLOT(doAddTextStdErr())); connect(process,SIGNAL(started()),this,SLOT(doProcessStarted())); connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(doAddTextStdOut())); connect(process,SIGNAL(finished(int)),this,SLOT(doFinished(int))); process->start(prog,arg); }
avrOutputDialog::avrOutputDialog(QWidget *parent, QString prog, QStringList arg, QString wTitle, int closeBehaviour, bool displayDetails) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), ui(new Ui::avrOutputDialog), kill_timer(NULL), hasErrors(false) { ui->setupUi(this); #ifdef __APPLE__ QFont newFont("Courier", 13); ui->plainTextEdit->setFont(newFont); ui->plainTextEdit->setAttribute(Qt::WA_MacNormalSize); #endif #if defined WIN32 || !defined __GNUC__ QFont newFont("Courier", 9); ui->plainTextEdit->setFont(newFont); #endif cmdLine = prog; closeOpt = closeBehaviour; if (cmdLine.isEmpty()) { if (arg.count()<2) { closeOpt = AVR_DIALOG_FORCE_CLOSE; QTimer::singleShot(0, this, SLOT(forceClose())); } else { sourceFile=arg.at(0); destFile=arg.at(1); if (!displayDetails) { ui->plainTextEdit->hide(); QTimer::singleShot(0, this, SLOT(shrink())); } else { ui->checkBox->setChecked(true); } ui->progressBar->setMaximum(127); QTimer::singleShot(500, this, SLOT(doCopy())); } } else { if (wTitle.isEmpty()) setWindowTitle(getProgrammer() + " " + tr("result")); else setWindowTitle(getProgrammer() + " - " + wTitle); QFile exec; winTitle=wTitle; if (!(exec.exists(prog))) { QMessageBox::critical(this, "Companion", getProgrammer() + " " + tr("executable not found")); closeOpt = AVR_DIALOG_FORCE_CLOSE; QTimer::singleShot(0, this, SLOT(forceClose())); } else { foreach(QString str, arg) cmdLine.append(" " + str); lfuse = 0; hfuse = 0; efuse = 0; phase=0; currLine.clear(); if (!displayDetails) { ui->plainTextEdit->hide(); QTimer::singleShot(0, this, SLOT(shrink())); } else { ui->checkBox->setChecked(true); } process = new QProcess(this); connect(process,SIGNAL(readyReadStandardError()), this, SLOT(doAddTextStdErr())); connect(process,SIGNAL(started()),this,SLOT(doProcessStarted())); connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(doAddTextStdOut())); connect(process,SIGNAL(finished(int)),this,SLOT(doFinished(int))); #if !__GNUC__ kill_timer = new QTimer(this); connect(kill_timer, SIGNAL(timeout()), this, SLOT(killTimerElapsed())); kill_timer->start(2000); #endif process->start(prog,arg); } } }