aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-11-18 19:32:56 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-29 03:29:53 +0100
commitba0d63fd220ff215150e827a21a42c8de3372dd4 (patch)
tree7182b6234404ce421c14338170e27d72223510e6 /src/declarative
parent6a198083e5f61fb51c5f1c5d77366edd404bc7c2 (diff)
Initial window implementation
Includes adding a color property on QQuickCanvas. Note that most Window related properties come from the QWindow inheritance. Task-number: QTBUG-19799 Change-Id: I00f6c90a1e2a5c85d787793d6edac2cd7d5309ab Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/items/items.pri6
-rw-r--r--src/declarative/items/qquickcanvas.cpp36
-rw-r--r--src/declarative/items/qquickcanvas.h8
-rw-r--r--src/declarative/items/qquickcanvas_p.h8
-rw-r--r--src/declarative/items/qquickwindowmodule.cpp55
-rw-r--r--src/declarative/items/qquickwindowmodule_p.h63
-rw-r--r--src/declarative/qtquick2.cpp2
7 files changed, 174 insertions, 4 deletions
diff --git a/src/declarative/items/items.pri b/src/declarative/items/items.pri
index f83c65c203..308706f0b9 100644
--- a/src/declarative/items/items.pri
+++ b/src/declarative/items/items.pri
@@ -66,7 +66,8 @@ HEADERS += \
$$PWD/qquickdroparea_p.h \
$$PWD/qquickmultipointtoucharea_p.h \
$$PWD/qquickitemview_p.h \
- $$PWD/qquickitemview_p_p.h
+ $$PWD/qquickitemview_p_p.h \
+ $$PWD/qquickwindowmodule_p.h
SOURCES += \
$$PWD/qquickevents.cpp \
@@ -112,7 +113,8 @@ SOURCES += \
$$PWD/qquickdrag.cpp \
$$PWD/qquickdroparea.cpp \
$$PWD/qquickmultipointtoucharea.cpp \
- $$PWD/qquickitemview.cpp
+ $$PWD/qquickitemview.cpp \
+ $$PWD/qquickwindowmodule.cpp
SOURCES += \
$$PWD/qquickshadereffect.cpp \
diff --git a/src/declarative/items/qquickcanvas.cpp b/src/declarative/items/qquickcanvas.cpp
index c6969b5cda..8022af98f4 100644
--- a/src/declarative/items/qquickcanvas.cpp
+++ b/src/declarative/items/qquickcanvas.cpp
@@ -532,6 +532,23 @@ void QQuickCanvasPrivate::init(QQuickCanvas *c)
q->setFormat(context->defaultSurfaceFormat());
}
+QDeclarativeListProperty<QObject> QQuickCanvasPrivate::data()
+{
+ initRootItem();
+ return QQuickItemPrivate::get(rootItem)->data();
+}
+
+void QQuickCanvasPrivate::initRootItem()
+{
+ Q_Q(QQuickCanvas);
+ q->connect(q, SIGNAL(widthChanged(int)),
+ rootItem, SLOT(setWidth(int)));
+ q->connect(q, SIGNAL(heightChanged(int)),
+ rootItem, SLOT(setHeight(int)));
+ rootItem->setWidth(q->width());
+ rootItem->setHeight(q->height());
+}
+
void QQuickCanvasPrivate::transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform)
{
for (int i=0; i<touchPoints.count(); i++) {
@@ -815,6 +832,14 @@ void QQuickCanvasPrivate::cleanup(QSGNode *n)
/*!
+ \qmlclass Window QQuickCanvas
+ \inqmlmodule QtQuick.Window 2
+ \brief The Window object creates a new top-level window.
+
+ The Window object creates a new top-level window for a QtQuick scene. It automatically sets up the
+ window for use with QtQuick 2.0 graphical elements.
+*/
+/*!
\class QQuickCanvas
\since QtQuick 2.0
\brief The QQuickCanvas class provides the canvas for displaying a graphical QML scene
@@ -894,6 +919,14 @@ QQuickItem *QQuickCanvas::mouseGrabberItem() const
}
+/*!
+ \qmlproperty color QtQuick2.Window::Window::color
+
+ The background color for the window.
+
+ Setting this property is more efficient than using a separate Rectangle.
+*/
+
bool QQuickCanvasPrivate::clearHover()
{
if (hoverItems.isEmpty())
@@ -2131,7 +2164,10 @@ QSGTexture *QQuickCanvas::createTextureFromId(uint id, const QSize &size, Create
void QQuickCanvas::setClearColor(const QColor &color)
{
+ if (color == d_func()->clearColor)
+ return;
d_func()->clearColor = color;
+ emit clearColorChanged(color);
}
diff --git a/src/declarative/items/qquickcanvas.h b/src/declarative/items/qquickcanvas.h
index a480439574..6f9d40da48 100644
--- a/src/declarative/items/qquickcanvas.h
+++ b/src/declarative/items/qquickcanvas.h
@@ -63,8 +63,11 @@ class QInputMethodEvent;
class Q_DECLARATIVE_EXPORT QQuickCanvas : public QWindow
{
-Q_OBJECT
-Q_DECLARE_PRIVATE(QQuickCanvas)
+ Q_OBJECT
+ Q_PRIVATE_PROPERTY(QQuickCanvas::d_func(), QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
+ Q_PROPERTY(QColor color READ clearColor WRITE setClearColor NOTIFY clearColorChanged)
+ Q_CLASSINFO("DefaultProperty", "data")
+ Q_DECLARE_PRIVATE(QQuickCanvas)
public:
enum CreateTextureOption {
TextureHasAlphaChannel = 0x0001,
@@ -114,6 +117,7 @@ Q_SIGNALS:
void sceneGraphInitialized();
void beforeRendering();
void afterRendering();
+ void clearColorChanged(const QColor &);
protected:
QQuickCanvas(QQuickCanvasPrivate &dd, QWindow *parent = 0);
diff --git a/src/declarative/items/qquickcanvas_p.h b/src/declarative/items/qquickcanvas_p.h
index fdfe0911f5..13ca288cb1 100644
--- a/src/declarative/items/qquickcanvas_p.h
+++ b/src/declarative/items/qquickcanvas_p.h
@@ -73,13 +73,18 @@
QT_BEGIN_NAMESPACE
//Make it easy to identify and customize the root item if needed
+
class QQuickRootItem : public QQuickItem
{
Q_OBJECT
public:
QQuickRootItem();
+public Q_SLOTS:
+ void setWidth(int w) {QQuickItem::setWidth(qreal(w));}
+ void setHeight(int h) {QQuickItem::setHeight(qreal(h));}
};
+class QQuickItemPrivate;
class QQuickCanvasPrivate;
class QTouchEvent;
@@ -97,8 +102,10 @@ public:
virtual ~QQuickCanvasPrivate();
void init(QQuickCanvas *);
+ void initRootItem();//Currently only used if items added in QML
QQuickRootItem *rootItem;
+ QDeclarativeListProperty<QObject> data();
QQuickItem *activeFocusItem;
QQuickItem *mouseGrabberItem;
@@ -175,6 +182,7 @@ public:
QHash<int, QQuickItem *> itemForTouchPointId;
mutable QQuickCanvasIncubationController *incubationController;
+
private:
static void cleanupNodesOnShutdown(QQuickItem *);
};
diff --git a/src/declarative/items/qquickwindowmodule.cpp b/src/declarative/items/qquickwindowmodule.cpp
new file mode 100644
index 0000000000..7a7f28cb43
--- /dev/null
+++ b/src/declarative/items/qquickwindowmodule.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickwindowmodule_p.h"
+#include <QQuickCanvas>
+
+QT_BEGIN_NAMESPACE
+
+void QQuickWindowModule::defineModule()
+{
+ const char* uri = "QtQuick.Window";
+
+ qmlRegisterType<QQuickCanvas>(uri, 2, 0, "Window");
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/items/qquickwindowmodule_p.h b/src/declarative/items/qquickwindowmodule_p.h
new file mode 100644
index 0000000000..ead15942b9
--- /dev/null
+++ b/src/declarative/items/qquickwindowmodule_p.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWINDOWMODULE_H
+#define QQUICKWINDOWMODULE_H
+
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QQuickWindowModule
+{
+public:
+ static void defineModule();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/qtquick2.cpp b/src/declarative/qtquick2.cpp
index 72e3251dd8..ff49641865 100644
--- a/src/declarative/qtquick2.cpp
+++ b/src/declarative/qtquick2.cpp
@@ -45,6 +45,7 @@
#include <private/qdeclarativevaluetype_p.h>
#include <private/qquickitemsmodule_p.h>
#include <private/qquickparticlesmodule_p.h>
+#include <private/qquickwindowmodule_p.h>
#include <private/qdeclarativeenginedebugservice_p.h>
#include <private/qdeclarativedebugstatesdelegate_p.h>
@@ -179,6 +180,7 @@ void QDeclarativeQtQuick2Module::defineModule()
QDeclarativeEnginePrivate::defineModule();
QQuickItemsModule::defineModule();
QQuickParticlesModule::defineModule();
+ QQuickWindowModule::defineModule();
QDeclarativeValueTypeFactory::registerValueTypes();
if (QDeclarativeEngineDebugService::isDebuggingEnabled()) {