comit the changes for quick-widgets-0.2.1
[quick-widgets] / plugins / qmlprocess / process.qml
diff --git a/plugins/qmlprocess/process.qml b/plugins/qmlprocess/process.qml
new file mode 100644 (file)
index 0000000..cd1fef2
--- /dev/null
@@ -0,0 +1,44 @@
+import Qt 4.7
+import qmlprocess
+
+Item {
+     width: childrenRect.width
+     height: childrenRect.height
+
+     Rectangle {
+         id: bg
+          anchors.fill: txt
+         color: "blue"
+         opacity: 0.8
+         radius: 5
+     }
+     Text {
+         id: txt
+         smooth: true
+         font.pointSize: 12
+         wrapMode: Text.Wrap
+         text: "Active Mem: MB"
+         verticalAlignment: Text.AlignVCenter
+         horizontalAlignment: Text.AlignHCenter
+         //width: parent.width
+         //height: parent.height
+         color: "white"
+     }
+     function parse(out) {
+         var x = out.match(/[0-9]+/gi);
+         console.log(x)
+         return "Active Mem: "+Math.round(x/1024)+ " MB"
+     }
+     Process {
+         id: process
+         command: "sh -c \"cat /proc/meminfo | /bin/grep 'Active:'\""
+         onCompleted: { txt.text = parse(stdout) }
+         onFailed: { bg.color = "red"; txt.text = stderr }
+     }
+     Timer {
+         running: runtime.isActiveWindow
+         repeat: true
+         interval: 5000
+         onTriggered: { process.run() }
+     }
+}
\ No newline at end of file