~cyphermox/unity/phablet-packaging

« back to all changes in this revision

Viewing changes to Shell.qml

  • Committer: Tarmac
  • Author(s): Daniel d'Andrada
  • Date: 2013-04-19 14:51:08 UTC
  • mfrom: (603.1.34 remove_fakes_from_qml)
  • Revision ID: tarmac-20130419145108-wanpphpc2pbumgui
Purge fakes from QML code.
  
Instead of having several switches in the qml code to choose between fake
and real implementations of components, provide a fake implementation of
Ubuntu.Application module instead. That way we have a cleaner QML code
that is easier to test and we run exactly the same qml code both on the
target device and under a fake environment.

Approved by Michał Sawicz, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 */
16
16
 
17
17
import QtQuick 2.0
 
18
import Ubuntu.Application 0.1
18
19
import Ubuntu.Components 0.1
19
20
import "Dash"
20
 
import "Applications"
21
 
import "Applications/applications.js" as ApplicationsModel
22
21
import "Greeter"
23
22
import "Launcher"
24
23
import "Panel"
27
26
import "Components/Math.js" as MathLocal
28
27
import "Bottombar"
29
28
import "SideStage"
 
29
import "Applications/applications.js" as ApplicationsModel
30
30
 
31
31
FocusScope {
32
32
    id: shell
55
55
 
56
56
    property ListModel searchHistory: SearchHistoryModel {}
57
57
 
58
 
    // if running in Hybris environment, can offload running app management to it, else we fake it
59
 
    property var applicationManager
60
 
    // whether or not "import Ubuntu.Application" would work
61
 
    property bool importUbuntuApplicationAvailable: checkImportUbuntuApplicationAvailable()
62
 
 
63
 
    /* Checks if the "Ubuntu.Application" plugin is available, and if so use it for application management.
64
 
       Returns true if the plugin is available, false otherwise.
65
 
 
66
 
       This works around the lack of conditional imports in QML.
67
 
       Ref.: https://bugreports.qt-project.org/browse/QTBUG-16854
68
 
    */
69
 
    function checkImportUbuntuApplicationAvailable() {
70
 
        try {
71
 
            var object = Qt.createQmlObject('import Ubuntu.Application 0.1; import QtQuick 2.0; QtObject {}', shell, "");
72
 
            object.destroy();
73
 
            return true;
74
 
        } catch (error) {
75
 
            console.log("NOTICE: The Ubuntu.Application plugin was not found, so all window management is emulated in this application.\n\
76
 
This emulation will not be perfect, you *must* not trust it. To be safe always test on a device with Ubuntu.Application available.");
77
 
            return false;
78
 
        }
79
 
    }
 
58
    property var applicationManager: ApplicationManagerWrapper {}
80
59
 
81
60
    Component.onCompleted: {
82
 
        var component;
83
 
        if (!importUbuntuApplicationAvailable) {
84
 
            component = Qt.createComponent("Components/ApplicationManagerFake.qml");
85
 
        } else {
86
 
            component = Qt.createComponent("Components/ApplicationManagerWrapper.qml");
87
 
        }
88
 
 
89
 
        applicationManager = component.createObject(shell);
90
61
        applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
91
62
 
92
63
        // FIXME: if application focused before shell starts, shell draws on top of it only.
143
114
        }
144
115
    }
145
116
 
146
 
    // for Desktop only, to emulate window management when hybris not available
147
 
    Item {
148
 
        id: fakeWindowContainer
149
 
 
150
 
        property real sideStageWidth: sideStage.width
151
 
 
152
 
        anchors.fill: parent
153
 
        z: -1000
154
 
    }
155
 
 
156
117
    Item {
157
118
        id: underlay
158
119