bool Helpers::viewFileWithApplication(const QString path) { qDebug() << "Opening " << path << " with external application"; const QString COMMAND = "xdg-open"; m_process = new QProcess(this); connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(handleProcessFinish(int, QProcess::ExitStatus))); connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError))); m_process->start(COMMAND, QStringList(path)); return true; }
void FileInfo::executeCommand(QString command, QStringList arguments) { m_processOutput.clear(); emit processOutputChanged(); // process is killed when Page is closed - should run this in bg thread to allow command finish(?) m_process = new QProcess(this); m_process->setReadChannel(QProcess::StandardOutput); m_process->setProcessChannelMode(QProcess::MergedChannels); // merged stderr channel with stdout channel connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readProcessChannels())); connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(handleProcessFinish(int, QProcess::ExitStatus))); connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError))); m_process->start(command, arguments); }
DGLDebugeeQTProcess::DGLDebugeeQTProcess(int port, bool modeEGL) : m_Port(port), m_Loaded(false), m_ModeEGL(modeEGL), m_PortStr(boost::lexical_cast<std::string>(getPort())), m_SemLoaderStr("sem_loader_" + m_PortStr), m_SemOpenGLStr("sem_" + m_PortStr), m_SemLoader(boost::interprocess::open_or_create, m_SemLoaderStr.c_str(), 0), m_SemOpenGL(boost::interprocess::open_or_create, m_SemOpenGLStr.c_str(), 0), m_PollTimer(new QTimer(this)) { CONNASSERT(m_PollTimer, SIGNAL(timeout()), this, SLOT(pollReady())); CONNASSERT(getProcess(), SIGNAL(started()), this, SLOT(startPolling())); CONNASSERT(getProcess(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError))); CONNASSERT(getProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(handleProcessFinished(int, QProcess::ExitStatus))); }
bool ConsoleModel::executeCommand(QString command, QStringList arguments) { // don't execute the command if an old command is still running if (m_process && m_process->state() != QProcess::NotRunning) { // if the old process doesn't stop in 1/2 secs, then don't run the new command if (!m_process->waitForFinished(500)) return false; } setLines(QStringList()); m_process = new QProcess(this); m_process->setReadChannel(QProcess::StandardOutput); m_process->setProcessChannelMode(QProcess::MergedChannels); // merged stderr channel with stdout channel connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readProcessChannels())); connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(handleProcessFinish(int, QProcess::ExitStatus))); connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError))); m_process->start(command, arguments); // the process is killed when ConsoleModel is destroyed (usually when Page is closed) // should we run the process in bg thread to allow the command to finish(?) return true; }
CHoloPropagLargeEditor::CHoloPropagLargeEditor(const QString & hist_file, QWidget *parent) : QWidget(parent), m_HoloPropagLarge_proc(), m_caption(0), m_cfg_file(0), m_binary_file(0), m_pb_run(0), m_pb_reload(0), m_pb_save(0), m_HoloPropagLarge_output(0), m_entry_Lambda(0), m_entry_Pitch(0), m_entry_ForceSettings(0), m_entry_RandomizePhase(0), m_entry_ImageContainsIntensity(0), m_entry_ImageContainsAmplitude(0), m_entry_ImageContainsPhase(0), m_entry_Input(0), m_entry_Target(0), m_entry_ImageIntensityMaximum(0), m_entry_ImageIntensityMinimum(0), m_entry_Frame(0), m_entry_FrameX(0), m_entry_FrameY(0), m_entry_FrameRemove(0), m_entry_Operations(0) { /* set up DFtoHologram process */ m_HoloPropagLarge_proc.setProcessChannelMode(QProcess::MergedChannels); // redirect stderr to stdout connect(&m_HoloPropagLarge_proc, SIGNAL(readyReadStandardOutput()), SLOT(handleStdoutRead())); connect(&m_HoloPropagLarge_proc, SIGNAL(error(QProcess::ProcessError)), SLOT(handleProcessError(QProcess::ProcessError))); connect(&m_HoloPropagLarge_proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(handleProcessFinished(int, QProcess::ExitStatus))); /* create UI */ m_caption = new QLabel(tr("HoloPropagLarge Editor")); m_caption->setAlignment(Qt::AlignCenter); m_caption->setStyleSheet("font-size: 16px; font-weight: bold;"); m_HoloPropagLarge_output = new QTextEdit; QVBoxLayout *vl = new QVBoxLayout; vl->addSpacing(20); vl->addWidget(m_caption); vl->addSpacing(30); vl->addWidget(createSystemInfo()); vl->addWidget(createGroupEntries()); vl->addWidget(createGroupImageContains()); vl->addWidget(createGroupFrame()); vl->addWidget(createGroupOperations()); vl->addWidget(m_HoloPropagLarge_output, 1); vl->addLayout(createButtons()); setLayout(vl); if (!hist_file.isNull()) { /* reload the config' history */ loadHistory(hist_file); /* realod the first config file */ reload(); } /* connect a signal for automatic reloading each time a new config is picked */ connect(m_cfg_file, SIGNAL(picked()), SLOT(reload())); }
void CSavedProjectsTableView::runProjectScript(QModelIndex index) { QProcess script_process; QObject::connect(&script_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError))); SProjectInfo saved_project_info = this->_model->getList().at(index.row()); script_process.setWorkingDirectory(saved_project_info._location); script_process.start(saved_project_info._run_script); if (script_process.waitForFinished()) { emit scriptRunSuccessfully(); } }