Commit 5145564d02d8c7e0d95cce6faaed51a1d5630cd8
1 parent
496eb90c
Exists in
master
Classe ConsoleObject feita, e teste da chamada de console() passando.
Showing
3 changed files
with
19 additions
and
4 deletions
Show diff stats
cacic-teste/testcacic.cpp
src/console.h
| ... | ... | @@ -2,16 +2,31 @@ |
| 2 | 2 | #define CONSOLE_H |
| 3 | 3 | |
| 4 | 4 | #include <QDebug> |
| 5 | +#include <QProcess> | |
| 5 | 6 | #include <QString> |
| 7 | +#include <QSysInfo> | |
| 6 | 8 | |
| 7 | 9 | class ConsoleObject:public std::unary_function<std::string,QString> |
| 8 | 10 | { |
| 9 | 11 | |
| 10 | 12 | public: |
| 11 | - QString operator() (std::string) | |
| 13 | + | |
| 14 | +#if defined(Q_OS_LINUX) | |
| 15 | + QString operator() (std::string input) | |
| 12 | 16 | { |
| 13 | - return ""; | |
| 17 | + QProcess* process = new QProcess(); | |
| 18 | + | |
| 19 | + QStringList options; | |
| 20 | + options << "-c" << QString::fromStdString(input); | |
| 21 | + process->start("/bin/sh", options); | |
| 22 | + process->waitForFinished(); | |
| 23 | + QString output = process->readAll(); | |
| 24 | +// qDebug() << output; | |
| 25 | + | |
| 26 | + delete process; | |
| 27 | + return output; | |
| 14 | 28 | } |
| 29 | +#endif | |
| 15 | 30 | }; |
| 16 | 31 | |
| 17 | 32 | #endif // CONSOLE_H | ... | ... |
src/operatingsystem.cpp