diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..1512eb7b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "telldus-gui/3rdparty/qt-components-desktop"] + path = telldus-gui/3rdparty/qt-components-desktop + url = git://gitorious.org/qt-components/desktop.git diff --git a/telldus-gui/3rdparty/qt-components-desktop b/telldus-gui/3rdparty/qt-components-desktop new file mode 160000 index 00000000..563fdbc4 --- /dev/null +++ b/telldus-gui/3rdparty/qt-components-desktop @@ -0,0 +1 @@ +Subproject commit 563fdbc4d7805c9d9c1d2abde1d52b39e58b4329 diff --git a/telldus-gui/3rdparty/qt-components-desktop.cmake b/telldus-gui/3rdparty/qt-components-desktop.cmake new file mode 100644 index 00000000..ff7deaba --- /dev/null +++ b/telldus-gui/3rdparty/qt-components-desktop.cmake @@ -0,0 +1,59 @@ +FIND_PACKAGE( Qt4 REQUIRED ) + +SET(BASE_PATH "${CMAKE_SOURCE_DIR}/3rdparty/qt-components-desktop") +FILE(GLOB SRCS ${BASE_PATH}/src/*.cpp) +FILE(GLOB HDRS ${BASE_PATH}/src/*.h) + +FILE(GLOB_RECURSE QML ${BASE_PATH}/components/*.qml) +FILE(GLOB_RECURSE JS ${BASE_PATH}/components/*.js) +FILE(GLOB_RECURSE PNG ${BASE_PATH}/components/*.png) +FILE(GLOB_RECURSE QMLDIR ${BASE_PATH}/components/qmldir) +SET(EXTRA_FILES ${QML} ${JS} ${PNG} ${QMLDIR}) + +IF (QT_COMPONENTS_OUTPUT_DIR) + SET(QT_COMPONENTS_OUTPUT_DIR "${QT_COMPONENTS_OUTPUT_DIR}/QtDesktop") +ELSE() + SET(QT_COMPONENTS_OUTPUT_DIR "QtDesktop") +ENDIF() + +STRING(LENGTH "${BASE_PATH}/components" BASE_LENGTH) +FOREACH(_FILE ${EXTRA_FILES}) + STRING(LENGTH ${_FILE} _FILE_LENGTH) + MATH(EXPR _TOP_LENGTH "${_FILE_LENGTH}-${BASE_LENGTH}") + STRING(SUBSTRING ${_FILE} ${BASE_LENGTH} ${_TOP_LENGTH} _OUT_FILE) + GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) + SET(_OUTFILEPATH ${QT_COMPONENTS_OUTPUT_DIR}${_OUT_FILE}) + LIST(APPEND SRCS ${_OUTFILEPATH}) + ADD_CUSTOM_COMMAND( + OUTPUT ${_OUTFILEPATH} + DEPENDS ${_FILE} + COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${_OUTFILEPATH} + COMMENT "Copy ${_FILENAME} to destination" + ) +ENDFOREACH(_FILE) + +QT4_WRAP_CPP( MOC_SRCS ${HDRS} ) +QT4_AUTOMOC ( ${SRCS} ) + +SET(LIBRARIES ${QT_LIBRARIES}) + +IF (APPLE) + FIND_LIBRARY(CARBON_LIBRARY Carbon) + LIST(APPEND LIBRARIES ${CARBON_LIBRARY}) +ENDIF () + +ADD_LIBRARY(styleplugin SHARED + ${SRCS} + ${MOC_SRCS} +) +TARGET_LINK_LIBRARIES( styleplugin ${LIBRARIES} ) + +IF (WIN32) + SET_TARGET_PROPERTIES(styleplugin PROPERTIES + PREFIX "Plugins/declarative/QtDesktop/plugin/" + ) +ELSE() + SET_TARGET_PROPERTIES(styleplugin PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${QT_COMPONENTS_OUTPUT_DIR}/plugin + ) +ENDIF() diff --git a/telldus-gui/Plugins/QML/CMakeLists.txt b/telldus-gui/Plugins/QML/CMakeLists.txt index 5d0830d8..d008a815 100644 --- a/telldus-gui/Plugins/QML/CMakeLists.txt +++ b/telldus-gui/Plugins/QML/CMakeLists.txt @@ -23,3 +23,12 @@ SET( Plugin_MOC_HDRS SET( Plugin_PATH "com.telldus.qml" ) INCLUDE( ../TelldusCenterPlugin.cmake NO_POLICY_SCOPE ) + +IF (WIN32) + SET(QT_COMPONENTS_OUTPUT_DIR "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/Plugins/declarative") +ELSEIF (APPLE) + SET(QT_COMPONENTS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/TelldusCenter.app/Contents/Plugins/declarative") +ELSE() + SET(QT_COMPONENTS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/TelldusCenter/Plugins/declarative") +ENDIF() +INCLUDE( ${CMAKE_SOURCE_DIR}/3rdparty/qt-components-desktop.cmake NO_POLICY_SCOPE ) diff --git a/telldus-gui/Plugins/QML/qmlarray.cpp b/telldus-gui/Plugins/QML/qmlarray.cpp index b36bfac8..fa306fea 100644 --- a/telldus-gui/Plugins/QML/qmlarray.cpp +++ b/telldus-gui/Plugins/QML/qmlarray.cpp @@ -1,6 +1,5 @@ #include "qmlarray.h" - -#include +#include class QMLArray::PrivateData { public: @@ -35,6 +34,18 @@ void QMLArray::push(const QScriptValue &v) { endInsertRows(); } +void QMLArray::remove(int index) { + beginRemoveRows( QModelIndex(), index, index ); + d->list.takeAt(index); + endRemoveRows(); +} + +void QMLArray::removeLater(int index) { + int methodIndex = this->metaObject()->indexOfMethod(QMetaObject::normalizedSignature("remove(int)")); + QMetaMethod method = this->metaObject()->method(methodIndex); + method.invoke(this, Qt::QueuedConnection, Q_ARG(int, index)); +} + int QMLArray::rowCount(const QModelIndex &parent) const { return d->list.size(); } diff --git a/telldus-gui/Plugins/QML/qmlarray.h b/telldus-gui/Plugins/QML/qmlarray.h index 8c29b798..d9da42e1 100644 --- a/telldus-gui/Plugins/QML/qmlarray.h +++ b/telldus-gui/Plugins/QML/qmlarray.h @@ -19,6 +19,8 @@ signals: public slots: void push(const QScriptValue &v); + void remove(int index); + void removeLater(int index); QVariant get(int index) const; diff --git a/telldus-gui/Plugins/QML/qmlview.cpp b/telldus-gui/Plugins/QML/qmlview.cpp index dea06628..6d12cc0f 100644 --- a/telldus-gui/Plugins/QML/qmlview.cpp +++ b/telldus-gui/Plugins/QML/qmlview.cpp @@ -2,7 +2,9 @@ #include "scriptfunctionwrapper.h" #include #include +#include #include +#include class QMLView::PrivateData { public: @@ -16,6 +18,22 @@ QMLView::QMLView(const QDir &dir, const QScriptValue &object) : setAttribute(Qt::WA_TranslucentBackground); setStyleSheet("background:transparent;"); + QDeclarativeEngine *eng = this->engine(); + QStringList paths(eng->importPathList()); + QDir pluginsDir = QDir(qApp->applicationDirPath()); + +#if defined(Q_OS_MAC) + if (pluginsDir.dirName() == "MacOS") { + pluginsDir.cdUp(); + } +#endif + + if (pluginsDir.cd("Plugins/declarative")) { + paths << pluginsDir.absolutePath(); + } + + eng->setImportPathList(paths); + d = new PrivateData; d->baseDir = dir; d->object = object; diff --git a/telldus-gui/Plugins/Sensors/CMakeLists.txt b/telldus-gui/Plugins/Sensors/CMakeLists.txt index cf97f98c..45371412 100644 --- a/telldus-gui/Plugins/Sensors/CMakeLists.txt +++ b/telldus-gui/Plugins/Sensors/CMakeLists.txt @@ -3,7 +3,7 @@ SET(REQUIRE_PLUGIN_SETTINGS TRUE PARENT_SCOPE) SET(QT_USE_QTDECLARATIVE TRUE) -SET( Plugin_NAME "sensors" ) +SET( Plugin_NAME "Sensors" ) SET( Plugin_SRCS @@ -33,6 +33,8 @@ SET( Plugin_EXTRA row_bg.png qmldir SensorValue.qml + SensorView.qml + SensorList.qml ) FIND_PACKAGE(TelldusCore REQUIRED) diff --git a/telldus-gui/Plugins/Sensors/SensorList.qml b/telldus-gui/Plugins/Sensors/SensorList.qml new file mode 100644 index 00000000..8f6635bd --- /dev/null +++ b/telldus-gui/Plugins/Sensors/SensorList.qml @@ -0,0 +1,82 @@ +import Qt 4.7 +import QtDesktop 0.1 + +Column { + id: sensorList + 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: "" + anchors.right: sensorid.left + visible: main.state == "EDIT" + width: 50 + } + HeaderTitle { + id: sensorid + text: "ID" + anchors.right: modelTitle.left + visible: main.state == "EDIT" + width: 50 + } + HeaderTitle { + id: modelTitle + text: "Model" + anchors.right: visibleinlistTitle.left + visible: main.state == "EDIT" + width: 100 + } + HeaderTitle { + id: visibleinlistTitle + text: "Visible in list" + anchors.right: sensorinformationTitle.left + horizontalAlignment: Text.AlignHCenter + visible: main.state == "EDIT" + width: 100 + } + HeaderTitle { + id: sensorinformationTitle + text: "Sensor information" + width: 150 + anchors.right: timestampTitle.left + } + HeaderTitle { + id: timestampTitle + text: "Last updated" + width: 100 + anchors.right: parent.right + //horizontalAlignment: Text.AlignRight + } + } + Repeater { + model: sensorModel + delegate: SensorView{ state: main.state == "EDIT" ? 'EDIT' : ''} + } + Row{ + spacing: 20 + Button { + width: 50 + height: 20 + text: main.state == "VIEW" ? "Edit" : "View" + onClicked: { + if(main.state == "VIEW"){ + main.state = "EDIT" + } + else{ + main.state = "VIEW" + } + } + } + } +} diff --git a/telldus-gui/Plugins/Sensors/SensorView.qml b/telldus-gui/Plugins/Sensors/SensorView.qml new file mode 100644 index 00000000..e383c8b3 --- /dev/null +++ b/telldus-gui/Plugins/Sensors/SensorView.qml @@ -0,0 +1,138 @@ +import Qt 4.7 +import QtDesktop 0.1 + +Item{ + id: sensorViewItem + visible: state == "EDIT" || modelData.showInList + height: childrenRect.height + width: parent ? parent.width : 0 + + states:[ + State { + name: "EDIT" + } + ] + + BorderImage { + source: "row_bg.png" + border.left: 5; border.top: 5 + border.right: 5; border.bottom: 5 + height: sensorInfo.height + width: parent.width + + Text { + visible: sensorViewItem.state != "EDIT" + anchors.left: parent.left + anchors.leftMargin: 15 + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.name == '' ? '' : modelData.name; + color: "#004275" + } + TextField { + id: nameEdit + visible: sensorViewItem.state == "EDIT" + anchors.left: parent.left + anchors.leftMargin: 15 + anchors.top: parent.top + anchors.topMargin: (40-nameEdit.height)/2 + text: modelData.name; + placeholderText: 'Enter a name' + onTextChanged: modelData.name = text + } + + Text{ + anchors.right: sensorid.left + visible: sensorViewItem.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: "Delete" + font.underline: true + color: "#004275" + width: 50 + MouseArea{ + anchors.fill: parent + onClicked: { + confirmDeletion.visible = true; + } + } + } + Text{ + id: sensorid + anchors.right: model.left + visible: sensorViewItem.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.id + color: "#004275" + width: 50 + } + Text{ + id: model + anchors.right: visibleinlistcheckbox.left + visible: sensorViewItem.state == "EDIT" + height: 40 + verticalAlignment: Text.AlignVCenter + text: modelData.model + color: "#004275" + width: 100 + } + Item { + id: visibleinlistcheckbox + height: 40 + width: 100 + anchors.right: sensorInfo.left + CheckBox { + id: checkBox + anchors.centerIn: parent + width: checkBox.height + visible: sensorViewItem.state == "EDIT" + checked: modelData.showInList + onClicked: modelData.setShowInList(!modelData.showInList) + } + } + + 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() + } + } + } + + Dialog{ + id: confirmDeletion + modal: true + title: "Confirm deletion" + Text{ + id: descriptionHeadline + text:"Delete this sensor?" + font.bold: true + } + Text{ + id: descriptionText + anchors.top: descriptionHeadline.bottom + anchors.topMargin: 10 + width: parent.width - 20 + anchors.left: parent.left + anchors.leftMargin: 10 + text: "Please note that a sensor that is still transmitting will reappear here again, but it will be hidden in the list by default." + wrapMode: Text.Wrap + } + + onAccepted: { + deleteSensor.callWith(modelData.protocol, modelData.model, modelData.id); + } + } +} diff --git a/telldus-gui/Plugins/Sensors/__init__.js b/telldus-gui/Plugins/Sensors/__init__.js index 70283e2b..b2a36c73 100644 --- a/telldus-gui/Plugins/Sensors/__init__.js +++ b/telldus-gui/Plugins/Sensors/__init__.js @@ -6,10 +6,13 @@ __postInit__ = function() { } com.telldus.sensors = function() { - var sensorList = new com.telldus.qml.array(); - + var sensorList; function init() { var sensorData = 0; + sensorList = loadSensorModel(); + sensorList.rowsRemoved.connect(function(){saveSensorModel();}); + sensorList.rowsInserted.connect(function(){saveSensorModel();}); + while(sensorData = com.telldus.core.sensor()) { var p = sensorData["protocol"]; var m = sensorData["model"]; @@ -19,7 +22,7 @@ com.telldus.sensors = function() { var tryFetchValue = function(p, m, id, types, type) { if (types & type) { sensorValue = com.telldus.core.sensorValue(p, m, id, type); - sensorEvent(p, m, id, type, sensorValue["value"], sensorValue["timestamp"]); + sensorEvent(p, m, id, type, sensorValue["value"], sensorValue["timestamp"], true); } } tryFetchValue(p, m, id, types, com.telldus.core.TELLSTICK_TEMPERATURE); @@ -28,14 +31,94 @@ com.telldus.sensors = function() { } com.telldus.core.sensorEvent.connect(sensorEvent); - view = new com.telldus.qml.view({}); + view = new com.telldus.qml.view({ + deleteSensor: deleteSensor + }); view.setProperty('sensorModel', sensorList); + saveSensorModel(); view.load("main.qml"); application.addWidget("sensors.gui", "icon.png", view); } - function sensorEvent(protocol, model, id, dataType, value, timestamp) { + function createSensor(protocol, model, id, name, showInList){ + var sensor = new com.telldus.sensors.sensor(); + sensor.protocol = protocol; + sensor.model = model; + sensor.id = id; + sensor.name = name; + sensor.nameChanged.connect(function() { saveSensorModel(); }); + sensor.showInList = showInList; + sensor.showInListChanged.connect(function() { saveSensorModel(); }); + return sensor; + } + + function deleteSensor(protocol, model, id){ + var i = 0; + var found = false; + for (; i < sensorList.length; ++i) { + if (sensorList.get(i).protocol != protocol) { + continue; + } + if (sensorList.get(i).model != model) { + continue; + } + if (sensorList.get(i).id != id) { + continue; + } + found = true; + break; + } + if(found){ + sensorList.removeLater(i); + } + } + + function loadSensorModel(){ + var settings = new com.telldus.settings(); + var sensors = new com.telldus.qml.array(); + + var sensorProperties = settings.value("sensors", ""); + if(sensorProperties){ + for (var i = 0; i < sensorProperties.length; i++) { + var sensor = createSensor(sensorProperties[i].protocol, sensorProperties[i].model, sensorProperties[i].id, sensorProperties[i].name, sensorProperties[i].showInList=="true"); + for (var j = 0; j < sensorProperties[i].values.length; j++) { + sensor.setValue(sensorProperties[i].values[j].type, sensorProperties[i].values[j].value, sensorProperties[i].values[j].lastUpdated) + } + sensors.push(sensor); + } + } + return sensors; + } + + function saveSensorModel(){ + var settings = new com.telldus.settings(); + var sensorProperties = new Array(); + + for (var i = 0; i < sensorList.length; ++i) { + var sensor = sensorList.get(i); + + var allValues = new Array(); + if(sensor.hasHumidity){ + var sensorValue = sensor.sensorValue(com.telldus.core.TELLSTICK_HUMIDITY); + var value = {type: com.telldus.core.TELLSTICK_HUMIDITY, lastUpdated: sensorValue.lastUpdated, value: sensorValue.value}; + allValues.push(value); + } + if(sensor.hasTemperature){ + var sensorValue = sensor.sensorValue(com.telldus.core.TELLSTICK_TEMPERATURE); + var value = {type: com.telldus.core.TELLSTICK_TEMPERATURE, lastUpdated: sensorValue.lastUpdated, value: sensorValue.value}; + allValues.push(value); + } + + var sensorProp = {protocol:sensor.protocol, model:sensor.model, id:sensor.id, values:allValues, name:sensor.name, showInList:sensor.showInList}; + sensorProperties.push(sensorProp); + } + + settings.setValue("sensors", sensorProperties); + } + + function sensorEvent(protocol, model, id, dataType, value, timestamp, avoidSave) { + var sensor = 0; for (var i = 0; i < sensorList.length; ++i) { if (sensorList.get(i).protocol != protocol) { @@ -52,19 +135,15 @@ com.telldus.sensors = function() { } if (!sensor) { - sensor = new com.telldus.sensors.sensor(); - sensor.protocol = protocol; - sensor.model = model; - sensor.id = id; - sensor.showInList = false; + sensor = createSensor(protocol, model, id, "", false); sensorList.push(sensor); - print("Create new"); - } else { - print("Update"); } - print("Sensor event", protocol, model, id, dataType, value, timestamp); sensor.setValue(dataType, value, timestamp); + + if(!avoidSave){ + saveSensorModel(); + } } return { //Public functions diff --git a/telldus-gui/Plugins/Sensors/main.qml b/telldus-gui/Plugins/Sensors/main.qml index 5d240c29..41ecb0ac 100644 --- a/telldus-gui/Plugins/Sensors/main.qml +++ b/telldus-gui/Plugins/Sensors/main.qml @@ -1,214 +1,21 @@ import Qt 4.7 +import QtDesktop 0.1 Item { id: main state: "VIEW" - Component { - id: sensorView - Item{ - id: sensorViewItem - visible: main.state == "EDIT" || modelData.showInList - height: childrenRect.height - width: parent.width - - BorderImage { - source: "row_bg.png" - border.left: 5; border.top: 5 - border.right: 5; border.bottom: 5 - height: sensorInfo.height - width: parent.width - - Text { - visible: main.state == "VIEW" - anchors.left: parent.left - anchors.leftMargin: 15 - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.name; - color: "#004275" - } - Rectangle{ - color: "white" - visible: main.state == "EDIT" - anchors.left: parent.left - anchors.leftMargin: 15 - width: nameEdit.width + 4 - height: 22 - TextInput{ - id: nameEdit - anchors.centerIn: parent - text: modelData.name; - color: "#004275" - - onActiveFocusChanged: { - if(!activeFocus){ - //todo other way? - modelData.setName(nameEdit.text); - } - } - onAccepted: { - modelData.setName(nameEdit.text); - } - } - } - Text{ - anchors.right: model.left - visible: main.state == "EDIT" - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.id - color: "#004275" - width: 50 - } - Text{ - id: model - anchors.right: visibleinlistcheckbox.left - visible: main.state == "EDIT" - height: 40 - verticalAlignment: Text.AlignVCenter - text: modelData.model - color: "#004275" - width: 100 - } - Item{ - id: visibleinlistcheckbox - anchors.right: sensorInfo.left - visible: main.state == "EDIT" - height: 40 - Rectangle{ - anchors.centerIn: parent - height: 10 - width: 10 - color: "white" - Text{ - anchors.centerIn: parent - color: "#004275" - text: modelData.showInList ? "X" : "" - } - MouseArea{ - anchors.fill: parent - onClicked: { - modelData.setShowInList(!modelData.showInList); - } - } - } - width: 100 - } - - 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: "ID" - anchors.right: modelTitle.left - visible: main.state == "EDIT" - width: 50 - } - HeaderTitle { - id: modelTitle - text: "Model" - anchors.right: visibleinlistTitle.left - visible: main.state == "EDIT" - width: 100 - } - HeaderTitle { - id: visibleinlistTitle - text: "Visible in list" - anchors.right: sensorinformationTitle.left - visible: main.state == "EDIT" - width: 100 - } - HeaderTitle { - id: sensorinformationTitle - text: "Sensor information" - width: 150 - anchors.right: timestampTitle.left - } - HeaderTitle { - id: timestampTitle - text: "Last updated" - width: 100 - anchors.right: parent.right - //horizontalAlignment: Text.AlignRight - } - } - Repeater { - model: sensorModel - delegate: sensorView - } - Row{ - spacing: 20 - Rectangle { - width: 50 - height: 20 - Text{ - anchors.centerIn: parent - text: main.state == "VIEW" ? "Edit" : "View" - } - MouseArea{ - anchors.fill: parent - onClicked: { - if(main.state == "VIEW"){ - main.state = "EDIT" - } - else{ - main.state ="VIEW" - } - } - } - } - /* - Rectangle { - //TODO should this button exist at all, or always save? - width: 50 - height: 20 - visible: main.state == "EDIT" - Text{ - anchors.centerIn: parent - text: "Cancel" - } - MouseArea{ - anchors.fill: parent - onClicked: { - main.state ="VIEW" - } - } - } - */ - } + ScrollArea { + id: scrollArea anchors.fill: parent + frame: false + + contentHeight: sensorList.height + contentWidth: sensorList.width + + SensorList { + id: sensorList + width: main.width-scrollArea.verticalScrollBar.width + } } } diff --git a/telldus-gui/Plugins/Sensors/qmldir b/telldus-gui/Plugins/Sensors/qmldir index 19c8cb6f..050f9f5b 100644 --- a/telldus-gui/Plugins/Sensors/qmldir +++ b/telldus-gui/Plugins/Sensors/qmldir @@ -1,2 +1,4 @@ HeaderTitle 1.0 HeaderTitle.qml SensorValue 1.0 SensorValue.qml +SensorView 1.0 SensorView.qml +SensorList 1.0 SensorList.qml diff --git a/telldus-gui/Plugins/Sensors/sensor.cpp b/telldus-gui/Plugins/Sensors/sensor.cpp index 7a56f46f..1ba7d76f 100644 --- a/telldus-gui/Plugins/Sensors/sensor.cpp +++ b/telldus-gui/Plugins/Sensors/sensor.cpp @@ -17,6 +17,7 @@ Sensor::Sensor(QObject *parent) : { d = new PrivateData; d->id = 0; + d->showInList = false; } Sensor::~Sensor() { @@ -46,14 +47,13 @@ void Sensor::setModel(const QString &model) { } QString Sensor::name() const { - //return QString("%1 %2").arg(this->protocol()).arg(this->id()); //TODO: Remove when name is fully implemented - if(d->name == ""){ - return ""; - } return d->name; } void Sensor::setName(const QString &name) { + if (name == d->name) { + return; + } d->name = name; emit nameChanged(); } @@ -71,7 +71,7 @@ bool Sensor::hasTemperature() const { return d->values.contains(TELLSTICK_TEMPERATURE); } -SensorValue * Sensor::sensorValue(int type) { +QObject * Sensor::sensorValue(int type) { return (d->values.contains(type) ? d->values[type] : 0); } @@ -94,7 +94,6 @@ void Sensor::setValue(int type, const QString &value, const QDateTime ×tamp } bool Sensor::showInList() const{ - //TODO showInList and name must be persistent... return d->showInList; } diff --git a/telldus-gui/Plugins/Sensors/sensor.h b/telldus-gui/Plugins/Sensors/sensor.h index 85164246..6683e305 100644 --- a/telldus-gui/Plugins/Sensors/sensor.h +++ b/telldus-gui/Plugins/Sensors/sensor.h @@ -17,7 +17,7 @@ class Sensor : public QObject Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString protocol READ protocol WRITE setProtocol NOTIFY protocolChanged) - Q_PROPERTY(bool showInList READ showInList NOTIFY showInListChanged) + Q_PROPERTY(bool showInList READ showInList WRITE setShowInList NOTIFY showInListChanged) public: explicit Sensor(QObject *parent = 0); @@ -32,7 +32,6 @@ public: void setModel(const QString &model); QString name() const; - //void setName(const QString &name); QString protocol() const; void setProtocol(const QString &protocol); @@ -40,7 +39,7 @@ public: bool hasTemperature() const; bool showInList() const; - Q_INVOKABLE SensorValue *sensorValue(int type); + Q_INVOKABLE QObject *sensorValue(int type); Q_INVOKABLE void setValue(int type, const QString &value, const QDateTime ×tamp); Q_INVOKABLE void setName(const QString &name); Q_INVOKABLE void setShowInList(bool show); diff --git a/telldus-gui/Plugins/Settings/settings.cpp b/telldus-gui/Plugins/Settings/settings.cpp index d0f7097b..85ae12ff 100644 --- a/telldus-gui/Plugins/Settings/settings.cpp +++ b/telldus-gui/Plugins/Settings/settings.cpp @@ -26,10 +26,12 @@ void Settings::setValue( const QString & key, const QVariant & value ) { d->s.beginGroup(key); d->s.setValue("size", list.size()); d->s.setValue("type", "array"); + //d->s.beginWriteArray("list"); //TODO write or read? What prefix? for (int i = 0; i < list.size(); ++i) { - d->s.setArrayIndex(i); + //d->s.setArrayIndex(i); this->setValue(QString::number(i), list.at(i)); } + //d->s.endArray(); d->s.endGroup(); } else if (value.type() == QVariant::Map) { diff --git a/telldus-gui/Plugins/TelldusCenterPlugin.cmake b/telldus-gui/Plugins/TelldusCenterPlugin.cmake index 20ab8c6a..daae9f1a 100644 --- a/telldus-gui/Plugins/TelldusCenterPlugin.cmake +++ b/telldus-gui/Plugins/TelldusCenterPlugin.cmake @@ -63,6 +63,21 @@ ELSE (UPDATE_TRANSLATIONS) LIST(APPEND Plugin_FILES ${Plugin_QM}) ENDIF (UPDATE_TRANSLATIONS) +IF(Plugin_PATH) + FOREACH(_FILE ${Plugin_FILES}) + GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) + ADD_CUSTOM_COMMAND( OUTPUT ${Plugin_PATH}/${_FILENAME} + COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${Plugin_PATH}/${_FILENAME} + DEPENDS ${_FILE} + COMMENT "Copy ${_FILENAME} for plugin ${Plugin_NAME}" + ) + LIST(APPEND Plugin_TARGET_FILES "${Plugin_PATH}/${_FILENAME}") + IF (NOT APPLE) + INSTALL(FILES ${_FILE} DESTINATION "${PLUGIN_LIB_FULL_PATH}/script/${Plugin_PATH_relative}") + ENDIF () + ENDFOREACH(_FILE) +ENDIF(Plugin_PATH) + IF(Plugin_SRCS) ADD_LIBRARY(${Plugin_NAME} SHARED ${Plugin_SRCS} @@ -74,6 +89,7 @@ IF(Plugin_SRCS) ${Plugin_FILES} ${Plugin_TS} ${Plugin_QM} + ${Plugin_TARGET_FILES} ) TARGET_LINK_LIBRARIES( ${Plugin_NAME} ${Plugin_LIBRARIES} ) @@ -87,13 +103,13 @@ IF(Plugin_SRCS) SET(app \"\${DESTDIR}/Applications/TelldusCenter.app\") GET_BUNDLE_AND_EXECUTABLE(\"\${app}\" bundle exe valid) SET(plugin \"\${bundle}/Contents/Plugins/script/${Plugin_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}\") - + GET_ITEM_KEY(\"\${plugin}\" pkey) SET(prereqs \"\") GET_PREREQUISITES(\${plugin} prereqs 1 0 \"\${exe}\" \"\${bundle}/Contents/Frameworks/\") FOREACH(pr \${prereqs}) GET_ITEM_KEY(\"\${pr}\" rkey) - + #Don't change the path to TelldusCore IF (NOT \"\${rkey}\" STREQUAL \"TelldusCore\") #Check to see if this is ourself @@ -117,33 +133,12 @@ IF(Plugin_SRCS) LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/TelldusCenter/Plugins/script ) INSTALL(TARGETS ${Plugin_NAME} - LIBRARY DESTINATION "${PLUGIN_LIB_FULL_PATH}/script" + LIBRARY DESTINATION "${PLUGIN_LIB_FULL_PATH}/script" ) ENDIF (APPLE) SIGN(${Plugin_NAME}) ELSE(Plugin_SRCS) ADD_CUSTOM_TARGET(${Plugin_NAME} ALL - SOURCES ${Plugin_FILES} + SOURCES ${Plugin_FILES} ${Plugin_TARGET_FILES} ) ENDIF(Plugin_SRCS) - -IF(Plugin_PATH) - ADD_CUSTOM_COMMAND( TARGET ${Plugin_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${Plugin_PATH} - COMMENT "Creating plugin directory ${Plugin_NAME}" - ) - FOREACH(_FILE ${Plugin_FILES}) - GET_FILENAME_COMPONENT(_FILENAME ${_FILE} NAME) - ADD_CUSTOM_COMMAND( TARGET ${Plugin_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${_FILE} ${Plugin_PATH} - COMMENT "Copy ${_FILENAME} for plugin ${Plugin_NAME}" - ) - IF (NOT APPLE) - INSTALL(FILES ${_FILE} DESTINATION "${PLUGIN_LIB_FULL_PATH}/script/${Plugin_PATH_relative}") - ENDIF () - ENDFOREACH(_FILE) -ENDIF(Plugin_PATH) - - diff --git a/telldus-gui/Plugins/telldus/__init__.js b/telldus-gui/Plugins/telldus/__init__.js index 64493195..a9c88dfb 100644 --- a/telldus-gui/Plugins/telldus/__init__.js +++ b/telldus-gui/Plugins/telldus/__init__.js @@ -1 +1 @@ -__setupPackage__( __extension__ ); \ No newline at end of file +__setupPackage__( __extension__ );