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){
configUI.findChild('registrationLink').visible = visibleParam;
if (com.telldus.sensors) {
com.telldus.sensors.showLiveOptions(!visibleParam);
}
}
function sendDevicesReport() {

View file

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

View file

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

View file

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