This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
modern-linbo-gui/sources/legacy/linboMsgImpl.cc
Dorian Zedler d2a165a1ec
- Sorted some stuff
- Began to implement new GUI
2020-11-16 00:31:28 +01:00

90 lines
1.7 KiB
C++

#include "linboMsgImpl.hh"
#include <qapplication.h>
#include <unistd.h>
linboMsgImpl::linboMsgImpl( QWidget* parent ) : linboDialog()
{
Ui_linboMsg::setupUi((QDialog*)this);
process = new QProcess();
if( parent )
myParent = parent;
// connect SLOT for finished process
connect( process, SIGNAL(finished(int, QProcess::ExitStatus) ),
this, SLOT(processFinished(int, QProcess::ExitStatus)) );
// connect stdout and stderr to linbo console
connect( process, SIGNAL(readyReadStandardOutput()),
this, SLOT(readFromStdout()) );
connect( process, SIGNAL(readyReadStandardError()),
this, SLOT(readFromStderr()) );
}
linboMsgImpl::~linboMsgImpl()
{
}
void linboMsgImpl::precmd() {
// nothing to do
}
void linboMsgImpl::postcmd() {
// nothing to do
}
void linboMsgImpl::execute() {
QStringList processargs( arguments );
QString command = processargs.takeFirst();
process->start( command, processargs );
process->waitForStarted();
// wait until the process is finished
while(process->state() == QProcess::Running ) {
this->update();
qApp->processEvents();
}
}
void linboMsgImpl::setMainApp( QWidget* newMainApp ) {
if ( newMainApp ) {
myMainApp = newMainApp;
}
}
QStringList linboMsgImpl::getCommand() {
return arguments;
}
void linboMsgImpl::setCommand(const QStringList& arglist)
{
arguments = arglist;
}
void linboMsgImpl::readFromStdout()
{
message->setText( process->readAllStandardOutput() );
this->update();
}
void linboMsgImpl::readFromStderr()
{
// ignore this
// message->setText( process->readAllStandardError() );
}
void linboMsgImpl::processFinished( int retval,
QProcess::ExitStatus status) {
// let user read the process results
this->close();
}