~paulliu/unity8/zoomImage

« back to all changes in this revision

Viewing changes to qml/Components/ApplicationManagerWrapper.qml

  • Committer: Ying-Chun Liu
  • Date: 2014-04-22 15:33:24 UTC
  • mfrom: (734.1.119 unity8)
  • Revision ID: paul.liu@canonical.com-20140422153324-9o7r3gh3dzczx4sr
Merge upstream
[ Albert Astals ]
* Fix last item X position Fixes clicking on the last item sometimes
  not working (LP: #1301871)
* Use upstart in ./run Makes it so that you can use the lock button on
  the device without getting that nasty hwc crash
* Remove AnimationControllerWithSignals.
* Use the correct delegate base item for the Carousel test
* Some simplification in DashContent Kill the ScopeDelegateMapper in
  favour of a simple if (that will eventually go away). Removal of all
  the fake scopes in the tests that added nothing of value to the
  tests. Removal of movementEnded signal that was unused. Removal of
  movementStarted and positionedAtBeginning signals that were being
  used as function calls. Rework DashContent tests so they what the
  function does what it is supposed to do instead of just making sure
  QML signals work .
* Improve Card creation time by adding loaders that make sure only
  what's needed is loaded In my computer it goes from RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotSummaryMode
  l": 3.217 msecs per iteration (total: 3,218, iterations: 1000)
  RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotModel":
  1.647 msecs per iteration (total: 1,648, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleModel": 1.514
  msecs per iteration (total: 1,515, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtModel": 1.471 msecs per
  iteration (total: 1,471, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardArtModel": 1.447 msecs per
  iteration (total: 1,448, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleModel": 1.276 msecs per
  iteration (total: 1,276, iterations: 1000) to RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotSummaryMode
  l": 2.916 msecs per iteration (total: 2,917, iterations: 1000)
  RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotModel":
  1.504 msecs per iteration (total: 1,504, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleModel": 1.060
  msecs per iteration (total: 1,061, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtModel": 1.052 msecs per
  iteration (total: 1,053, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardArtModel": 0.727 msecs per
  iteration (total: 728, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleModel": 0.817 msecs per
  iteration (total: 818, iterations: 1000) (LP: #1297197)
[ Allan LeSage ]
* DashApps emulator get_applications should return a list ordered by
  visible y, x.
[ Andrea Cimitan ]
* Workaround for lp1301309 until fixes for palette in ui toolkit (LP:
  #1301309)
[ Leo Arias ]
* Reverted the change that returns application cards instead of
  titles.
[ Nick Dedekind ]
* Indicator services started by unity8 upstart configuration rather
  than manual emmision from indicator manager.
[ Mirco Müller ]
* Fix notification ap-test assertions.
[ Michael Terry ]
* Use new tablet and phone backgrounds from Design.
[ Michael Zanetti ]
* workaround the QTestLogger assertion issue with make tryXyz and our
  custom uqmlscene
[ Michael Terry ]
* When an application requests focus, handle it in Shell.qml by hiding
  the greeter and stopping any edge demo. (LP: #1227753)
[ Leo Arias ]
* Use subprocess.check_call when caling url-dispatcher, so an error
  will be raised if it fails.
* Test application life cycle with fake apps, instead of messaging and
  address book.
[ Didier Roche ]
* Resync trunk with previous revert upload
[ Michał Sawicz ]
* Set the Qt.ImhNoPredictiveText flag on wifi password field, fixes
  lp:1291575 (LP: #1291575)
[ Albert Astals ]
* Take into account the originY when specifying the delegate ranges
  Fixes bug #1300302 (LP: #1300302)
[ CI bot ]
* Resync trunk
[ Allan LeSage ]
* Swiping open an indicator must show its correct title--protect
  against lp:1253804 . (LP: #1253804)
[ Alexander Sack ]
* Fix TypeError: issue seen in system_integration autopilot test on
  image 279. (LP: #1303685)
[ Bill Filler ]
* Set the Qt.ImhNoPredictiveText flag on wifi password field, fixes
  lp:1291575 (LP: #1291575)
[ Leo Arias ]
* Added a search autopilot helper.
[ Michael Terry ]
* Provide a all-in-one script for getting a device to an unlocked
  state.
* Revert to previous version as it's linked to latest sdk change which
  is making gallery-app AP tests failing on the CI dashboard
[ Albert Astals ]
* Adapt to new TabBar
[ Michael Terry ]
* Re-enable test_networkmanager_integration autopilot test on phone
  platforms
[ CI bot ]
* Resync trunk
[ Leo Arias ]
* Reverted the open_preview autopilot helper to return a Preview
  object.
[ Albert Astals ]
* If not running in Mir load the "fake" application manager (LP:
  #1301547)
* Remove unused properties from DashRenderer
[ Michael Zanetti ]
* Fix tests after right edge merge. Drop old stages tests. Fix right
  edge tests if someone doesn't have the GRID_UNIT_PX exported. make
  GenericScopeView test more robust that broke because the ordering
  changed
* add "make xvfbtestSomething" target to run qml tests in xvfb
* make the "make test" commit hook work again
[ Michał Sawicz ]
* Bump version to ensure incompatibility with previous Unity.Application
  implementations.
* We'll only have the unity-mir and mock Ubuntu.Application plugins
  now, no need for mangling the import paths.
[ Michal Hruby ]
* Remove the albumart image provider. (LP: #1262711)
* Don't reset search string after 2 seconds. (LP: #1297246)
[ James Henstridge ]
* Remove the albumart image provider. (LP: #1262711)
[ Albert Astals ]
* Carousel: Add test to make sure we only create the needed delegates
  and not more
* LVWPH: Remove processEvents() call from updatePolish() It causes
  some reentrancy issues and in some times you end up in polishItems()
  with items that have been deleted because you called processEvents()
  This means i need a small tweak in itemGeometryChanged to not
  reposition items if we are inside a setContentHeight call and two
  small tweaks to tests since now things happen in a different order
  and numbers are different (though equivalent) (LP: #1297240)
* Card.qml binding loops are gone. hooray \o/ Also made the aspect
  properties readonly
[ Mirco Müller ]
* A potential fix for "Cannot read property 'state' of null"-failure
  on Jenkins with the VisualSnapDecisionsQueue QML-test of
  notifications.
[ Michael Terry ]
* Pass user's preference for auto-brightness on to powerd. (LP:
  #1273174)
[ Michael Zanetti ]
* Registers a dummy QObject as QTestRootObject in uqmlscene in order
  to fix make trySomething with Qt 5.2.
* For now, have libunity-private depending on libunity-core-6.0-9 as the
  gsettings schema is here. The dependency wasn't direct and dropped from
  Touch image #271. Consequently, unity8 didn't start (gsettings
  segfaulting).
  Proper strategy will be to include the schema in another package to only
  pull it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013 Canonical, Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; version 3.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 */
16
 
 
17
 
import QtQuick 2.0
18
 
import Unity.Application 0.1
19
 
 
20
 
Item {
21
 
    id: root
22
 
 
23
 
    property alias mainStageApplications: mainStageModel
24
 
    property alias sideStageApplications: sideStageModel
25
 
    property variant mainStageFocusedApplication: null
26
 
    property variant sideStageFocusedApplication: null
27
 
    property bool sideStageEnabled: true
28
 
    property bool keyboardVisible: ApplicationManager.keyboardVisible
29
 
    property int keyboardHeight: ApplicationManager.keyboardHeight
30
 
 
31
 
    property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
32
 
 
33
 
    signal focusRequested(string appId)
34
 
 
35
 
    ApplicationsModelStageFiltered {
36
 
        id: mainStageModel
37
 
        stage: ApplicationInfo.MainStage
38
 
    }
39
 
 
40
 
    ApplicationsModelStageFiltered {
41
 
        id: sideStageModel
42
 
        stage: ApplicationInfo.SideStage
43
 
    }
44
 
 
45
 
    Connections {
46
 
        target: ApplicationManager
47
 
        onFocusedApplicationIdChanged: {
48
 
            var app = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
49
 
            if (!app) { //nothing at all focused, so clear all
50
 
                mainStageFocusedApplication = null;
51
 
                sideStageFocusedApplication = null;
52
 
            } else {
53
 
                if (app.stage == ApplicationInfo.MainStage) {
54
 
                    mainStageFocusedApplication = app;
55
 
                    // possible the side stage app being unfocused fired this signal, so check for it
56
 
                    if (sideStageFocusedApplication && !sideStageFocusedApplication.focused)
57
 
                        sideStageFocusedApplication = null;
58
 
                } else {
59
 
                    sideStageFocusedApplication = app;
60
 
                    // possible the main stage app being unfocused fired this signal, so check for it
61
 
                    if (mainStageFocusedApplication && !mainStageFocusedApplication.focused)
62
 
                        mainStageFocusedApplication = null;
63
 
                }
64
 
            }
65
 
        }
66
 
 
67
 
        onFocusRequested: {
68
 
            // if no side stage enabled, override application's stage parameter
69
 
            var app = ApplicationManager.findApplication(appId);
70
 
            if (app && app.stage === ApplicationInfo.SideStage && !sideStageEnabled) {
71
 
                app.stage = ApplicationInfo.MainStage;
72
 
            }
73
 
 
74
 
            root.focusRequested(appId);
75
 
        }
76
 
    }
77
 
 
78
 
    function activateApplication(desktopFile, argument) {
79
 
        var appId;
80
 
 
81
 
        // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
82
 
        // TODO: convert entire shell to use appId only.
83
 
        if (desktopFile.indexOf(".desktop") >= 0) {
84
 
            appId = desktopFileToAppId(desktopFile);
85
 
        } else {
86
 
            appId = desktopFile;
87
 
        }
88
 
 
89
 
        var application = ApplicationManager.findApplication(appId);
90
 
        if (application !== null) {
91
 
            return application;
92
 
        }
93
 
 
94
 
        var execFlags = sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
95
 
 
96
 
        if (argument) {
97
 
            return ApplicationManager.startApplication(appId, execFlags, [argument]);
98
 
        } else {
99
 
            return ApplicationManager.startApplication(appId, execFlags);
100
 
        }
101
 
    }
102
 
 
103
 
    function stopApplication(application) {
104
 
        var appId;
105
 
 
106
 
        // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
107
 
        // TODO: convert entire shell to use appId only.
108
 
        if (typeof application == "string") {
109
 
            appId = application;
110
 
        } else {
111
 
            appId = desktopFileToAppId(application.desktopFile);
112
 
        }
113
 
 
114
 
        ApplicationManager.stopApplication(appId);
115
 
    }
116
 
 
117
 
    function focusApplication(application) {
118
 
        if (application == null || application == undefined) {
119
 
            return;
120
 
        }
121
 
 
122
 
        ApplicationManager.focusApplication(application.appId);
123
 
    }
124
 
 
125
 
    function unfocusCurrentApplication() {
126
 
        ApplicationManager.unfocusCurrentApplication();
127
 
    }
128
 
 
129
 
    function moveRunningApplicationStackPosition(from, to, stage) {
130
 
        if (from == to || from < 0 || to < 0) return;
131
 
 
132
 
        if (stage == ApplicationInfo.SideStage) {
133
 
            sideStageModel.move(from, to);
134
 
        } else {
135
 
            mainStageModel.move(from, to);
136
 
        }
137
 
    }
138
 
 
139
 
    function getApplicationFromDesktopFile(desktopFile, stage) {
140
 
        var appId;
141
 
 
142
 
        // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
143
 
        // TODO: convert entire shell to use appId only.
144
 
        if (desktopFile.indexOf(".desktop") >= 0) {
145
 
            appId = desktopFileToAppId(desktopFile);
146
 
        } else {
147
 
            appId = desktopFile;
148
 
        }
149
 
 
150
 
        for (var i = 0, len = ApplicationManager.count; i < len; i++ ) {
151
 
            var app = ApplicationManager.get(i);
152
 
 
153
 
            // if stage not specified, return whichever app running on either stage
154
 
            if (app.appId == appId && (stage == undefined || app.stage == stage)) {
155
 
                return app;
156
 
            }
157
 
        }
158
 
    }
159
 
 
160
 
    function desktopFileToAppId(desktopFile) {
161
 
        var right = desktopFile.lastIndexOf(".desktop");
162
 
        var left = desktopFile.lastIndexOf("/");
163
 
        if (left == -1 || right == -1 || left == right) {
164
 
            console.log("ApplicationManagerWrapper: unable to extract appId from '" + desktopFile + "'");
165
 
            return "";
166
 
        }
167
 
        return desktopFile.substring(left+1, right);
168
 
    }
169
 
}