Now possible to activate Telldus Live! from Settings. Closes #101.

This commit is contained in:
Stefan Persson 2011-12-22 12:10:48 +01:00
parent 16a9b87fb6
commit 319e505509
2 changed files with 119 additions and 27 deletions

View file

@ -19,6 +19,7 @@ com.telldus.live = function() {
socket.connectToServer(); socket.connectToServer();
com.telldus.core.deviceEvent.connect(deviceEvent); com.telldus.core.deviceEvent.connect(deviceEvent);
com.telldus.core.deviceChange.connect(sendDevicesReport); com.telldus.core.deviceChange.connect(sendDevicesReport);
configUI.findChild('registrationLink').visible = false;
} }
function notRegistered() { function notRegistered() {
@ -28,6 +29,7 @@ com.telldus.live = function() {
menuId = com.telldus.systray.addMenuItem( qsTr("Activate Telldus Live!") ); menuId = com.telldus.systray.addMenuItem( qsTr("Activate Telldus Live!") );
com.telldus.systray.menuItem(menuId).triggered.connect(socket.activate); com.telldus.systray.menuItem(menuId).triggered.connect(socket.activate);
} }
registrationLinkVisible(true);
} }
function deviceEvent(deviceId, method, data) { function deviceEvent(deviceId, method, data) {
@ -63,9 +65,17 @@ com.telldus.live = function() {
} }
supportedMethods = msg.getInt('supportedMethods'); supportedMethods = msg.getInt('supportedMethods');
isRegistered = true; isRegistered = true;
registrationLinkVisible(false);
sendDevicesReport(); sendDevicesReport();
} }
function registrationLinkVisible(visibleParam){
configUI.findChild('registrationLink').visible = visibleParam;
if(visibleParam){
configUI.findChild('registrationLink').clicked.connect(socket.activate);
}
}
function sendDevicesReport() { function sendDevicesReport() {
if (!isRegistered) { if (!isRegistered) {
return; return;

View file

@ -7,38 +7,120 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>323</width> <width>323</width>
<height>263</height> <height>251</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <widget class="QWidget" name="">
<item row="0" column="0"> <property name="geometry">
<widget class="QLabel" name="label"> <rect>
<property name="text"> <x>0</x>
<string>Status:</string> <y>0</y>
</property> <width>331</width>
</widget> <height>251</height>
</item> </rect>
<item row="0" column="1"> </property>
<widget class="QLabel" name="statusLabel"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="text"> <item>
<string>unknown</string> <layout class="QGridLayout" name="gridLayout_3">
</property> <item row="0" column="0">
</widget> <widget class="QLabel" name="label">
</item> <property name="text">
<item row="1" column="1"> <string>Status:</string>
<widget class="QLabel" name="errorLabel"> </property>
<property name="text"> </widget>
<string/> </item>
</property> <item row="0" column="1">
<property name="wordWrap"> <widget class="QLabel" name="statusLabel">
<bool>true</bool> <property name="text">
</property> <string>unknown</string>
</widget> </property>
</item> <property name="wordWrap">
</layout> <bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="errorLabel">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="registrationLink">
<property name="text">
<string>Activate Telldus Live!</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>