Ubuntu Pastebin

Paste from me at Thu, 29 Jan 2015 11:45:39 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import QtQuick 2.0
import GSettings 1.0

MainView {
    id: root

    width: units.gu(100)
    height: units.gu(75)

    Timer {
        id: testTimer
        interval: 1 // This does delete the old component!
//        interval: 0  // This does NOT delete the old component
        running: false
        repeat: false
        onTriggered: {
            root.usageMode = usageModeSettings.usageMode
        }
    }

    GSettings {
        id: usageModeSettings
        schema.id: "com.canonical.Unity8"
    }
    Connections {
        target: usageModeSettings
        onUsageModeChanged: {
//            root.usageMode = usageModeSettings.usageMode // This does NOT delete the old component
            testTimer.start()
        }
    }

    property string usageMode: "Windowed"
    Loader {
        anchors.fill: parent
//        sourceComponent: usageModeSettings.usageMode === "Windowed" ? comp1 : comp2 // This does NOT delete the old component
        sourceComponent: root.usageMode === "Windowed" ? comp1 : comp2
    }

    Component {
        id: comp1
        Rectangle {
            color: "red"
            Component.onCompleted: print("red created")
            Component.onDestruction: print("red destructing")
        }
    }

    Component {
        id: comp2
        Rectangle {
            color: "blue"
            Component.onCompleted: print("blue created")
            Component.onDestruction: print("blue destructing")
        }
    }
}
Download as text