From 01f5c74b8ecddfc192895ccb85c1627467bb6ff5 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 08:10:14 +0000 Subject: Generating QFileOpenEvent messages when S60 UI receives OpenFileL S60 applications can receive OpenFileL requests from other apps in the OpenFileL method of their main document class. This S60 main document class is internal to QtGui, so the request is turned into a QFileOpenEvent for the application to pick up if it want to implenment this service. If an application wants to receive the QFileOpenEvent before UI construction, it should do something like: app->sendPostedEvents(app, QEvent::FileOpen); Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/s60framework/qs60mainappui.cpp | 10 ++++++++++ src/gui/s60framework/qs60mainappui.h | 1 + src/gui/s60framework/qs60maindocument.cpp | 20 +++++++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index b5b8b81..454f90d 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -49,6 +49,7 @@ #include #endif #include +#include #include #include "qs60mainappui.h" @@ -401,6 +402,15 @@ void QS60MainAppUi::HandleForegroundEventL(TBool aForeground) QS60MainAppUiBase::HandleForegroundEventL(aForeground); } +/*! + \internal +*/ +TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &aDocumentName, const TDesC8 &/*aTail*/) +{ + // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working. + return ConeUtils::FileExists(aDocumentName); +} + #ifndef Q_WS_S60 void QS60StubAknAppUi::HandleViewDeactivation(const TVwsViewId &, const TVwsViewId &) {} diff --git a/src/gui/s60framework/qs60mainappui.h b/src/gui/s60framework/qs60mainappui.h index ce3b5b0..bf118ff 100644 --- a/src/gui/s60framework/qs60mainappui.h +++ b/src/gui/s60framework/qs60mainappui.h @@ -131,6 +131,7 @@ public: virtual void HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId); virtual void PrepareToExit(); virtual void HandleTouchPaneSizeChange(); + virtual TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName &aDocumentName, const TDesC8 &aTail); protected: virtual void HandleScreenDeviceChangedL(); diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index a8886ac..071aa5b 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -41,6 +41,8 @@ #include "qs60mainappui.h" #include "qs60maindocument.h" +#include "qcoreapplication.h" +#include "qevent.h" #include @@ -108,9 +110,15 @@ CEikAppUi *QS60MainDocument::CreateAppUiL() /*! \internal */ -CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &aFs) +CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &/*aFs*/) { - return QS60MainDocumentBase::OpenFileL(aDoOpen, aFilename, aFs); + if (aDoOpen) { + QCoreApplication* app = QCoreApplication::instance(); + QString qname((QChar*)aFilename.Ptr(), aFilename.Length()); + QFileOpenEvent* event = new QFileOpenEvent(qname); + app->postEvent(app, event); + } + return 0; } /*! @@ -118,7 +126,13 @@ CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, R */ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { - QS60MainDocumentBase::OpenFileL(aFileStore, aFile); + QCoreApplication* app = QCoreApplication::instance(); + TFileName name; + aFile.FullName(name); + QString qname((QChar*)name.Ptr(), name.Length()); + QFileOpenEvent* event = new QFileOpenEvent(qname); + app->postEvent(app, event); + aFileStore = 0; } QT_END_NAMESPACE -- cgit v0.12