1/*
2    SPDX-FileCopyrightText: 2011 Nokia Corporation and /or its subsidiary(-ies) <qt-info@nokia.com>
3
4    This file is part of the Qt Components project.
5
6    SPDX-License-Identifier: BSD-3-Clause
7*/
8
9import QtQuick 2.1
10
11import "." 2.0 as PlasmaComponents
12
13/**
14 * Defines the content of a piece of the user interface, it's meant to be
15 * loaded by a PageStack or TabGroup element.  The typical use can be in small
16 * plasmoids or  mobile devices where the whole screen is a series of
17 * interchangeable and flickable pages, of which the user navigates across.
18 *
19 * @inherit QtQuick.Item
20 */
21Item {
22    id: root
23
24    /**
25     * type:PageStatus::Status
26     * The status of the page
27     *
28     * One of the following:
29     *
30     * - PageStatus.Inactive: the page is not visible
31     * - PageStatus.Activating: the page is transitioning into becoming the active page
32     * - PageStatus.Active: the page is the current active page
33     * - PageStatus.Deactivating: the page is transitioning into becoming inactive
34     */
35    property int status: PlasmaComponents.PageStatus.Inactive
36
37    /**
38     * type:PageStack
39     * The page stack that this page is owned by.
40     */
41    property Item pageStack
42
43    /**
44     * Sets the orientation for the Page
45     */
46    property int orientationLock: PlasmaComponents.PageOrientation.Automatic
47
48    /**
49     * Defines the toolbar contents for the page. If the page stack is set up
50     * using a toolbar instance, it automatically shows the currently active
51     * page's toolbar contents in the toolbar.
52     *
53     * The default value is null resulting in the page's toolbar to be
54     * invisible when the page is active.
55     */
56    property Item tools: null
57
58    visible: false
59
60    width: visible && parent ? parent.width : internal.previousWidth
61    height: visible && parent ? parent.height : internal.previousHeight
62
63    onWidthChanged: internal.previousWidth = (visible ? width : internal.previousWidth)
64    onHeightChanged: internal.previousHeight = (visible ? height : internal.previousHeight)
65
66    // This is needed to make a parentless Page component visible in the Designer of QtCreator.
67    // It's done here instead of binding the visible property because binding it to a script
68    // block returning false would cause an element on the Page not to end up focused despite
69    // specifying focus=true inside the active focus scope. The focus would be gained and lost
70    // in createObject.
71    Component.onCompleted: if (!parent) visible = true
72
73    QtObject {
74        id: internal
75        property int previousWidth: 0
76        property int previousHeight: 0
77    }
78}
79