--- /dev/null
+plugins/qmlprocess/ProcessObject.cpp
\ No newline at end of file
--- /dev/null
+plugins/qmlprocess/ProcessObject.h
\ No newline at end of file
{
QString out(m_process->readAllStandardOutput());
qDebug() << "normal";
- emit completed(out);
+ emit completed(out.trimmed());
}
else
{
QString err(m_process->readAllStandardError());
qDebug() << "failed";
- emit failed(exitCode, err, m_process->error());
+ emit failed(exitCode, err.trimmed(), m_process->error());
}
}
else
--- /dev/null
+import Qt 4.7
+import qmlprocess 1.0
+//import "content"
+
+ Column {
+ id: col
+ spacing: 2
+ width: 210
+ height: childrenRect.height
+
+ ProcessLabel {
+ label: "Active:"
+ width: parent.width;
+ color: "grey"
+ command: "sh -c \"cat /proc/meminfo | /bin/grep 'Active:'\""
+ interval_in_sec: 5
+ }
+
+ ProcessLabel {
+ label: "Free:"
+ width: parent.width
+ color: "black"
+ interval_in_sec: 10
+ command: "sh -c \"cat /proc/meminfo | /bin/grep 'MemFree:'\""
+ }
+
+ ProcessLabel {
+ label: "Total:"
+ width: parent.width
+ color: "#222222"
+ interval_in_sec: 0
+ command: "sh -c \"cat /proc/meminfo | /bin/grep 'MemTotal:'\""
+ }
+}
+
--- /dev/null
+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
void qmlprocess::registerTypes(const char *uri)
{
- Q_ASSERT(uri == QLatin1String("quickwidget"));
+ Q_ASSERT(uri == QLatin1String("qmlprocess"));
qmlRegisterType<ProcessObject>(uri, 1, 0, "Process");
}
HEADERS += \
qmlprocess.h \
ProcessObject.h
+
+DESTDIR = qmlprocess
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qtlocal Debug</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/mar637/Documents/qmlprocess-build-desktop</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">6</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">false</value>
</valuemap>
<valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
</valuemap>
<value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">4</value>
<valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
- <valuelist key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments" type="QVariantList"/>
+ <valuelist key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments" type="QVariantList">
+ <value type="QString">-I</value>
+ <value type="QString">.</value>
+ <value type="QString">meminfo.qml</value>
+ </valuelist>
<value key="ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase" type="int">2</value>
- <value key="ProjectExplorer.CustomExecutableRunConfiguration.Executable" type="QString"></value>
+ <value key="ProjectExplorer.CustomExecutableRunConfiguration.Executable" type="QString">/var/tmp/mar637/qtsdk-2010.05/qt/bin/qmlviewer</value>
<value key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal" type="bool">false</value>
<valuelist key="ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
- <value key="ProjectExplorer.CustomExecutableRunConfiguration.UserName" type="QString"></value>
- <value key="ProjectExplorer.CustomExecutableRunConfiguration.UserSetName" type="bool">false</value>
+ <value key="ProjectExplorer.CustomExecutableRunConfiguration.UserName" type="QString">qmlviewer</value>
+ <value key="ProjectExplorer.CustomExecutableRunConfiguration.UserSetName" type="bool">true</value>
<value key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory" type="QString">$BUILDDIR</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Custom Executable</value>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmlviewer</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.CustomExecutableRunConfiguration</value>
</valuemap>
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
--- /dev/null
+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() }
+ }
+ }
--- /dev/null
+ProcessLabel 1.0 ProcessLabel.qml
+plugin qmlprocess