-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
79 lines (49 loc) · 1.93 KB
/
main.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "mysysinfo.h"
#include <QApplication>
#include <QObject>
#include <QQmlApplicationEngine>
#include<QProcess>
#include<QDebug>
int main(int argc, char *argv[])
{
try {
QApplication app(argc, argv);
QString commands;
//Mac specific Terminal command
commands = "system_profiler SPHardwareDataType";
//commands = "cat abc"; /* Wrong cat file -- testing */
//commands = " abc"; /* Wrong Terminal command -- testing */
/* For Linux and Ubuntu we use -- cat /proc/cpuinfo*/
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QProcess *process = new QProcess(0);
process->setProcessChannelMode(QProcess::MergedChannels);
//process->start("system_profiler SPHardwareDataType");
process->start(commands);
QByteArray arrSysInfo;
process->write(arrSysInfo);
process->closeWriteChannel();
if(!process->waitForStarted()){
qDebug() << "Could not wait to start..."
<< process->error()
<< process->errorString();
}
if(!process->waitForFinished()) {
qDebug() << "Could not wait to finish..."
<< process->error()
<< process->errorString();
}
else{
mySysInfo output; /* interface */
output.setData( process->readAll());
QObject *rootObject = engine.rootObjects().first();
QObject* lstview = rootObject->findChild<QObject*>("lstview");
if (lstview)
lstview->setProperty("placeholderText", output.getData());//quick fix
}
return app.exec();
} catch(std::exception e) {\
qDebug() << "Exception caught in main()"
<< e.what();
}
}