You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
QML
44 lines
1.2 KiB
QML
import QtQuick 2.0
|
|
import Process 1.0
|
|
|
|
Process {
|
|
property string binary
|
|
property variant arguments
|
|
|
|
signal hasFinished(exitCode: int, stdout: string, stderr: string)
|
|
signal hasSuccess(stdout: string, stderr: string)
|
|
signal hasError(exitCode: int, stdout: string, stderr: string)
|
|
signal stdout(stdout_chunk: string)
|
|
signal stderr(stderr_chunk: string)
|
|
|
|
property string entire_stdout: ""
|
|
property string entire_stderr: ""
|
|
|
|
id: process
|
|
|
|
function run(_binary: string, _arguments: variant){
|
|
if(typeof _arguments == "string"){
|
|
_arguments = [_arguments]
|
|
}
|
|
binary = _binary
|
|
arguments = _arguments
|
|
process.start(binary, arguments)
|
|
}
|
|
|
|
onReadyRead: {
|
|
let stdout_chunk = readAllStandardOutput()
|
|
entire_stdout += stdout_chunk
|
|
process.stdout(stdout_chunk)
|
|
}
|
|
|
|
onFinished: {
|
|
entire_stderr = readAllStandardError()
|
|
if (exitCode === 0) {
|
|
process.hasSuccess(entire_stdout, entire_stderr)
|
|
} else {
|
|
process.hasError(exitCode, entire_stdout, entire_stderr)
|
|
}
|
|
process.hasFinished(exitCode, entire_stdout, entire_stderr)
|
|
}
|
|
}
|