diff options
author | axis <qt-info@nokia.com> | 2009-09-22 11:48:38 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-09-23 14:06:36 (GMT) |
commit | 77166549a95056a9e0ac78a1e2248c78406630a4 (patch) | |
tree | c8bf18cd8bac9c0dcd8a686f902a728487e78c81 /src/gui/kernel | |
parent | 4a157ee126fc482cd1954b80f22f790ec544e241 (diff) | |
download | Qt-77166549a95056a9e0ac78a1e2248c78406630a4.zip Qt-77166549a95056a9e0ac78a1e2248c78406630a4.tar.gz Qt-77166549a95056a9e0ac78a1e2248c78406630a4.tar.bz2 |
Added support for using custom application objects on S60.
With this patch, the application developer can use his own
CEikApplication, CEikDocument and CEikAppUi classes with Qt, by
deriving from QS60MainApplication, QSMainDocument and QS60MainAppUi,
respectively. He can then register a factory function in the
QApplication constructor to have his own objects created during the
framework initialization.
This patch also fixes some Qt code style issues.
RevBy: Jason Barron
RevBy: mread
RevBy: Sami Merila
RevBy: Shane Kearns
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qapplication.h | 14 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 41 | ||||
-rw-r--r-- | src/gui/kernel/qt_s60_p.h | 2 |
3 files changed, 56 insertions, 1 deletions
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 0562251..5f21a56 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -64,6 +64,9 @@ QT_BEGIN_HEADER #if defined(Q_OS_SYMBIAN) class TWsEvent; #endif +#if defined(Q_WS_S60) +class CApaApplication; +#endif QT_BEGIN_NAMESPACE @@ -114,6 +117,11 @@ class Q_GUI_EXPORT QApplication : public QCoreApplication public: enum Type { Tty, GuiClient, GuiServer }; + +#ifdef Q_WS_S60 + typedef CApaApplication * (*QS60MainApplicationFactory)(); +#endif + #ifndef qdoc QApplication(int &argc, char **argv, int = QT_VERSION); QApplication(int &argc, char **argv, bool GUIenabled, int = QT_VERSION); @@ -122,6 +130,9 @@ public: QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = QT_VERSION); QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION); #endif +#if defined(Q_WS_S60) + QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION); +#endif #endif virtual ~QApplication(); @@ -357,6 +368,9 @@ public: QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); #endif +#if defined(Q_WS_S60) || defined(qdoc) + QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv); +#endif #endif private: diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index a5d07fd..4ca9459 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -817,11 +817,50 @@ TTypeUid::Ptr QSymbianControl::MopSupplyObject(TTypeUid id) return CCoeControl::MopSupplyObject(id); } +/*! + \typedef QApplication::QS60MainApplicationFactory + + This is a typedef for a pointer to a function with the following + signature: + + \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 47 + + \sa QApplication::QApplication(QApplication::QS60MainApplicationFactory, int &, char **) +*/ + +/*! + \since 4.6 + + Creates an application using the application factory given in + \a factory, and using \a argc command line arguments in \a argv. + \a factory can be leaving, but the error will be converted to a + standard exception. + + This function is only available on S60. +*/ +QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) +{ + Q_D(QApplication); + S60->s60ApplicationFactory = factory; + d->construct(); +} + +QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int _internal) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) +{ + Q_D(QApplication); + S60->s60ApplicationFactory = factory; + d->construct(); + QApplicationPrivate::app_compile_version = _internal; +} + void qt_init(QApplicationPrivate * /* priv */, int) { if (!CCoeEnv::Static()) { // The S60 framework has not been initalized. We need to do it. - TApaApplicationFactory factory(NewApplication); + TApaApplicationFactory factory(S60->s60ApplicationFactory ? + S60->s60ApplicationFactory : newS60Application); CApaCommandLine* commandLine = 0; TInt err = CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine); // After this construction, CEikonEnv will be available from CEikonEnv::Static(). diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index aa39f9d..9734d26 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -61,6 +61,7 @@ #include "QtGui/qimage.h" #include "QtGui/qevent.h" #include "qpointer.h" +#include "qapplication.h" #include <w32std.h> #include <coecntrl.h> #include <eikenv.h> @@ -107,6 +108,7 @@ public: int mouseInteractionEnabled : 1; int virtualMouseRequired : 1; int qtOwnsS60Environment : 1; + QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type static inline void updateScreenSize(); static inline RWsSession& wsSession(); static inline RWindowGroup& windowGroup(); |