Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.00 KB | None | 0 0
  1. import QtQuick 2.5
  2. import Sailfish.Silica 1.0
  3. import QtSensors 5.2
  4.  
  5. Page {
  6.     AmbientLightSensor {
  7.         id: ambientSensor
  8.         active: true
  9.     }
  10.     LightSensor {
  11.         id: lightSensor
  12.         active: true
  13.     }
  14.     PageHeader { title: qsTr("Light Sensors") }
  15.     Switch {
  16.         property real scaleFactor: {
  17.             if (!ambientSensor.reading) return 1.0;
  18.             return ambientSensor.reading.lightLevel / 5;
  19.         }
  20.         anchors.centerIn: parent
  21.         enabled: ambientSensor.active
  22.         checked: ambientSensor.reading &&
  23.             (ambientSensor.reading.lightLevel !==
  24.                   AmbientLightReading.Undefined)
  25.         automaticCheck: false
  26.         scale: Math.min(parent.width, parent.height) *
  27.                scaleFactor / Theme.iconSizeSmall
  28.     }
  29.     Label {
  30.         anchors.centerIn: parent
  31.         text: lightSensor.reading ?
  32.             lightSensor.reading.illuminance : " "
  33.         color: Theme.highlightColor
  34.         font.bold: true
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement