DlgRunExternal.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <QFileDialog>
00027 # include <QMessageBox>
00028 #endif
00029
00030 #include "Application.h"
00031 #include "MainWindow.h"
00032 #include "DlgRunExternal.h"
00033 #include "FileDialog.h"
00034
00035 #include "ui_DlgRunExternal.h"
00036
00037
00038 using namespace Gui::Dialog;
00039
00040
00041
00049 DlgRunExternal::DlgRunExternal( QWidget* parent, Qt::WFlags fl )
00050 : QDialog(parent, fl),process(this),advancedHidden(true)
00051 {
00052 ui = new Ui_DlgRunExternal();
00053 ui->setupUi(this);
00054 connect(&process,SIGNAL(finished(int, QProcess::ExitStatus)),
00055 this,SLOT(finished(int, QProcess::ExitStatus)));
00056 connect(ui->buttonAccept,SIGNAL(clicked()),this,SLOT(accept()));
00057 connect(ui->buttonDiscard,SIGNAL(clicked()),this,SLOT(reject()));
00058 connect(ui->buttonAbort,SIGNAL(clicked()),this,SLOT(abort()));
00059 connect(ui->buttonAdvanced,SIGNAL(clicked()),this,SLOT(advanced()));
00060
00061 ui->gridLayout->setSizeConstraint(QLayout::SetFixedSize);
00062 ui->extensionWidget->hide();
00063 }
00064
00068 DlgRunExternal::~DlgRunExternal()
00069 {
00070
00071 delete ui;
00072 }
00073
00074 int DlgRunExternal::Do(void)
00075 {
00076 QFileInfo ifo (ProcName);
00077
00078 ui->programName->setText(ifo.baseName());
00079 ui->programPath->setText(ProcName);
00080 process.start(ProcName,arguments);
00081
00082 ui->buttonAccept->setEnabled(false);
00083 ui->buttonDiscard->setEnabled(false);
00084 return exec();
00085 }
00086
00087 void DlgRunExternal::reject (void)
00088 {
00089 QDialog::reject();
00090 }
00091
00092 void DlgRunExternal::accept (void)
00093 {
00094 QDialog::accept();
00095 }
00096
00097 void DlgRunExternal::abort (void)
00098 {
00099 process.terminate();
00100 DlgRunExternal::reject();
00101 }
00102
00103 void DlgRunExternal::advanced (void)
00104 {
00105 if (advancedHidden){
00106 ui->extensionWidget->show();
00107 advancedHidden = false;
00108 }
00109 else {
00110 ui->extensionWidget->hide();
00111 advancedHidden = true;
00112 }
00113 }
00114
00115 void DlgRunExternal::finished (int exitCode, QProcess::ExitStatus exitStatus)
00116 {
00117 ui->buttonAccept->setEnabled(true);
00118 ui->buttonDiscard->setEnabled(true);
00119 ui->buttonAbort->setEnabled(false);
00120 }
00121
00122 void DlgRunExternal::on_chooseProgram_clicked()
00123 {
00124 QString fn;
00125 fn = QFileDialog::getOpenFileName(this, tr("Select a file"), ui->programPath->text());
00126 if (!fn.isEmpty()) {
00127 ui->programPath->setText(fn);
00128 }
00129 }
00130
00131 #include "moc_DlgRunExternal.cpp"
00132