summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/touch/content/ButtonPage.qml4
-rw-r--r--examples/touch/content/ProgressBarPage.qml4
-rw-r--r--examples/touch/content/SliderPage.qml5
-rw-r--r--examples/touch/content/TabBarPage.qml4
-rw-r--r--examples/touch/content/TextInputPage.qml4
-rw-r--r--examples/touch/main.qml4
-rw-r--r--src/controls/Page.qml99
-rw-r--r--src/controls/PageStack.qml73
-rw-r--r--src/controls/controls.pro1
-rw-r--r--src/controls/plugin.cpp4
-rw-r--r--src/controls/plugin.pri5
-rw-r--r--src/controls/qmldir1
-rw-r--r--src/controls/qtstack.cpp164
-rw-r--r--src/controls/qtstack_p.h (renamed from src/controls/qpagestatus.h)52
-rw-r--r--tests/auto/controls/data/tst_pagestack.qml2
-rw-r--r--tests/auto/controls/data/tst_stack.qml (renamed from tests/auto/controls/data/tst_page.qml)15
-rw-r--r--tests/manual/PageStack.qml35
17 files changed, 295 insertions, 181 deletions
diff --git a/examples/touch/content/ButtonPage.qml b/examples/touch/content/ButtonPage.qml
index ff86c8140..cc5925ce0 100644
--- a/examples/touch/content/ButtonPage.qml
+++ b/examples/touch/content/ButtonPage.qml
@@ -46,7 +46,9 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
-Page {
+Item {
+ width: parent.width
+ height: parent.height
property real progress: 0
SequentialAnimation on progress {
diff --git a/examples/touch/content/ProgressBarPage.qml b/examples/touch/content/ProgressBarPage.qml
index abbf78fc7..86a46b69b 100644
--- a/examples/touch/content/ProgressBarPage.qml
+++ b/examples/touch/content/ProgressBarPage.qml
@@ -46,7 +46,9 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
-Page {
+Item {
+ width: parent.width
+ height: parent.height
property real progress: 0
SequentialAnimation on progress {
diff --git a/examples/touch/content/SliderPage.qml b/examples/touch/content/SliderPage.qml
index d90a3c2cd..8d9ff0b1f 100644
--- a/examples/touch/content/SliderPage.qml
+++ b/examples/touch/content/SliderPage.qml
@@ -46,7 +46,10 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
-Page {
+Item {
+ width: parent.width
+ height: parent.height
+
Column {
spacing: 12
anchors.centerIn: parent
diff --git a/examples/touch/content/TabBarPage.qml b/examples/touch/content/TabBarPage.qml
index 0a47308b6..41de78220 100644
--- a/examples/touch/content/TabBarPage.qml
+++ b/examples/touch/content/TabBarPage.qml
@@ -46,7 +46,9 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
-Page {
+Item {
+ width: parent.width
+ height: parent.height
TabView {
anchors.fill: parent
diff --git a/examples/touch/content/TextInputPage.qml b/examples/touch/content/TextInputPage.qml
index e363648b8..3f408d472 100644
--- a/examples/touch/content/TextInputPage.qml
+++ b/examples/touch/content/TextInputPage.qml
@@ -46,7 +46,9 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
-Page {
+Item {
+ width: parent.width
+ height: parent.height
property real progress: 0
SequentialAnimation on progress {
diff --git a/examples/touch/main.qml b/examples/touch/main.qml
index 3ce116f36..2546b7da1 100644
--- a/examples/touch/main.qml
+++ b/examples/touch/main.qml
@@ -133,7 +133,9 @@ ApplicationWindow {
id: pageStack
anchors.fill: parent
- initialPage: Page {
+ initialPage: Item {
+ width: parent.width
+ height: parent.height
ListView {
model: pageModel
anchors.fill: parent
diff --git a/src/controls/Page.qml b/src/controls/Page.qml
deleted file mode 100644
index 4295f65c0..000000000
--- a/src/controls/Page.qml
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-import QtQuick.Controls 1.0
-
-/*!
- \qmltype Page
- \inqmlmodule QtQuick.Controls 1.0
- \ingroup viewitems
- \brief A Page is an Item you can push on a PageStack.
-
- A \a Page is the main Item pushed onto a \l PageStack. It normally contains a discrete
- set of information and interaction elements meant for the user to solve a specific task, and
- contains properties to use when working with a PageStack.
- See \l PageStack for more information.
-
- \qml
- \endqml
-*/
-
-Item {
- id: root
-
- /*! \readonly
- The status of the page. It can have one of the following values:
- \list
- \li \c PageStatus.Inactive: the page is not visible
- \li \c PageStatus.Activating: the page is transitioning into becoming an active page on the stack
- \li \c PageStatus.Active: the page is on top of the stack
- \li \c PageStatus.Deactivating: the page is transitioning into becoming inactive
- \endlist */
- readonly property alias status: root.__status
- /*! \readonly
- This property contains the PageStack the page is in. If the page is not inside
- a PageStack, \a pageStack will be \c null. */
- readonly property alias pageStack: root.__pageStack
- /*! \readonly
- This property contains the index of the page inside \l{pageStack}{PageStack}, so
- that \l{PageStack::get()}{pageStack.get(index)} will
- return the page itself. If \l{Page::pageStack}{pageStack} is \c null, \a index
- will be \c -1. */
- readonly property alias index: root.__index
- /*! This property can be set to override the default animations used
- during a page transition. To better understand how to use this
- property, refer to the \l{PageStack#Transitions}{transition documentation} in PageStack.
- \sa {PageStack::animations}{PageStack.animations} */
- property PageTransition pageTransition
-
- visible: false // PageStack will show/hide the page as needed
- width: parent.width
- height: parent.height
-
- // ********** PRIVATE API **********
-
- /*! \internal */
- property int __status: PageStatus.Inactive
- /*! \internal */
- property PageStack __pageStack: null
- /*! \internal */
- property int __index: -1
-}
diff --git a/src/controls/PageStack.qml b/src/controls/PageStack.qml
index 89cf0170c..388a766ed 100644
--- a/src/controls/PageStack.qml
+++ b/src/controls/PageStack.qml
@@ -57,16 +57,7 @@ import "Private/PageStack.js" as JSArray
deeper into the application page hierarchy. Similarily, the user can return back to
previous pages at a later point, which from a stack point of view means popping pages from the
top of the stack and re-activating them (make them visible on screen).
-
- Pages can - but do not have to - use \l{Page} as the root item.
- \l{Page} defines a contract for how the page and the page stack works together.
- Namely the page can be notified when it becomes active or inactive
- through the \l{Page::status} {Page.status} property. Status will be
- \c PageStatus.Activating when a
- page is transitioning into being the current page on screen, and \c PageStatus.Active
- once the transition stops. When it leaves the screen, it will be
- \c PageStatus.Deactivating, and then \c PageStatus.Inactive. When the page is
- inactive, it will be hidden.
+ The \l Stack attached property provides information about items pushed onto a stack.
\section1 Using PageStack in an Application
Using the PageStack in the application is typically a simple matter of adding
@@ -234,17 +225,17 @@ import "Private/PageStack.js" as JSArray
Popping the page off the top of the stack at this point would not result in further
deactivation since the page is not active.
- There is a \l{Page::status}{status} property that tracks the lifecycle. The value of status is
- an enumeration with values \c PageStatus.Inactive, \c PageStatus.Activating, \c PageStatus.Active
- and \c PageStatus.Deactivating. Combined with the normal \c Component.onComplete and
+ There is an attached \l{Stack::status}{Stack.status} property that tracks the lifecycle. The value of status is
+ an enumeration with values \c Stack.Inactive, \c Stack.Activating, \c Stack.Active
+ and \c Stack.Deactivating. Combined with the normal \c Component.onComplete and
\c Component.onDestruction signals the entire lifecycle is thus:
\list
\li Created: Component.onCompleted()
- \li Activating: onStatusChanged (status is PageStatus.Activating)
- \li Acivated: onStatusChanged (status is PageStatus.Active)
- \li Deactivating: onStatusChanged (status is PageStatus.Deactivating)
- \li Deactivated: onStatusChanged (status is PageStatus.Inactive)
+ \li Activating: Stack.onStatusChanged (Stack.status is Stack.Activating)
+ \li Acivated: Stack.onStatusChanged (Stack.status is Stack.Active)
+ \li Deactivating: Stack.onStatusChanged (Stack.status is Stack.Deactivating)
+ \li Deactivated: Stack.onStatusChanged (Stack.status is Stack.Inactive)
\li Destruction: Component.onDestruction()
\endlist
@@ -372,12 +363,12 @@ import "Private/PageStack.js" as JSArray
\endqml
A single Page can also override the transition to use when itself is pushed or popped. This can
- be done by just assigning another PageTransition object to \l{Page::pageTransition}{Page.pageTransition}.
+ be done by just assigning another PageTransition object to \l{Stack::pageTransition}{Stack.pageTransition}.
\section2 Advanced usage
After PageStack finds the correct transition to use (it first checks
- \l{Page::pageTransition}{Page.pageTransition}, then \l {PageStack::pageTransition}{pageTransition})
+ \l{Stack::pageTransition}{Stack.pageTransition}, then \l {PageStack::pageTransition}{pageTransition})
it calls \l {PageTransition::getAnimation(properties)}{PageTransition.getAnimation(properties)}.
The base implementation of this function just looks for a property named \c properties.name inside
itself (root), which is how it finds \c {property Component pushAnimation} in the examples above.
@@ -493,7 +484,7 @@ Item {
/*! The animations to use for page transitions.
For better understanding on how to apply custom page transitions, read \l{Transitions}.
- \sa {Page::animations}{Page.transitions} */
+ \sa {Stack::animations}{Stack.transitions} */
property PageTransition pageTransition: PageSlideTransition {}
/*! Pushes a page onto the stack. The function takes a property list as argument, which
@@ -867,11 +858,9 @@ Item {
// Mark the page as no longer part of the PageStack. It
// might reenter on pop if pushed several times:
page.visible = false
- __setPageStatus(page, PageStatus.Inactive)
- if (page.hasOwnProperty("__pageStack"))
- page.__pageStack = null
- if (page.hasOwnProperty("__index"))
- page.__index = -1
+ __setPageStatus(page, Stack.Inactive)
+ page.Stack.__pageStack = null
+ page.Stack.__index = -1
if (element.originalParent)
page.parent = element.originalParent
}
@@ -879,8 +868,7 @@ Item {
/*! \internal */
function __setPageStatus(page, status) {
- if (page.hasOwnProperty("__status"))
- page.__status = status
+ page.Stack.__status = status
}
/*! \internal */
@@ -888,7 +876,7 @@ Item {
{
// Animate page in "outElement" out, and page in "inElement" in. Set a guard to protect
// the user from pushing new pages on signals that will fire while preparing for the transition
- // (e.g Page.onCompleted, Page.onStatusChanged, Page.onIndexChanged etc). Otherwise, we will enter
+ // (e.g Stack.onCompleted, Stack.onStatusChanged, Stack.onIndexChanged etc). Otherwise, we will enter
// this function several times, which causes the pages to be half-way updated.
if (__currentTransition)
__currentTransition.animation.complete()
@@ -900,17 +888,15 @@ Item {
// Since a page can be pushed several times, we need to update its properties:
enterPage.parent = root
- if (enterPage.hasOwnProperty("__pageStack"))
- enterPage.__pageStack = root
- if (enterPage.hasOwnProperty("__index"))
- enterPage.__index = transition.inElement.index
+ enterPage.Stack.__pageStack = root
+ enterPage.Stack.__index = transition.inElement.index
__currentPage = enterPage
if (!transition.outElement) {
// A transition consists of two pages, but we got just one. So just show the page:
enterPage.visible = true
- __setPageStatus(enterPage, PageStatus.Activating)
- __setPageStatus(enterPage, PageStatus.Active)
+ __setPageStatus(enterPage, Stack.Activating)
+ __setPageStatus(enterPage, Stack.Active)
return
}
@@ -919,9 +905,9 @@ Item {
if (enterPage === exitPage)
return
- __searchForAnimationIn(transition.transitionElement.page, transition)
+ __searchForAnimationIn(transition.transitionElement.page.Stack.pageTransition, transition)
if (!transition.animation)
- __searchForAnimationIn(root, transition)
+ __searchForAnimationIn(root.pageTransition, transition)
if (!transition.animation) {
console.warn("Warning: PageStack: no", transition.name, "found!")
return
@@ -931,9 +917,9 @@ Item {
console.warn("Warning: PageStack: cannot transition a page that is anchored!")
__currentTransition = transition
- __setPageStatus(exitPage, PageStatus.Deactivating)
+ __setPageStatus(exitPage, Stack.Deactivating)
enterPage.visible = true
- __setPageStatus(enterPage, PageStatus.Activating)
+ __setPageStatus(enterPage, Stack.Activating)
transition.animation.runningChanged.connect(animationFinished)
transition.animation.start()
// NB! For empty animations, "animationFinished" is already
@@ -945,15 +931,14 @@ Item {
/*! \internal */
function __searchForAnimationIn(obj, transition)
{
- var t = obj.pageTransition
- if (t) {
- transition.pageTransition = t
+ if (obj) {
+ transition.pageTransition = obj
transition.properties = {
"name":transition.name,
"enterPage":transition.enterPage,
"exitPage":transition.exitPage,
"immediate":transition.immediate }
- var anim = t.getAnimation(transition.properties)
+ var anim = obj.getAnimation(transition.properties)
if (anim.createObject) {
anim = anim.createObject(null, transition.properties)
anim.runningChanged.connect(function(){ if (anim.running === false) anim.destroy() })
@@ -970,8 +955,8 @@ Item {
__currentTransition.animation.runningChanged.disconnect(animationFinished)
__currentTransition.exitPage.visible = false
- __setPageStatus(__currentTransition.exitPage, PageStatus.Inactive);
- __setPageStatus(__currentTransition.enterPage, PageStatus.Active);
+ __setPageStatus(__currentTransition.exitPage, Stack.Inactive);
+ __setPageStatus(__currentTransition.enterPage, Stack.Active);
__currentTransition.properties.animation = __currentTransition.animation
__currentTransition.pageTransition.cleanupAnimation(__currentTransition.properties)
diff --git a/src/controls/controls.pro b/src/controls/controls.pro
index df9f120f3..51716652b 100644
--- a/src/controls/controls.pro
+++ b/src/controls/controls.pro
@@ -14,7 +14,6 @@ QML_FILES = \
Label.qml \
MenuBar.qml \
Menu.qml \
- Page.qml \
PageAnimation.qml \
PageStack.qml \
PageTransition.qml \
diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp
index 20d2f394f..b7dd36cd3 100644
--- a/src/controls/plugin.cpp
+++ b/src/controls/plugin.cpp
@@ -44,7 +44,7 @@
#include "qtexclusivegroup_p.h"
#include "qtmenu_p.h"
#include "qtmenubar_p.h"
-#include "qpagestatus.h"
+#include "qtstack_p.h"
#include <qimage.h>
#include <qqml.h>
@@ -86,7 +86,7 @@ void StylePlugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<QtMenuBase>(uri, 1, 0, "MenuBase",
QLatin1String("Do not create objects of type MenuBase"));
- qmlRegisterUncreatableType<QPageStatus>(uri, 1, 0, "PageStatus", QLatin1String("Do not create objects of type PageStatus"));
+ qmlRegisterUncreatableType<QtStack>(uri, 1, 0, "Stack", QLatin1String("Do not create objects of type Stack"));
}
void StylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
diff --git a/src/controls/plugin.pri b/src/controls/plugin.pri
index 61bda5da6..82f42ea35 100644
--- a/src/controls/plugin.pri
+++ b/src/controls/plugin.pri
@@ -7,7 +7,7 @@ HEADERS += \
$$PWD/qtmenuitem_p.h \
$$PWD/qtmenuitemcontainer_p.h \
$$PWD/qtmenupopupwindow_p.h \
- $$PWD/qpagestatus.h
+ $$PWD/qtstack_p.h
SOURCES += \
$$PWD/plugin.cpp \
@@ -16,7 +16,8 @@ SOURCES += \
$$PWD/qtmenu.cpp \
$$PWD/qtmenubar.cpp \
$$PWD/qtmenuitem.cpp \
- $$PWD/qtmenupopupwindow.cpp
+ $$PWD/qtmenupopupwindow.cpp \
+ $$PWD/qtstack.cpp
OTHER_FILES += \
$$PWD/plugin.json
diff --git a/src/controls/qmldir b/src/controls/qmldir
index 377b55ee1..be9fff4f0 100644
--- a/src/controls/qmldir
+++ b/src/controls/qmldir
@@ -8,7 +8,6 @@ GroupBox 1.0 GroupBox.qml
Label 1.0 Label.qml
MenuBar 1.0 MenuBar.qml
Menu 1.0 Menu.qml
-Page 1.0 Page.qml
PageAnimation 1.0 PageAnimation.qml
PageStack 1.0 PageStack.qml
PageTransition 1.0 PageTransition.qml
diff --git a/src/controls/qtstack.cpp b/src/controls/qtstack.cpp
new file mode 100644
index 000000000..09f2c534d
--- /dev/null
+++ b/src/controls/qtstack.cpp
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtstack_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Stack
+ \instantiates QtStack
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup views
+ \brief Provides attached properties for items pushed onto a PageStack.
+
+ The Stack attached property provides information when an item becomes
+ active or inactive through the \l{Stack::status}{Stack.status} property.
+ Status will be \c Stack.Activating when an item is transitioning into
+ being the current item on the screen, and \c Stack.Active once the
+ transition stops. When it leaves the screen, it will be
+ \c Stack.Deactivating, and then \c Stack.Inactive.
+
+ \sa PageStack
+*/
+
+QtStack::QtStack(QObject *object)
+ : QObject(object),
+ m_index(-1),
+ m_status(Inactive),
+ m_pageStack(0),
+ m_pageTransition(0)
+{
+}
+
+QtStack *QtStack::qmlAttachedProperties(QObject *object)
+{
+ return new QtStack(object);
+}
+
+/*!
+ \readonly
+ \qmlproperty int Stack::index
+
+ This property holds the index of the item inside \l{pageStack}{PageStack},
+ so that \l{PageStack::get()}{pageStack.get(index)} will return the item itself.
+ If \l{Stack::pageStack}{pageStack} is \c null, \a index will be \c -1.
+*/
+int QtStack::index() const
+{
+ return m_index;
+}
+
+void QtStack::setIndex(int index)
+{
+ if (m_index != index) {
+ m_index = index;
+ emit indexChanged();
+ }
+}
+
+/*!
+ \readonly
+ \qmlproperty enumeration Stack::status
+
+ This property holds the status of the item. It can have one of the following values:
+ \list
+ \li \c Stack.Inactive: the item is not visible
+ \li \c Stack.Activating: the item is transitioning into becoming an active item on the stack
+ \li \c Stack.Active: the item is on top of the stack
+ \li \c Stack.Deactivating: the item is transitioning into becoming inactive
+ \endlist
+*/
+QtStack::Status QtStack::status() const
+{
+ return m_status;
+}
+
+void QtStack::setStatus(Status status)
+{
+ if (m_status != status) {
+ m_status = status;
+ emit statusChanged();
+ }
+}
+
+/*!
+ \readonly
+ \qmlproperty PageStack Stack::pageStack
+
+ This property holds the PageStack the item is in. If the item is not inside
+ a PageStack, \a pageStack will be \c null.
+*/
+QQuickItem *QtStack::pageStack() const
+{
+ return m_pageStack;
+}
+
+void QtStack::setPageStack(QQuickItem *pageStack)
+{
+ if (m_pageStack != pageStack) {
+ m_pageStack = pageStack;
+ emit pageStackChanged();
+ }
+}
+
+/*!
+ \qmlproperty PageTransition Stack::pageTransition
+
+ This property can be set to override the default animations used
+ during a page transition. To better understand how to use this
+ property, refer to the \l{PageStack#Transitions}{transition documentation} in PageStack.
+ \sa {PageStack::animations}{PageStack.animations}
+*/
+QObject *QtStack::pageTransition() const
+{
+ return m_pageTransition;
+}
+
+void QtStack::setPageTransition(QObject* pageTransition)
+{
+ if (m_pageTransition != pageTransition) {
+ m_pageTransition = pageTransition;
+ emit pageTransitionChanged();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qpagestatus.h b/src/controls/qtstack_p.h
index b4c0db8fc..aa22bf8c7 100644
--- a/src/controls/qpagestatus.h
+++ b/src/controls/qtstack_p.h
@@ -39,27 +39,65 @@
**
****************************************************************************/
-#ifndef QPAGESTATUS_H
-#define QPAGESTATUS_H
+#ifndef QTSTACK_P_H
+#define QTSTACK_P_H
-#include <QtCore/qobject.h>
+#include <QtQuick/qquickitem.h>
QT_BEGIN_NAMESPACE
-class QPageStatus : public QObject
+class QtStack : public QObject
{
Q_OBJECT
- Q_ENUMS(PageStatus)
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
+ Q_PROPERTY(int __index READ index WRITE setIndex NOTIFY indexChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(Status __status READ status WRITE setStatus NOTIFY statusChanged)
+ Q_PROPERTY(QQuickItem* pageStack READ pageStack NOTIFY pageStackChanged)
+ Q_PROPERTY(QQuickItem* __pageStack READ pageStack WRITE setPageStack NOTIFY pageStackChanged)
+ Q_PROPERTY(QObject* pageTransition READ pageTransition WRITE setPageTransition NOTIFY pageTransitionChanged)
+ Q_ENUMS(Status)
public:
- enum PageStatus {
+ QtStack(QObject *object = 0);
+
+ static QtStack *qmlAttachedProperties(QObject *object);
+
+ int index() const;
+ void setIndex(int index);
+
+ enum Status {
Inactive = 0,
Deactivating = 1,
Activating = 2,
Active = 3
};
+
+ Status status() const;
+ void setStatus(Status status);
+
+ QQuickItem *pageStack() const;
+ void setPageStack(QQuickItem *pageStack);
+
+ QObject *pageTransition() const;
+ void setPageTransition(QObject* pageTransition);
+
+signals:
+ void statusChanged();
+ void pageStackChanged();
+ void indexChanged();
+ void pageTransitionChanged();
+
+private:
+ int m_index;
+ Status m_status;
+ QQuickItem *m_pageStack;
+ QObject *m_pageTransition;
};
QT_END_NAMESPACE
-#endif // QPAGESTATUS_H
+QML_DECLARE_TYPE(QtStack)
+QML_DECLARE_TYPEINFO(QtStack, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QTSTACK_P_H
diff --git a/tests/auto/controls/data/tst_pagestack.qml b/tests/auto/controls/data/tst_pagestack.qml
index e5c56dbdb..f03235718 100644
--- a/tests/auto/controls/data/tst_pagestack.qml
+++ b/tests/auto/controls/data/tst_pagestack.qml
@@ -52,7 +52,7 @@ TestCase {
Item { id: anItem }
Component {
id: pageComponent
- Page {}
+ Item {}
}
Component {
diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_stack.qml
index acb0f627b..f51251e9f 100644
--- a/tests/auto/controls/data/tst_page.qml
+++ b/tests/auto/controls/data/tst_stack.qml
@@ -43,14 +43,23 @@ import QtTest 1.0
TestCase {
id: testCase
- name: "Tests_Page"
+ name: "Tests_Stack"
when:windowShown
width:400
height:400
- function test_createPage() {
- var page = Qt.createQmlObject('import QtQuick.Controls 1.0; Page {}', testCase, '');
+ function test_index() {
+ var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property int index: Stack.index }', testCase, '');
+ compare(item.index, -1);
}
+ function test_status() {
+ var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property int status: Stack.status }', testCase, '');
+ compare(item.status, 0); // Stack.Inactive
+ }
+ function test_pageStack() {
+ var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property PageStack pageStack: Stack.pageStack }', testCase, '');
+ compare(item.pageStack, null);
+ }
}
diff --git a/tests/manual/PageStack.qml b/tests/manual/PageStack.qml
index 0b3713af3..e84b67876 100644
--- a/tests/manual/PageStack.qml
+++ b/tests/manual/PageStack.qml
@@ -133,23 +133,25 @@ Window {
Component {
id: pageComponent
- Page {
+ Item {
id: page
- Component.onDestruction: console.log("destroyed component page: " + index)
+ width: parent.width
+ height: parent.height
+ Component.onDestruction: console.log("destroyed component page: " + Stack.index)
property bool pushFromOnCompleted: false
Component.onCompleted: if (pushFromOnCompleted) pageStack.push(pageComponent)
//pageTransition: rotateTransition
Rectangle {
anchors.fill: parent
- color: index % 2 ? "green" : "yellow"
+ color: page.Stack.index % 2 ? "green" : "yellow"
Column {
Text {
- text: "This is component page: " + page.index
+ text: "This is component page: " + page.Stack.index
}
Text {
- text: "Current status: " + page.status
+ text: "Current status: " + page.Stack.status
}
Text { text:" " }
Button {
@@ -194,11 +196,11 @@ Window {
}
Button {
text: "Search for page 3, and pop down to it"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (page.Stack.index === 3) return true }))
}
Button {
text: "Search for page 3, and pop down to it (dontLoad == true)"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }, true))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (page.Stack.index === 3) return true }, true))
}
Button {
text: "Clear"
@@ -229,22 +231,25 @@ Window {
}
}
- Page {
+ Item {
id: pageInline
- Component.onDestruction: console.log("destroyed inline page: " + index)
+ visible: false
+ width: parent.width
+ height: parent.height
+ Component.onDestruction: console.log("destroyed inline page: " + Stack.index)
- pageTransition: rotateTransition
+ Stack.pageTransition: rotateTransition
Rectangle {
anchors.fill: parent
- color: pageInline.index % 2 ? "green" : "yellow"
+ color: pageInline.Stack.index % 2 ? "green" : "yellow"
Column {
Text {
- text: "This is inline page: " + pageInline.index
+ text: "This is inline page: " + pageInline.Stack.index
}
Text {
- text: "Current status: " + pageInline.status
+ text: "Current status: " + pageInline.Stack.status
}
Button {
text: "Push component page"
@@ -280,11 +285,11 @@ Window {
}
Button {
text: "Search for page 3, and pop down to it"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (pageInline.Stack.index === 3) return true }))
}
Button {
text: "Search for page 3, and pop down to it (dontLoad == true)"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }, true))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (pageInline.Stack.index === 3) return true }, true))
}
Button {
text: "Clear"