Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 0.75 KB | None | 0 0
  1. import QtQuick 2.5
  2. import Sailfish.Silica 1.0
  3. import QtSensors 5.2
  4.  
  5. Page {
  6.     OrientationSensor {
  7.         id: orientationSensor
  8.         active: true
  9.     }
  10.     Image {
  11.         anchors.centerIn: parent
  12.         scale: Math.min(parent.width, parent.height) / Theme.iconSizeMedium
  13.         source: "image://theme/icon-m-capslock"
  14.         rotation: {
  15.             if (!orientationSensor.reading) return 0;
  16.             switch (orientationSensor.reading.orientation) {
  17.             case OrientationReading.TopUp: return 0;
  18.             case OrientationReading.RightUp: return 90;
  19.             case OrientationReading.TopDown: return 180;
  20.             case OrientationReading.LeftUp: return 270;
  21.             default: return 0;
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement