Added graphics for sensors. A first version without support for edit or remove sensors

This commit is contained in:
Micke Prag 2011-10-27 16:33:54 +02:00
parent 194579cd2b
commit 1bebaefff9
11 changed files with 119 additions and 17 deletions

View file

@ -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 )

View file

@ -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
}

View file

@ -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
}
}

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -3,17 +3,72 @@ import Qt 4.7
Item {
id: main
Component {
id: sensorView
BorderImage {
source: "row_bg.png"
border.left: 5; border.top: 5
border.right: 5; border.bottom: 5
height: sensorInfo.height
width: parent.width
Text {
anchors.left: parent.left
anchors.leftMargin: 15
height: 40
verticalAlignment: Text.AlignVCenter
text: modelData.name;
color: "#004275"
}
Column {
id: sensorInfo
anchors.right: parent.right
width: 250
SensorValue {
visible: modelData.hasTemperature
text: visible ? modelData.sensorValue(1).value + '°C' : ''
icon: "icon_temp.png"
lastUpdated: visible ? modelData.sensorValue(1).lastUpdated : new Date()
}
SensorValue {
visible: modelData.hasHumidity
text: visible ? modelData.sensorValue(2).value + '%' : ''
icon: "icon_humidity.png"
lastUpdated: visible ? modelData.sensorValue(2).lastUpdated : new Date()
}
}
}
}
Column {
spacing: 1
BorderImage {
id: header
source: "header_bg.png"
width: parent.width; height: 40
border.left: 5; border.top: 5
border.right: 5; border.bottom: 5
HeaderTitle {
text: "Name"
anchors.left: parent.left
anchors.leftMargin: 15
}
HeaderTitle {
text: "Sensor information"
width: 150
anchors.right: timestampTitle.left
}
HeaderTitle {
id: timestampTitle
text: "Last updated"
width: 100
anchors.right: parent.right
}
}
Repeater {
model: sensorModel
delegate: Row {
spacing: 10
Text { text: modelData.name }
Text { text: modelData.protocol }
Text { text: modelData.model }
Text { text: modelData.temperature + '°C'; visible: modelData.hasTemperature }
Text { text: modelData.humidity + "%"; visible: modelData.hasHumidity }
}
delegate: sensorView
}
anchors.fill: parent
}

View file

@ -0,0 +1,2 @@
HeaderTitle 1.0 HeaderTitle.qml
SensorValue 1.0 SensorValue.qml

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

View file

@ -1,6 +1,8 @@
#include "sensorsplugin.h"
#include "sensor.h"
#include "sensorvalue.h"
#include <QScriptEngine>
#include <QtDeclarative>
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<SensorValue>("Telldus", 1, 0, "SensorValue");
}
SensorsPlugin::~SensorsPlugin() {