From 89e1cba2f671c1c46f81dcd36a168f469315c8ee Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 21 Nov 2011 11:38:26 +0100 Subject: Move QDeclarativeApplication from util/ to qml/ QDeclarativeEngine/QV8Engine depend on QDeclarativeApplication, so this class should reside under qml/, not util/. Change-Id: I2cd49ba1170bfb610a7607525891cb80c8828f27 Reviewed-by: Roberto Raggi --- src/declarative/qml/qdeclarativeapplication.cpp | 118 +++++++++++++++++++++++ src/declarative/qml/qdeclarativeapplication_p.h | 88 +++++++++++++++++ src/declarative/qml/qdeclarativeengine.cpp | 1 + src/declarative/qml/qml.pri | 2 + src/declarative/util/qdeclarativeapplication.cpp | 118 ----------------------- src/declarative/util/qdeclarativeapplication_p.h | 88 ----------------- src/declarative/util/qdeclarativeutilmodule.cpp | 2 - src/declarative/util/util.pri | 2 - 8 files changed, 209 insertions(+), 210 deletions(-) create mode 100644 src/declarative/qml/qdeclarativeapplication.cpp create mode 100644 src/declarative/qml/qdeclarativeapplication_p.h delete mode 100644 src/declarative/util/qdeclarativeapplication.cpp delete mode 100644 src/declarative/util/qdeclarativeapplication_p.h diff --git a/src/declarative/qml/qdeclarativeapplication.cpp b/src/declarative/qml/qdeclarativeapplication.cpp new file mode 100644 index 0000000000..765f8dd2cd --- /dev/null +++ b/src/declarative/qml/qdeclarativeapplication.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** 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 QtDeclarative 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 "qdeclarativeapplication_p.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeApplicationPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarativeApplication) +public: + QDeclarativeApplicationPrivate() : active(QGuiApplication::activeWindow() != 0), + layoutDirection(QGuiApplication::layoutDirection()) {} + bool active; + Qt::LayoutDirection layoutDirection; +}; + +/* + This object and its properties are documented as part of the Qt object, + in qdeclarativengine.cpp +*/ + +QDeclarativeApplication::QDeclarativeApplication(QObject *parent) : QObject(*new QDeclarativeApplicationPrivate(), parent) +{ + if (qApp) + qApp->installEventFilter(this); +} + +QDeclarativeApplication::~QDeclarativeApplication() +{ +} + +bool QDeclarativeApplication::active() const +{ + Q_D(const QDeclarativeApplication); + return d->active; +} + +Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const +{ + Q_D(const QDeclarativeApplication); + return d->layoutDirection; +} + +QObject *QDeclarativeApplication::inputPanel() const +{ + return qApp ? qApp->inputPanel() : 0; +} + +bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event) +{ + Q_UNUSED(obj) + Q_D(QDeclarativeApplication); + if (event->type() == QEvent::ApplicationActivate + || event->type() == QEvent::ApplicationDeactivate) { + bool active = d->active; + if (event->type() == QEvent::ApplicationActivate) + active = true; + else if (event->type() == QEvent::ApplicationDeactivate) + active = false; + + if (d->active != active) { + d->active = active; + emit activeChanged(); + } + } + if (event->type() == QEvent::LayoutDirectionChange) { + Qt::LayoutDirection direction = QGuiApplication::layoutDirection(); + if (d->layoutDirection != direction) { + d->layoutDirection = direction; + emit layoutDirectionChanged(); + } + } + return false; +} + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeapplication_p.h b/src/declarative/qml/qdeclarativeapplication_p.h new file mode 100644 index 0000000000..aa51085f01 --- /dev/null +++ b/src/declarative/qml/qdeclarativeapplication_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 QtDeclarative 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 QDECLARATIVEAPPLICATION_P_H +#define QDECLARATIVEAPPLICATION_P_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeApplicationPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeApplication : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool active READ active NOTIFY activeChanged) + Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged) + Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT) + +public: + explicit QDeclarativeApplication(QObject *parent = 0); + virtual ~QDeclarativeApplication(); + bool active() const; + Qt::LayoutDirection layoutDirection() const; + QObject *inputPanel() const; + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +Q_SIGNALS: + void activeChanged(); + void layoutDirectionChanged(); + +private: + Q_DISABLE_COPY(QDeclarativeApplication) + Q_DECLARE_PRIVATE(QDeclarativeApplication) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarativeApplication) + +QT_END_HEADER + +#endif // QDECLARATIVEAPPLICATION_P_H diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ef638b4e44..05db2e8e21 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -175,6 +175,7 @@ void QDeclarativeEnginePrivate::defineModule() { registerBaseTypes("QtQuick", 2, 0); qmlRegisterType(); + qmlRegisterUncreatableType("QtQuick",2,0,"Application", QDeclarativeApplication::tr("Application is an abstract class")); qmlRegisterUncreatableType("QtQuick",2,0,"Locale",QDeclarativeEngine::tr("Locale cannot be instantiated. Use Qt.locale()")); } diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index a920d62a2a..444183eeab 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -1,4 +1,5 @@ SOURCES += \ + $$PWD/qdeclarativeapplication.cpp \ $$PWD/qdeclarativeinstruction.cpp \ $$PWD/qdeclarativevmemetaobject.cpp \ $$PWD/qdeclarativeengine.cpp \ @@ -50,6 +51,7 @@ HEADERS += \ $$PWD/qdeclarativeinstruction_p.h \ $$PWD/qdeclarativevmemetaobject_p.h \ $$PWD/qdeclarative.h \ + $$PWD/qdeclarativeapplication_p.h \ $$PWD/qdeclarativebinding_p.h \ $$PWD/qdeclarativebinding_p_p.h \ $$PWD/qdeclarativeproperty.h \ diff --git a/src/declarative/util/qdeclarativeapplication.cpp b/src/declarative/util/qdeclarativeapplication.cpp deleted file mode 100644 index 765f8dd2cd..0000000000 --- a/src/declarative/util/qdeclarativeapplication.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** 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 QtDeclarative 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 "qdeclarativeapplication_p.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeApplicationPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeApplication) -public: - QDeclarativeApplicationPrivate() : active(QGuiApplication::activeWindow() != 0), - layoutDirection(QGuiApplication::layoutDirection()) {} - bool active; - Qt::LayoutDirection layoutDirection; -}; - -/* - This object and its properties are documented as part of the Qt object, - in qdeclarativengine.cpp -*/ - -QDeclarativeApplication::QDeclarativeApplication(QObject *parent) : QObject(*new QDeclarativeApplicationPrivate(), parent) -{ - if (qApp) - qApp->installEventFilter(this); -} - -QDeclarativeApplication::~QDeclarativeApplication() -{ -} - -bool QDeclarativeApplication::active() const -{ - Q_D(const QDeclarativeApplication); - return d->active; -} - -Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const -{ - Q_D(const QDeclarativeApplication); - return d->layoutDirection; -} - -QObject *QDeclarativeApplication::inputPanel() const -{ - return qApp ? qApp->inputPanel() : 0; -} - -bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event) -{ - Q_UNUSED(obj) - Q_D(QDeclarativeApplication); - if (event->type() == QEvent::ApplicationActivate - || event->type() == QEvent::ApplicationDeactivate) { - bool active = d->active; - if (event->type() == QEvent::ApplicationActivate) - active = true; - else if (event->type() == QEvent::ApplicationDeactivate) - active = false; - - if (d->active != active) { - d->active = active; - emit activeChanged(); - } - } - if (event->type() == QEvent::LayoutDirectionChange) { - Qt::LayoutDirection direction = QGuiApplication::layoutDirection(); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - } - } - return false; -} - -QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativeapplication_p.h b/src/declarative/util/qdeclarativeapplication_p.h deleted file mode 100644 index aa51085f01..0000000000 --- a/src/declarative/util/qdeclarativeapplication_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 QtDeclarative 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 QDECLARATIVEAPPLICATION_P_H -#define QDECLARATIVEAPPLICATION_P_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeApplicationPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeApplication : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool active READ active NOTIFY activeChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged) - Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT) - -public: - explicit QDeclarativeApplication(QObject *parent = 0); - virtual ~QDeclarativeApplication(); - bool active() const; - Qt::LayoutDirection layoutDirection() const; - QObject *inputPanel() const; - -protected: - bool eventFilter(QObject *obj, QEvent *event); - -Q_SIGNALS: - void activeChanged(); - void layoutDirectionChanged(); - -private: - Q_DISABLE_COPY(QDeclarativeApplication) - Q_DECLARE_PRIVATE(QDeclarativeApplication) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeApplication) - -QT_END_HEADER - -#endif // QDECLARATIVEAPPLICATION_P_H diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp index 0a8f04b0de..4df3115eaf 100644 --- a/src/declarative/util/qdeclarativeutilmodule.cpp +++ b/src/declarative/util/qdeclarativeutilmodule.cpp @@ -59,7 +59,6 @@ #include "qdeclarativesystempalette_p.h" #include "qdeclarativetimer_p.h" #include "qdeclarativetransition_p.h" -#include "qdeclarativeapplication_p.h" #include #include #ifndef QT_NO_XMLPATTERNS @@ -76,7 +75,6 @@ void QDeclarativeUtilModule::registerBaseTypes(const char *uri, int versionMajor void QDeclarativeUtilModule::defineModule() { - qmlRegisterUncreatableType("QtQuick",2,0,"Application", QDeclarativeApplication::tr("Application is an abstract class")); qmlRegisterUncreatableType("QtQuick",2,0,"InputPanel", QInputPanel::tr("InputPanel is an abstract class")); qmlRegisterUncreatableType("QtQuick",2,0,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class")); diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 1d71225bf5..a93fff7f89 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -1,5 +1,4 @@ SOURCES += \ - $$PWD/qdeclarativeapplication.cpp \ $$PWD/qdeclarativeutilmodule.cpp\ $$PWD/qdeclarativeconnections.cpp \ $$PWD/qdeclarativepackage.cpp \ @@ -33,7 +32,6 @@ SOURCES += \ $$PWD/qdeclarativesvgparser.cpp HEADERS += \ - $$PWD/qdeclarativeapplication_p.h \ $$PWD/qdeclarativeutilmodule_p.h\ $$PWD/qdeclarativeconnections_p.h \ $$PWD/qdeclarativepackage_p.h \ -- cgit v1.2.3