-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiofunctions.cpp
41 lines (36 loc) · 1.2 KB
/
iofunctions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "iofunctions.h"
#include "pipereader.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QVariant>
#include <QWindow>
#include <QDebug>
#include <exception>
IOFunctions::IOFunctions(QObject *r, QThread *pipereader, QObject *parent) : QObject(parent)
{
this->mainwin = r;
this->state = r->findChild<QObject*>("stateObject");
this->control = r->findChild<QObject*>("controlObject");
this->listener = pipereader;
}
void IOFunctions::putStrSlot(QString msg) {
QTextStream(stdout) << msg << endl;
}
void IOFunctions::sendToQML(QString msg) {
if (msg == "stop") {
control->setProperty("dismiss",QVariant(1));
} else if (msg == "hide") {
mainwin->setProperty("visibility", QWindow::Hidden);
} else if (msg == "show") {
mainwin->setProperty("visibility", QWindow::AutomaticVisibility);
} else {
QJsonDocument jsdoc = QJsonDocument::fromJson(msg.toUtf8());
QJsonObject jsobj = jsdoc.object();
foreach(QString k,jsobj.keys()) {
state->setProperty(k.toLocal8Bit().data(), jsobj.take(k).toVariant());
};
}
}
void IOFunctions::reportError(QString err) {
//qDebug() << "ERROR in Pipe Reader: " << err << endl;
}