comit the changes for quick-widgets-0.2.1
[quick-widgets] / plugins / qmlprocess / process.qml
1 import Qt 4.7
2 import qmlprocess
3
4 Item {
5      width: childrenRect.width
6      height: childrenRect.height
7
8      Rectangle {
9           id: bg
10           anchors.fill: txt
11           color: "blue"
12           opacity: 0.8
13           radius: 5
14      }
15      Text {
16           id: txt
17           smooth: true
18           font.pointSize: 12
19           wrapMode: Text.Wrap
20           text: "Active Mem: MB"
21           verticalAlignment: Text.AlignVCenter
22           horizontalAlignment: Text.AlignHCenter
23           //width: parent.width
24           //height: parent.height
25           color: "white"
26      }
27      function parse(out) {
28           var x = out.match(/[0-9]+/gi);
29           console.log(x)
30           return "Active Mem: "+Math.round(x/1024)+ " MB"
31      }
32      Process {
33           id: process
34           command: "sh -c \"cat /proc/meminfo | /bin/grep 'Active:'\""
35           onCompleted: { txt.text = parse(stdout) }
36           onFailed: { bg.color = "red"; txt.text = stderr }
37      }
38      Timer {
39           running: runtime.isActiveWindow
40           repeat: true
41           interval: 5000
42           onTriggered: { process.run() }
43      }
44 }