From 1bebaefff982e4b34e56fa6fd7ed0b16523fcd33 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 27 Oct 2011 16:33:54 +0200 Subject: [PATCH] Added graphics for sensors. A first version without support for edit or remove sensors --- telldus-gui/Plugins/Sensors/CMakeLists.txt | 6 ++ telldus-gui/Plugins/Sensors/HeaderTitle.qml | 10 +++ telldus-gui/Plugins/Sensors/SensorValue.qml | 32 ++++++++ telldus-gui/Plugins/Sensors/__init__.js | 12 +-- telldus-gui/Plugins/Sensors/header_bg.png | Bin 0 -> 526 bytes telldus-gui/Plugins/Sensors/icon_humidity.png | Bin 0 -> 1684 bytes telldus-gui/Plugins/Sensors/icon_temp.png | Bin 0 -> 1644 bytes telldus-gui/Plugins/Sensors/main.qml | 71 ++++++++++++++++-- telldus-gui/Plugins/Sensors/qmldir | 2 + telldus-gui/Plugins/Sensors/row_bg.png | Bin 0 -> 346 bytes telldus-gui/Plugins/Sensors/sensorsplugin.cpp | 3 + 11 files changed, 119 insertions(+), 17 deletions(-) create mode 100644 telldus-gui/Plugins/Sensors/HeaderTitle.qml create mode 100644 telldus-gui/Plugins/Sensors/SensorValue.qml create mode 100644 telldus-gui/Plugins/Sensors/header_bg.png create mode 100644 telldus-gui/Plugins/Sensors/icon_humidity.png create mode 100644 telldus-gui/Plugins/Sensors/icon_temp.png create mode 100644 telldus-gui/Plugins/Sensors/row_bg.png diff --git a/telldus-gui/Plugins/Sensors/CMakeLists.txt b/telldus-gui/Plugins/Sensors/CMakeLists.txt index bfd56a32..535ccc85 100644 --- a/telldus-gui/Plugins/Sensors/CMakeLists.txt +++ b/telldus-gui/Plugins/Sensors/CMakeLists.txt @@ -24,9 +24,15 @@ SET( Plugin_MOC_HDRS SET( Plugin_PATH "com.telldus.sensors" ) SET( Plugin_EXTRA + header_bg.png icon.png + icon_humidity.png + icon_temp.png main.qml + HeaderTitle.qml + row_bg.png qmldir + SensorValue.qml ) INCLUDE( ../TelldusCenterPlugin.cmake NO_POLICY_SCOPE ) diff --git a/telldus-gui/Plugins/Sensors/HeaderTitle.qml b/telldus-gui/Plugins/Sensors/HeaderTitle.qml new file mode 100644 index 00000000..0d7ae213 --- /dev/null +++ b/telldus-gui/Plugins/Sensors/HeaderTitle.qml @@ -0,0 +1,10 @@ +import Qt 4.7 + +Text { + id: headerTitle + text: "Name" + color: "white" + font.weight: Font.Bold + height: parent.height + verticalAlignment: Text.AlignVCenter +} diff --git a/telldus-gui/Plugins/Sensors/SensorValue.qml b/telldus-gui/Plugins/Sensors/SensorValue.qml new file mode 100644 index 00000000..7198c9ff --- /dev/null +++ b/telldus-gui/Plugins/Sensors/SensorValue.qml @@ -0,0 +1,32 @@ +import Qt 4.7 + +Item { + property alias text: text.text + property alias icon: icon.source + property date lastUpdated: new Date() + + id: sensorValue + width: parent.width + height: 40 + Image { + id: icon + anchors.verticalCenter: parent.verticalCenter + } + Text { + id: text + anchors.left: icon.right + anchors.leftMargin: 10 + anchors.verticalCenter: parent.verticalCenter + color: "#004275" + } + Text { + id: timestamp + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.verticalCenter: parent.verticalCenter + text: Qt.formatDateTime(lastUpdated, Qt.DefaultLocaleShortDate); + color: "#004275" + font.pointSize: text.font.pointSize - 1 + font.italic: true + } +} diff --git a/telldus-gui/Plugins/Sensors/__init__.js b/telldus-gui/Plugins/Sensors/__init__.js index b6b11054..c20bfb67 100644 --- a/telldus-gui/Plugins/Sensors/__init__.js +++ b/telldus-gui/Plugins/Sensors/__init__.js @@ -27,9 +27,8 @@ com.telldus.sensors = function() { } - //com.telldus.core.sensorEvent.connect(sensorEvent); - view = new com.telldus.qml.view({ - }); + com.telldus.core.sensorEvent.connect(sensorEvent); + view = new com.telldus.qml.view({}); view.setProperty('sensorModel', sensorList); view.load("main.qml"); @@ -63,13 +62,8 @@ com.telldus.sensors = function() { print("Update"); } - if (dataType == com.telldus.core.TELLSTICK_TEMPERATURE) { - sensor.temperature = value; - } else if (dataType == com.telldus.core.TELLSTICK_HUMIDITY) { - sensor.humidity = value; - } - print("Sensor event", protocol, model, id, dataType, value, timestamp); + sensor.setValue(dataType, value, timestamp); } return { //Public functions diff --git a/telldus-gui/Plugins/Sensors/header_bg.png b/telldus-gui/Plugins/Sensors/header_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..564a158b5d9c69a045712278b45085512e0474f7 GIT binary patch literal 526 zcmV+p0`dKcP)J)aLLt2t;vW#y(ps?7Lexe~5Cei*7!%YKMm-bF*WIl%r;#8> zyemZKc-hqp|drJ&7&)e zm~n;=Rwjo=Ov}d3SsIsF14gleD$R9OL8v)^4sy82zU*t{(ch#i*h*X@o_cU1*32S@ z63y9}Y=GfVGV_RwyC)RORk&G+zpGk^VPtZ7@-EYxL?d%x-nwd9Kd~RMZQGFc4`dCN zpHCwbHQ3>#$HpQhKfp`7aLWuaJDh zzf(xRmWJPZmXLq=rzj-Dl(Mc&T_m{XP+&M|n2J+^UkCjr(bUGPafV~(dEL_WfIF;e zP{L7e6EWqp6U9V03enO|i|WVLH1eE4jv6EGP`I?VAyOA9OFFJ^ZSMjM08uy&f`RU1 Q`v3p{07*qoM6N<$f)*X<_5c6? literal 0 HcmV?d00001 diff --git a/telldus-gui/Plugins/Sensors/icon_humidity.png b/telldus-gui/Plugins/Sensors/icon_humidity.png new file mode 100644 index 0000000000000000000000000000000000000000..29b02e26676f112bf67aec6d5438028f90622ed3 GIT binary patch literal 1684 zcmV;F25b3=P)`Fsfk1)YkWT60d-0gKxO{Er$>)`YRW~eR%?u{vFg(k`QCx|Zrppe2Yye_lXTQE)w95`y`-mlMK6OUF`kV&+XtHu|w(#zY)G{WmV&XhuVz1!X7BVc|2Au%yVZ?WYjo zqoziL3Lx{21OZ!OphakW6tKY;yMEK0Dre+itYl7TJOw`;z+(>$fTx=qYkn>l&Jpg4 z#4<9`l`{m9Y>Z4nBq0~*?b$1h_;S}_6wIH66+e_QM+}+*+-eUY|GT|dJ#PkzN{(nS znO?T1d{`1uCBJ0}~9*6lFQ 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g20&9Js+FVYUfvROAN%f%j7sjplKA|{@Yoi`+J9e*%O7!a~;yG*`>a^3Tm zf-rF$U=#Pe>b}{iX*`DJ6F=kDu_btZX$7{_ALLP(#D!UE3#tF4fySyxSW?NRSn1xha z+=WbMiIGMP8QAOYNn>2eaJ>KIV)^Ltw|3y~j!q%a$Bc#_lxXJ8sketAH_~K8hja?X z%mb84ZBAAg-~RFkKK$&6+;!;tGng={*!Pr-*qI?GzkY+=Ik&zA^qL6EtMySgHs$@*`l80Uk7ye3M=NI3}$G^3W4qXXj2Pp;Kpe9VQ_`;HS=1l$@7V#GhRn4iY~(m@O5 z7E!PlAWhFc$jLCk)JQ}|8R<}kZ5xBL2Myd}^R)t`J!vPSw7oPlmmiG7!Ro*E_3ZlM ztMKcEHrzF}Y(N8MP8=;uQgVSO-7*d+>YZTA#6X}vNn5`1?wP3BcLXaI&cMiF1$`9^%btDUXB)%=5f4-PUjvw~Q^t+bb8tChF(&MV~dvWb$w{8l5Aw zWH&W6-&tN>Ud#8{?iol%FJQK6gofik@D}_4&hSQrdm#~j4JV&R=TGBIIliAhLZv}} z?W7wU85IA|1@T#L%BP#@z8Ask`@2&sfGf^LJ&&wc|Kq7zX1q*Dya3ux%UDJDitT z-3xDltk6MxnbSQ3YG5=F|1?b_UV%Gfx(jib=edUaBjCI!3Unh>*M^5>Sqfyp+vggv s$2sDxJIMz>xM99Af0^I6KlmrW0Ji3+_8HcCGynhq07*qoM6N<$f;s|{CjbBd literal 0 HcmV?d00001 diff --git a/telldus-gui/Plugins/Sensors/sensorsplugin.cpp b/telldus-gui/Plugins/Sensors/sensorsplugin.cpp index 51d869c3..4891b7ad 100644 --- a/telldus-gui/Plugins/Sensors/sensorsplugin.cpp +++ b/telldus-gui/Plugins/Sensors/sensorsplugin.cpp @@ -1,6 +1,8 @@ #include "sensorsplugin.h" #include "sensor.h" +#include "sensorvalue.h" #include +#include QScriptValue SensorCTor(QScriptContext *context, QScriptEngine *engine) { if (!context->isCalledAsConstructor()) { @@ -12,6 +14,7 @@ QScriptValue SensorCTor(QScriptContext *context, QScriptEngine *engine) { SensorsPlugin::SensorsPlugin ( QObject * parent ) :QScriptExtensionPlugin( parent ) { + qmlRegisterType("Telldus", 1, 0, "SensorValue"); } SensorsPlugin::~SensorsPlugin() {