diff options
author | pommicket <pommicket@gmail.com> | 2025-08-07 14:37:02 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-08-07 14:37:02 -0400 |
commit | 0b60755eb7c38ae2995690f57ce405b5f0052f0f (patch) | |
tree | d02420f60eb56e34610fefd7e5db7dab8c5c30d3 /quacker/macondo.cpp | |
parent | c68ac871c73ff4c76246fc49465f53f8befef92f (diff) |
Add macondo tab, run process
Diffstat (limited to 'quacker/macondo.cpp')
-rw-r--r-- | quacker/macondo.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp new file mode 100644 index 0000000..476d41b --- /dev/null +++ b/quacker/macondo.cpp @@ -0,0 +1,45 @@ +#include "macondo.h" +#include "quacker.h" + +#include <QGridLayout> +#include <QPushButton> +#include <QProcess> +#include <QTimer> + +Macondo::Macondo(QWidget *parent) : QWidget(parent) { + m_updateTimer = new QTimer(this); + QGridLayout *layout = new QGridLayout(this); + m_runButton = new QPushButton(tr("Run")); + layout->addWidget(m_runButton, 0, 0); + layout->setAlignment(Qt::AlignTop); + const char *home = getenv("HOME"); + // TODO: configurable path + m_execPath = home ? home : "/"; + m_execPath += "/apps/macondo/macondo"; + connect(m_runButton, SIGNAL(clicked()), this, SLOT(run())); + connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateResults())); + m_updateTimer->setInterval(100); +} + +void Macondo::run() { + if (m_process) return; + printf("running macondo %s\n", m_execPath.c_str()); + m_process = new QProcess; + QStringList args; + m_process->start(m_execPath.c_str(), args); + connect(m_process, SIGNAL(started()), this, SLOT(processStarted())); +} + +void Macondo::processStarted() { + m_updateTimer->start(); + m_process->write("help\n"); +} + +void Macondo::updateResults() { + QProcess::ProcessState state = m_process->state(); + QByteArray data = m_process->readAllStandardError(); + printf("%s",data.constData()); + data = m_process->readAllStandardOutput(); + printf("%s", data.constData()); + fflush(stdout); +} |