diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsviewmanager.cpp --- a/logsui/logsapp/src/logsviewmanager.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsviewmanager.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -56,19 +56,18 @@ this, SLOT(handleOrientationChanged()) ); mComponentsRepository = new LogsComponentRepository(*this); - initViews(); - connect( &mService, SIGNAL( activateView(LogsServices::LogsView, bool) ), - this, SLOT( changeRecentView(LogsServices::LogsView, bool) ) ); + connect( &mService, SIGNAL( activateView(LogsServices::LogsView, bool, QString) ), + this, SLOT( changeRecentViewViaService(LogsServices::LogsView, bool, QString) ) ); connect( &mService, SIGNAL( activateView(QString) ), - this, SLOT( changeMatchesView(QString) )); + this, SLOT( changeMatchesViewViaService(QString) )); - connect( &mServiceOld, SIGNAL( activateView(LogsServices::LogsView, bool) ), - this, SLOT( changeRecentView(LogsServices::LogsView, bool) ) ); + connect( &mServiceOld, SIGNAL( activateView(LogsServices::LogsView, bool, QString) ), + this, SLOT( changeRecentViewViaService(LogsServices::LogsView, bool, QString) ) ); connect( &mServiceOld, SIGNAL( activateView(QString) ), - this, SLOT( changeMatchesView(QString) )); + this, SLOT( changeMatchesViewViaService(QString) )); QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); @@ -92,55 +91,40 @@ } // ----------------------------------------------------------------------------- -// LogsViewManager::initViews +// LogsViewManager::changeRecentViewViaService // ----------------------------------------------------------------------------- // -void LogsViewManager::initViews() +void LogsViewManager::changeRecentViewViaService( + LogsServices::LogsView view, bool showDialpad, QString dialpadText) { - LOGS_QDEBUG( "logs [UI] -> LogsViewManager::initViews()" ); - - // Don't activate any view, app focus gaining or service request - // will cause view activation - // - LogsRecentCallsView* view = mComponentsRepository->recentCallsView(); - Q_ASSERT_X(view != 0, "logs [UI] ", "recentCallsView not found!"); - LOGS_QDEBUG( "logs [UI] adding view" ); - mViewStack.append(view); - mMainWindow.addView(view); - - LogsDetailsView* detailsView = mComponentsRepository->detailsView(); - mViewStack.append(detailsView); - mMainWindow.addView(detailsView); - - LogsMatchesView* matchesView = mComponentsRepository->matchesView(); - mViewStack.append(matchesView); - mMainWindow.addView(matchesView); + mComponentsRepository->dialpad()->editor().setText(dialpadText); + changeRecentView(view, showDialpad); +} - LOGS_QDEBUG( "logs [UI] <- LogsViewManager::initViews()" ); +// ----------------------------------------------------------------------------- +// LogsViewManager::changeMatchesViewViaService +// ----------------------------------------------------------------------------- +// +void LogsViewManager::changeMatchesViewViaService(QString dialpadText) +{ + LOGS_QDEBUG( "logs [UI] -> LogsViewManager::changeMatchesView()" ); + mComponentsRepository->dialpad()->editor().setText(dialpadText); + doActivateView(LogsMatchesViewId, true, QVariant()); + LOGS_QDEBUG( "logs [UI] <- LogsViewManager::changeMatchesView()" ); } // ----------------------------------------------------------------------------- // LogsViewManager::changeRecentView // ----------------------------------------------------------------------------- // -void LogsViewManager::changeRecentView(LogsServices::LogsView view, bool showDialpad) +void LogsViewManager::changeRecentView( + LogsServices::LogsView view, bool showDialpad) { QVariant args(view); doActivateView(LogsRecentViewId, showDialpad, args); } // ----------------------------------------------------------------------------- -// LogsViewManager::changeMatchesView -// ----------------------------------------------------------------------------- -// -void LogsViewManager::changeMatchesView(QString dialpadText) -{ - LOGS_QDEBUG( "logs [UI] -> LogsViewManager::changeMatchesView()" ); - doActivateView(LogsMatchesViewId, true, QVariant(), dialpadText); - LOGS_QDEBUG( "logs [UI] <- LogsViewManager::changeMatchesView()" ); -} - -// ----------------------------------------------------------------------------- // LogsViewManager::proceedExit // ----------------------------------------------------------------------------- // @@ -148,11 +132,6 @@ { LOGS_QDEBUG( "logs [UI] -> LogsViewManager::proceedExit()" ); - // Instead of compressing data, exit the application for real because - // of bug in wk16 platform which prevents bg/fg switching of the app. - // - - //mComponentsRepository->model()->compressData(); qApp->quit(); LOGS_QDEBUG( "logs [UI] <- LogsViewManager::proceedExit()" ); @@ -225,10 +204,9 @@ // bool LogsViewManager::activatePreviousView() { - if ( mViewStack.count() < 2 ){ - return false; - } - return doActivateView(mViewStack.at(1)->viewId(), false, QVariant()); + LogsAppViewId viewId = ( mViewStack.count() > 1 ) ? + mViewStack.at(1)->viewId() : LogsRecentViewId; + return doActivateView(viewId, false, QVariant()); } // ----------------------------------------------------------------------------- @@ -255,6 +233,10 @@ } } + if ( !newView ){ + newView = createView(viewId); + } + if ( oldView && newView && oldView != newView ){ oldView->deactivated(); disconnect( &mMainWindow, SIGNAL( callKeyPressed() ), oldView, 0 ); @@ -263,6 +245,9 @@ if ( newView ){ mViewStack.insert(0, newView); mMainWindow.setCurrentView(newView); + //Setting mainwindow interactive to enable user input during + //view switching animation. + mMainWindow.setInteractive(true); mViewActivationArgs = args; mViewActivationShowDialpad = showDialpad; completeViewActivation(); @@ -326,12 +311,23 @@ } QVariantHash metaData; - metaData.insert("screenshot", QPixmap::grabWidget(&mMainWindow, mMainWindow.rect())); + + LOGS_QDEBUG( "logs [UI] Start taking screenshot" ); + QImage* img = new QImage(mMainWindow.rect().size(), QImage::Format_ARGB32_Premultiplied); + QPainter p( img ); + // Use render instead of QPixmap::grabWidget as otherwise screenshot + // may become empty. + mMainWindow.render( &p, mMainWindow.rect(), mMainWindow.rect() ); + metaData.insert("screenshot", QPixmap::fromImage(*img)); + delete img; + LOGS_QDEBUG( "logs [UI] End taking screenshot" ); QByteArray serializedActivity; QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); metaData.insert( + logsActivityParamInternalViewId, mViewStack.at(0)->viewId() ); + metaData.insert( logsActivityParamShowDialpad, mComponentsRepository->dialpad()->isOpen() ); metaData.insert( logsActivityParamDialpadText, mComponentsRepository->dialpad()->editor().text() ); @@ -368,6 +364,16 @@ } } + QList allParams = hbApp->activityManager()->activities(); + QVariantHash params = allParams.isEmpty() ? QVariantHash() : allParams.at(0); + LOGS_QDEBUG_2( "logs [UI] Activity params", params ); + + if ( !matchingView ){ + // Try if creating such view is possible + int viewId = params.value(logsActivityParamInternalViewId).toInt(); + matchingView = createView(static_cast(viewId)); + } + if ( matchingView ){ // Should have only one param hash in the list, use first always QList allParams = hbApp->activityManager()->activities(); @@ -394,8 +400,7 @@ LogsAppViewId viewId, const QString& dialpadText) { if ( !dialpadText.isEmpty() ){ - Dialpad* dialpad = mComponentsRepository->dialpad(); - dialpad->editor().setText(dialpadText); + mComponentsRepository->dialpad()->editor().setText(dialpadText); } if ( viewId == LogsMatchesViewId ){ @@ -435,3 +440,23 @@ } LOGS_QDEBUG( "logs [UI] <- LogsViewManager::handleFirstActivation()" ); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +LogsBaseView* LogsViewManager::createView(LogsAppViewId viewId) +{ + LogsBaseView* newView = 0; + if ( viewId == LogsRecentViewId ){ + newView = mComponentsRepository->recentCallsView(); + mMainWindow.addView(newView); + } else if ( viewId == LogsMatchesViewId ) { + newView = mComponentsRepository->matchesView(); + mMainWindow.addView(newView); + } else if ( viewId == LogsDetailsViewId ) { + newView = mComponentsRepository->detailsView(); + mMainWindow.addView(newView); + } + return newView; +}