comit the changes for quick-widgets-0.2.1
authorMalte Marquarding <malte@marquarding.com>
Fri, 26 Nov 2010 03:35:43 +0000 (14:35 +1100)
committerMalte Marquarding <malte@marquarding.com>
Fri, 26 Nov 2010 03:35:43 +0000 (14:35 +1100)
ProcessObject.cpp [new symlink]
ProcessObject.h [new symlink]
plugins/qmlprocess/ProcessObject.cpp
plugins/qmlprocess/meminfo.qml [new file with mode: 0644]
plugins/qmlprocess/process.qml [new file with mode: 0644]
plugins/qmlprocess/qmlprocess.cpp
plugins/qmlprocess/qmlprocess.pro
plugins/qmlprocess/qmlprocess.pro.user
plugins/qmlprocess/qmlprocess/ProcessLabel.qml [new file with mode: 0644]
plugins/qmlprocess/qmlprocess/qmldir [new file with mode: 0644]

diff --git a/ProcessObject.cpp b/ProcessObject.cpp
new file mode 120000 (symlink)
index 0000000..e64c8a1
--- /dev/null
@@ -0,0 +1 @@
+plugins/qmlprocess/ProcessObject.cpp
\ No newline at end of file
diff --git a/ProcessObject.h b/ProcessObject.h
new file mode 120000 (symlink)
index 0000000..a243678
--- /dev/null
@@ -0,0 +1 @@
+plugins/qmlprocess/ProcessObject.h
\ No newline at end of file
index 9e68381..c1dbdb3 100644 (file)
@@ -73,13 +73,13 @@ void ProcessObject::processFinished(int exitCode,
         {
             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
diff --git a/plugins/qmlprocess/meminfo.qml b/plugins/qmlprocess/meminfo.qml
new file mode 100644 (file)
index 0000000..b013d12
--- /dev/null
@@ -0,0 +1,35 @@
+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:'\""
+ }
+}
+
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
index 0ec99d1..9408193 100644 (file)
@@ -44,7 +44,7 @@
 
 void qmlprocess::registerTypes(const char *uri)
 {
-    Q_ASSERT(uri == QLatin1String("quickwidget"));
+    Q_ASSERT(uri == QLatin1String("qmlprocess"));
     qmlRegisterType<ProcessObject>(uri, 1, 0, "Process");
 }
 
index 73e7fbd..4f73aa0 100644 (file)
@@ -15,3 +15,5 @@ OTHER_FILES=qmldir
 HEADERS += \
     qmlprocess.h \
     ProcessObject.h
+
+DESTDIR = qmlprocess
index 91bd8a4..0f54791 100644 (file)
     <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>
diff --git a/plugins/qmlprocess/qmlprocess/ProcessLabel.qml b/plugins/qmlprocess/qmlprocess/ProcessLabel.qml
new file mode 100644 (file)
index 0000000..5ac5d56
--- /dev/null
@@ -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() }
+     }
+ }
diff --git a/plugins/qmlprocess/qmlprocess/qmldir b/plugins/qmlprocess/qmlprocess/qmldir
new file mode 100644 (file)
index 0000000..8e02799
--- /dev/null
@@ -0,0 +1,2 @@
+ProcessLabel 1.0 ProcessLabel.qml
+plugin qmlprocess