Only show "Send to live" when live is activated

This commit is contained in:
Stefan Persson 2013-11-22 11:07:05 +01:00
parent bd8388364d
commit 813c9696fc
4 changed files with 22 additions and 9 deletions

View file

@ -97,6 +97,9 @@ com.telldus.live = function() {
function registrationLinkVisible(visibleParam){ function registrationLinkVisible(visibleParam){
configUI.findChild('registrationLink').visible = visibleParam; configUI.findChild('registrationLink').visible = visibleParam;
if (com.telldus.sensors) {
com.telldus.sensors.showLiveOptions(!visibleParam);
}
} }
function sendDevicesReport() { function sendDevicesReport() {

View file

@ -51,8 +51,8 @@ Column {
text: qsTr("Send to Telldus Live!") text: qsTr("Send to Telldus Live!")
anchors.right: sensorinformationTitle.left anchors.right: sensorinformationTitle.left
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
visible: main.state == "EDIT" visible: main.state == "EDIT" && showLiveOptions
width: 150 width: showLiveOptions ? 150 : 0
} }
HeaderTitle { HeaderTitle {
id: sensorinformationTitle id: sensorinformationTitle
@ -70,7 +70,9 @@ Column {
} }
Repeater { Repeater {
model: sensorModel model: sensorModel
delegate: SensorView{ state: main.state == "EDIT" ? 'EDIT' : ''} delegate: SensorView {
state: main.state == "EDIT" ? 'EDIT' : ''
}
} }
Row{ Row{
spacing: 20 spacing: 20

View file

@ -96,13 +96,13 @@ Item{
Item { Item {
id: sendtolivecheckbox id: sendtolivecheckbox
height: 40 height: 40
width: 150 width: showLiveOptions ? 150 : 0
anchors.right: sensorInfo.left anchors.right: sensorInfo.left
CheckBox { CheckBox {
id: checkBoxSTL id: checkBoxSTL
anchors.centerIn: parent anchors.centerIn: parent
width: checkBoxSTL.height width: checkBoxSTL.height
visible: sensorViewItem.state == "EDIT" visible: sensorViewItem.state == "EDIT" && showLiveOptions
checked: modelData.sendToLive checked: modelData.sendToLive
onClicked: modelData.setSendToLive(!modelData.sendToLive) onClicked: modelData.setSendToLive(!modelData.sendToLive)
} }

View file

@ -7,6 +7,7 @@ __postInit__ = function() {
com.telldus.sensors = function() { com.telldus.sensors = function() {
var sensorList; var sensorList;
var view;
function init() { function init() {
var sensorData = 0; var sensorData = 0;
sensorList = loadSensorModel(); sensorList = loadSensorModel();
@ -51,6 +52,7 @@ com.telldus.sensors = function() {
} }
} }
view.setProperty('initialViewMode', initialViewMode); view.setProperty('initialViewMode', initialViewMode);
view.setProperty('showLiveOptions', (!com.telldus.live || !com.telldus.live.isRegisteredToLive()));
saveSensorModel(); saveSensorModel();
view.load("main.qml"); view.load("main.qml");
application.addWidget("sensors.gui", "icon.png", view); application.addWidget("sensors.gui", "icon.png", view);
@ -224,9 +226,14 @@ com.telldus.sensors = function() {
settings.setValue("sensors", sensorProperties); settings.setValue("sensors", sensorProperties);
} }
function showLiveOptions(status){
if(view){
view.setProperty('showLiveOptions', status);
}
}
function sendSensorReport(){ function sendSensorReport(){
//TODO Only show "sendToLive" if Telldus Live! is activated if(!com.telldus.live || !com.telldus.live.isRegisteredToLive()){
if(!com.telldus.live.isRegisteredToLive()){
return; return;
} }
@ -268,7 +275,7 @@ com.telldus.sensors = function() {
} }
sensor.setValue(dataType, value, timestamp); sensor.setValue(dataType, value, timestamp);
if (sensor.sendToLive){ if (com.telldus.live && com.telldus.live.isRegisteredToLive() && sensor.sendToLive){
sensorValues = pickSensorValues(sensor) sensorValues = pickSensorValues(sensor)
if (allValuesUpdated(sensorValues)) { if (allValuesUpdated(sensorValues)) {
com.telldus.live.sendSensorValues(sensor, sensorValues); com.telldus.live.sendSensorValues(sensor, sensorValues);
@ -281,7 +288,8 @@ com.telldus.sensors = function() {
} }
return { //Public functions return { //Public functions
init:init init:init,
showLiveOptions: showLiveOptions
} }
}(); }();