X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=plugins%2Fqmlprocess%2Fqmlprocess%2FProcessLabel.qml;fp=plugins%2Fqmlprocess%2Fqmlprocess%2FProcessLabel.qml;h=5ac5d56a70f9d3cdf6689324ffd236efaee13ea5;hb=b2aaae15f1f7d85835f768d566b09a24774adef8;hp=0000000000000000000000000000000000000000;hpb=40e3b10727452efa67a827ac467a9c2453ea0dfa;p=quick-widgets diff --git a/plugins/qmlprocess/qmlprocess/ProcessLabel.qml b/plugins/qmlprocess/qmlprocess/ProcessLabel.qml new file mode 100644 index 0000000..5ac5d56 --- /dev/null +++ b/plugins/qmlprocess/qmlprocess/ProcessLabel.qml @@ -0,0 +1,75 @@ +import Qt 4.7 +//import quickwidgets 1.0 + +Rectangle { + id: proclabel + width: 100 + height: childrenRect.height + color: "blue" + opacity: 0.8 + radius: 5 + + function parse(stdout) { + var rx = /[0-9]+/gi; + var val = stdout.match(rx) + return String(val) + } + + property string command: "sh -c \"cat /proc/meminfo | /bin/grep 'Active:'\"" + property string label: "Value:" + property string textcolor: "white" + property real interval_in_sec: 5 + + function setText() { + txt.text = txt.stagedtxt + } + + Text { + property string stagedtxt: "" + id: txt + smooth: true + font.pointSize: 16 + anchors.right: proclabel.right + anchors.margins: 5 + text: "" + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignRight + color: proclabel.textcolor + Behavior on stagedtxt { + SequentialAnimation { + NumberAnimation { target: txt; property: "opacity"; to: 0; duration: 300 } + ScriptAction { script: setText(); } + NumberAnimation { target: txt; property: "opacity"; to: 1; duration: 500 } + } + } + } + + Text { + id: label + smooth: true + font.pointSize: 16 + font.weight: Font.Bold + anchors.left: proclabel.left + anchors.margins: 5 + text: proclabel.label + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + color: proclabel.textcolor + } + + Process { + id: process + command: proclabel.command + onCompleted: { txt.stagedtxt = parse(stdout);} + onFailed: { proclabel.color = "red"; txt.stagedtxt = stderr } + } + + Timer { + id: timer + triggeredOnStart: true + running: runtime.isActiveWindow + repeat: true + interval: proclabel.interval_in_sec*1000 + onTriggered: { process.run() } + } + }