123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- /**
- * Copyright © 2010 Digia Plc
- * Copyright © 2010 Nokia Corporation
- *
- * All rights reserved.
- *
- * Nokia and Nokia Connecting People are registered trademarks of
- * Nokia Corporation.
- * Java and all Java-based marks are trademarks or registered
- * trademarks of
- * Sun Microsystems, Inc. Other product and company names
- * mentioned herein may be
- * trademarks or trade names of their respective owners.
- *
- *
- * Subject to the conditions below, you may, without charge:
- *
- * · Use, copy, modify and/or merge copies of this software and
- * associated documentation files (the "Software")
- *
- * · Publish, distribute, sub-licence and/or sell new software
- * derived from or incorporating the Software.
- *
- *
- * This file, unmodified, shall be included with all copies or
- * substantial portions
- * of the Software that are distributed in source code form.
- *
- * The Software cannot constitute the primary value of any new
- * software derived
- * from or incorporating the Software.
- *
- * Any person dealing with the Software shall not misrepresent
- * the source of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
- * KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- import Qt 4.7
- import "javascript/sql.js" as HCS
- import "../colibri"
- import "styles"
- Item {
- id: screen
- property int colSpacing : 15
- property string room : "room1"
- property bool isVisible : false
- property CLStyle style : StyleHomeControlSystem{}
- property int textSize : 28
- property color textColor: style.textColor
- property bool mute: false
- property int light : 0
- property int temp : 0
- property int volume : 0
- property string name : ""
- property bool onStartUp : true
- signal closeWindow()
- /**
- * Updates room information.
- */
- function updateInfo() {
- HCS.getTheRoom(screen.room);
- screen.name = HCS.theRoom.name;
- meter.opacity = (HCS.theRoom.temperature-adjustTemperature.minimum)/(adjustTemperature.maximum-adjustTemperature.minimum)
- meter.text = HCS.theRoom.temperature+"<html>°</html>C";
- meter1.text = HCS.theRoom.temperature+"<html>°</html>C";
- if (HCS.theRoom.temperature == adjustTemperature.minimum)meter.value = false
- else meter.value = true
- adjustTemperature.setValue(HCS.theRoom.temperature);
- lamp.opacity = (HCS.theRoom.light-adjustLight.minimum)/(adjustLight.maximum-adjustLight.minimum)
- if (HCS.theRoom.light == adjustLight.minimum)lamp.light = false
- else lamp.light = true
- adjustLight.setValue(HCS.theRoom.light);
- screen.mute = HCS.theRoom.mute
- if (!screen.mute && HCS.theRoom.volume != adjustVolume.minimum){
- screen.mute = false
- mute.opacity = 0
- speaker.opacity = 1
- } else {
- screen.mute = true
- mute.opacity = 1
- speaker.opacity = 0
- }
- onStartUp = true;
- adjustVolume.setValue(HCS.theRoom.volume);
- histogramValues(volume);
- }
- /**
- * Sets values to small histogram which is over loudspeaker.
- * @param value Current volume in speaker
- */
- function histogramValues(value){
- var array = new Array(3)
- if ( adjustVolume.minimum <= value && value < adjustVolume.maximum/3){
- array[0]=new Array(2*value/(adjustVolume.maximum/3),"1")
- array[1]=new Array(3*value/(adjustVolume.maximum/3),"1")
- array[2]=new Array(4*value/(adjustVolume.maximum/3),"1")
- }
- if (adjustVolume.maximum/3 <= value && value < adjustVolume.maximum/1.5){
- array[0]=new Array(3*value/(adjustVolume.maximum/1.5),"1")
- array[1]=new Array(5*value/(adjustVolume.maximum/1.5),"1")
- array[2]=new Array(7*value/(adjustVolume.maximum/1.5),"1")
- }
- if (adjustVolume.maximum/1.5 <= value && value <= adjustVolume.maximum){
- array[0]=new Array(4*value/(adjustVolume.maximum),"1")
- array[1]=new Array(7*value/(adjustVolume.maximum),"1")
- array[2]=new Array(10*value/(adjustVolume.maximum),"1")
- }
- histogram.setValues(array);
- }
- Component.onCompleted: {
- updateInfo();
- textSize = screen.height * 0.075
- }
- onHeightChanged: {
- textSize = screen.height * 0.075
- }
- onRoomChanged: {
- updateInfo();
- }
- width: 600//parent.width
- height: 480//parent.height
- Item {
- id: roomAdjustWidget
- anchors.horizontalCenter:parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
- width: parent.width
- height: parent.height
- Rectangle{
- width:roomAdjustWidget.width * (400/420)
- height:roomAdjustWidget.height * (255/275)
- color: style.selectionColor
- anchors.centerIn:parent
- radius:7
- }
- Image {
- id:bgPic
- source: "images/control_bg_trans_420x275_png.png";
- width:roomAdjustWidget.width
- height:roomAdjustWidget.height
- opacity:0.7
- }
- MouseArea {
- anchors.fill: parent
- }
- RoomExitButton {
- windowWidth: screen.width
- windowHeight: screen.height
- style: screen.style
- onClicked: screen.closeWindow();
- }
- Column{
- spacing: colSpacing
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- Text {
- id: roomName
- text: screen.name
- anchors.horizontalCenter:parent.horizontalCenter
- font.bold: true
- color: screen.textColor
- font.pixelSize: textSize
- }
- Row {
- spacing: colSpacing
- Item{
- height:roomAdjustWidget.height*0.20
- width: height
- Text{
- id:meter1
- font.pixelSize: textSize
- color: screen.style.textColor
- smooth:true
- y:roomAdjustWidget.height*0.03
- }
- Text{
- id:meter
- property bool value : false
- font.pixelSize: textSize
- color: screen.style.textColor
- smooth:true
- y:roomAdjustWidget.height*0.03
- }
- MouseArea {
- id: mouseArea2
- anchors.fill: parent
- onClicked: {
- meter.value = !meter.value
- if(meter.value){
- temp=adjustTemperature.maximum
- meter.opacity = 1
- adjustTemperature.setValue(adjustTemperature.maximum)
- } else {
- temp=adjustTemperature.minimum
- meter.opacity = 0
- adjustTemperature.setValue(adjustTemperature.minimum)
- }
- meter.text = temp+"<html>°</html>C";
- meter1.text = temp+"<html>°</html>C";
- }
- }
- }
- CLSlider{
- id:adjustTemperature
- style: screen.style
- height:roomAdjustWidget.height*0.15
- width:roomAdjustWidget.width*0.6
- minimum:18
- maximum:30
- borderWidth: 3
- onValueChanged: {
- temp = adjustTemperature.value
- if(temp == adjustTemperature.minimum)meter.value = false
- else meter.value = true
- meter.opacity = (temp-adjustTemperature.minimum)/(adjustTemperature.maximum-adjustTemperature.minimum)
- meter.text = temp+"<html>°</html>C";
- meter1.text = temp+"<html>°</html>C";
- }
- }
- }
- Row {
- spacing: colSpacing
- Item{
- height:roomAdjustWidget.height*0.20
- width: height
- Image {
- anchors.fill:parent
- smooth:true
- source:"images/lamp_off_100x100.png"
- }
- Rectangle{
- id:lamp
- property bool light : false
- color:"transparent"
- anchors.fill:parent
- Image{
- anchors.fill:parent
- smooth:true
- source:"images/glow_200x200.png"
- }
- Image{
- anchors.fill:parent
- smooth:true
- source:"images/lamp_on_100x100.png"
- }
- }
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: {
- if(lamp.light){
- light=adjustLight.minimum
- adjustLight.setValue(adjustLight.minimum)
- lamp.opacity = 0
- lamp.light = false
- } else {
- light=adjustLight.maximum
- lamp.opacity = 1
- adjustLight.setValue(adjustLight.maximum)
- lamp.light = true
- }
- }
- }
- }
- CLSlider{
- id:adjustLight
- style:screen.style
- minimum:0
- maximum:100
- borderWidth: 3
- height:roomAdjustWidget.height*0.15
- width:roomAdjustWidget.width*0.6
- onValueChanged: {
- light=adjustLight.value
- if(light == adjustLight.minimum)lamp.light = false
- else lamp.light = true
- lamp.opacity = (light-adjustLight.minimum)/(adjustLight.maximum-adjustLight.minimum)
- }
- }
- }
- Row {
- spacing: colSpacing
- Item{
- height:roomAdjustWidget.height*0.20
- width: height
- Image {
- anchors.fill:parent
- source:"images/speaker_100x100.png"
- smooth:true
- }
- Item{
- anchors.fill:parent
- id:speaker
- CLHistogram{
- id: histogram;
- style: screen.style;
- gradientWhenDefault:Gradient {
- GradientStop { position: 0.0; color: "#8aff00" }
- GradientStop { position: 1.0; color: "#57b229" }
- }
- colorWhenDefault:"#8aff00"
- maxValue: 25;
- anchors.right : parent.right;
- anchors.bottom: parent.bottom;
- width: parent.width
- height: parent.height*1.3
- opacity: 1;
- y:-20
- }
- }
- Image{
- id:mute
- anchors.fill:parent
- source:"images/speaker_mute_100x100.png"
- smooth:true
- }
- MouseArea {
- id: mouseArea3
- anchors.fill: parent
- onClicked: {
- if (adjustVolume.value != adjustVolume.minimum) {
- screen.mute = !screen.mute
- mute.opacity = (screen.mute)?1:0;
- speaker.opacity = (screen.mute)?0:1;
- }
- }
- }
- }
- CLSlider{
- id:adjustVolume
- style:screen.style
- minimum:0
- maximum:100
- borderWidth: 3
- height:roomAdjustWidget.height*0.15
- width:roomAdjustWidget.width*0.6
- onValueChanged: {
- volume=adjustVolume.value
- if( !onStartUp ) {
- if(volume == adjustVolume.minimum) {
- screen.mute = true
- mute.opacity = 1
- speaker.opacity = 0
- } else {
- screen.mute = false
- mute.opacity = 0
- histogramValues(value)
- speaker.opacity = 1
- }
- }
- onStartUp = false;
- }
- }
- }
- }
- }
- }
|