~chris.gagnon/ubuntu-ui-toolkit/fix-bug-1388896

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/PageStack.qml

  • Committer: CI bot
  • Author(s): Zsombor Egri, Michael Sheldon, Zoltán Balogh, Christian Dywan, Tim Peeters
  • Date: 2014-10-07 12:09:27 UTC
  • mfrom: (1000.249.11 landing-0711)
  • Revision ID: ps-jenkins@lists.canonical.com-20141007120927-ucysonqxn60vu8gz
  [ Michael Sheldon ]
  * Removes the keyboard anchor animation as this is now implemented
    in the keyboard.

  [ Tim Peeters ]
  * PageStack push returns the pushed page. Fixes LP: #1361919
  * Add selection mode as a preset to the header configuration.
    Fixes LP: #1370146.

  [ Zsombor Egri ]
  * Fix Dialog foreground sizing. Fixes LP: #1337555, LP: #1337556.
  * Workaround for StateSaver to fall back to use qgetenv() when
    QStandardPaths fails to return XDG_RUNTIME_DIR path.
    Fixes LP: #1363112.

  [ Christian Dywan ]
  * Add unit tests for MathUtils API.
    Fixes LP: #1244685.
  * Text field hint should use the same font as the editor.
    Fixes LP: #1237400.
  * Read-only text fields mustn't have a clear button.
    Fixes LP: #1337257.
  * autopilot package should source-depend on QML plugin.
    Fixes LP: #1236085.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 */
16
16
 
17
 
import QtQuick 2.0
 
17
import QtQuick 2.2
18
18
import "stack.js" as Stack
19
19
 
20
20
/*!
159
159
      \preliminary
160
160
      Push a page to the stack, and apply the given (optional) properties to the page.
161
161
      The pushed page may be an Item, Component or URL.
 
162
      The function returns the Item that was pushed, or the Item that was created from
 
163
      the Component or URL. Depending on the animation of the header, the returned
 
164
      Page may or may not be active and on top of the PageStack yet.
162
165
     */
163
166
    function push(page, properties) {
164
167
        internal.finishPreviousAction();
165
 
        internal.pageToPush = page;
166
 
        internal.propertiesToPush = properties;
 
168
        internal.pageWrapper = internal.createWrapper(page, properties);
 
169
        var pageObject = internal.pageWrapper.object;
 
170
 
167
171
        if (internal.animateHeader && internal.stack.size() > 0) {
168
 
            internal.headStyle.animateOutFinished.connect(internal.createAndPush);
 
172
            internal.headStyle.animateOutFinished.connect(internal.pushWrapperObject);
169
173
            internal.headStyle.animateOut();
170
174
        } else {
171
 
            internal.createAndPush();
 
175
            internal.pushWrapperObject();
172
176
        }
 
177
        return pageObject;
173
178
    }
174
179
 
175
180
    /*!
197
202
      Deactivate the active page and clear the stack.
198
203
     */
199
204
    function clear() {
 
205
        internal.finishPreviousAction();
200
206
        while (internal.stack.size() > 0) {
201
207
            internal.stack.top().active = false;
202
208
            if (internal.stack.top().canDestroy) internal.stack.top().destroyObject();
239
245
            }
240
246
        }
241
247
 
242
 
        // The page and properties to push on the stack when the OUT animation
243
 
        // finishes.
244
 
        property var pageToPush
245
 
        property var propertiesToPush
 
248
        // The PageWrapper to be pushed on the stack by pushWrapperObject().
 
249
        property var pageWrapper: null
246
250
 
247
251
        // Called when the header animate OUT transition finishes for push() or instantly
248
252
        // when header animations are disabled.
249
 
        function createAndPush() {
 
253
        function pushWrapperObject() {
250
254
            if (internal.animateHeader) {
251
 
                headStyle.animateOutFinished.disconnect(internal.createAndPush);
 
255
                headStyle.animateOutFinished.disconnect(internal.pushWrapperObject);
252
256
            }
253
257
            if (internal.stack.size() > 0) internal.stack.top().active = false;
254
 
            internal.stack.push(internal.createWrapper(pageToPush, propertiesToPush));
 
258
            internal.stack.push(internal.pageWrapper);
 
259
            internal.pageWrapper = null;
255
260
            internal.stackUpdated();
256
261
        }
257
262
 
275
280
        function createWrapper(page, properties) {
276
281
            var wrapperComponent = Qt.createComponent("PageWrapper.qml");
277
282
            var wrapperObject = wrapperComponent.createObject(pageStack);
278
 
            wrapperObject.reference = page;
279
283
            wrapperObject.pageStack = pageStack;
280
284
            wrapperObject.properties = properties;
 
285
            // set reference last because it will trigger creation of the object
 
286
            //  with specified properties.
 
287
            wrapperObject.reference = page;
281
288
            return wrapperObject;
282
289
        }
283
290