~system-settings-touch/ubuntu-system-settings/trunk

« back to all changes in this revision

Viewing changes to plugins/orientation-lock/EntryComponent.qml

  • Committer: CI bot
  • Author(s): jonas-drange
  • Date: 2014-08-15 16:45:35 UTC
  • mfrom: (890.3.7 orientation-lock)
  • Revision ID: ps-jenkins@lists.canonical.com-20140815164535-ukq0x4hxkm05e6ba
[main panel] point rotation lock at new backend and add (skipped) tests Fixes: 1288332
Approved by: Ken VanDine, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import GSettings 1.0
22
22
import QtQuick 2.0
 
23
import QtQuick.Window 2.1
23
24
import Ubuntu.Components 0.1
24
25
import Ubuntu.Components.ListItems 0.1 as ListItem
25
26
 
 
27
 
26
28
ListItem.Standard {
 
29
 
 
30
    function orientationToSetting (o) {
 
31
        switch (o) {
 
32
            case Qt.PrimaryOrientation:
 
33
                return "PrimaryOrientation";
 
34
            case Qt.LandscapeOrientation:
 
35
                return "LandscapeOrientation";
 
36
            case Qt.PortraitOrientation:
 
37
                return "PortraitOrientation";
 
38
            case Qt.InvertedLandscapeOrientation:
 
39
                return "InvertedLandscapeOrientation";
 
40
            case Qt.InvertedPortraitOrientation:
 
41
                return "InvertedPortraitOrientation";
 
42
            default:
 
43
                console.warn('Unknown screen orientation');
 
44
                return "none";
 
45
        }
 
46
    }
 
47
 
27
48
    id: root
28
49
    iconSource: model.icon
29
50
    iconFrame: true
30
51
    text: i18n.tr(model.displayName)
31
52
    control: Switch {
32
53
        id: control
33
 
        checked: systemSettings.rotationLock
34
 
        onCheckedChanged: systemSettings.rotationLock = checked
 
54
        objectName: "orientationLockSwitch"
 
55
        checked: systemSettings.orientationLock && systemSettings.orientationLock !== "none"
 
56
        onClicked: {
 
57
            if (checked) {
 
58
                systemSettings.orientationLock = orientationToSetting(Screen.orientation);
 
59
            } else {
 
60
                systemSettings.orientationLock = "none";
 
61
            }
 
62
        }
35
63
 
36
64
        GSettings {
37
65
            id: systemSettings
38
66
            schema.id: "com.ubuntu.touch.system"
39
 
            onChanged: {
40
 
                if (key == "rotationLock")
41
 
                    control.checked = value
42
 
            }
43
67
        }
44
68
    }
45
69
}