28 #include "logsmainwindow.h" |
28 #include "logsmainwindow.h" |
29 |
29 |
30 //SYSTEM |
30 //SYSTEM |
31 #include <hbmainwindow.h> |
31 #include <hbmainwindow.h> |
32 #include <hbview.h> |
32 #include <hbview.h> |
33 #include <logsservices.h> |
|
34 #include <QApplication> |
33 #include <QApplication> |
35 #include <hblineedit.h> |
34 #include <hblineedit.h> |
36 #include <dialpad.h> |
35 #include <dialpad.h> |
37 #include <hbactivitymanager.h> |
36 #include <hbactivitymanager.h> |
38 #include <hbapplication.h> |
37 #include <hbapplication.h> |
52 |
51 |
53 //It is important that we always handle orientation change first, before |
52 //It is important that we always handle orientation change first, before |
54 //dialpad widget. If connection is moved to a view, then it's not guarantied. |
53 //dialpad widget. If connection is moved to a view, then it's not guarantied. |
55 connect( &mainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
54 connect( &mainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
56 this, SLOT(handleOrientationChanged()) ); |
55 this, SLOT(handleOrientationChanged()) ); |
|
56 connect( &mainWindow, SIGNAL(appGainedForeground()), this, SLOT(appGainedForeground()) ); |
57 |
57 |
58 mComponentsRepository = new LogsComponentRepository(*this); |
58 mComponentsRepository = new LogsComponentRepository(*this); |
59 |
59 |
60 connect( &mService, SIGNAL( activateView(LogsServices::LogsView, bool, QString) ), |
60 connect( &mService, SIGNAL( activateView(XQService::LogsViewIndex, bool, QString) ), |
61 this, SLOT( changeRecentViewViaService(LogsServices::LogsView, bool, QString) ) ); |
61 this, SLOT( changeRecentViewViaService(XQService::LogsViewIndex, bool, QString) ) ); |
62 |
62 |
63 connect( &mService, SIGNAL( activateView(QString) ), |
63 connect( &mService, SIGNAL( activateView(QString) ), |
64 this, SLOT( changeMatchesViewViaService(QString) )); |
64 this, SLOT( changeMatchesViewViaService(QString) )); |
65 |
65 |
66 connect( &mServiceOld, SIGNAL( activateView(LogsServices::LogsView, bool, QString) ), |
66 connect( &mServiceOld, SIGNAL( activateView(XQService::LogsViewIndex, bool, QString) ), |
67 this, SLOT( changeRecentViewViaService(LogsServices::LogsView, bool, QString) ) ); |
67 this, SLOT( changeRecentViewViaService(XQService::LogsViewIndex, bool, QString) ) ); |
68 |
68 |
69 connect( &mServiceOld, SIGNAL( activateView(QString) ), |
69 connect( &mServiceOld, SIGNAL( activateView(QString) ), |
70 this, SLOT( changeMatchesViewViaService(QString) )); |
70 this, SLOT( changeMatchesViewViaService(QString) )); |
71 |
71 |
72 QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
72 QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
93 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
94 // LogsViewManager::changeRecentViewViaService |
94 // LogsViewManager::changeRecentViewViaService |
95 // ----------------------------------------------------------------------------- |
95 // ----------------------------------------------------------------------------- |
96 // |
96 // |
97 void LogsViewManager::changeRecentViewViaService( |
97 void LogsViewManager::changeRecentViewViaService( |
98 LogsServices::LogsView view, bool showDialpad, QString dialpadText) |
98 XQService::LogsViewIndex view, bool showDialpad, QString dialpadText) |
99 { |
99 { |
100 closeEmbeddedApplication(); |
100 closeEmbeddedApplication(); |
101 mMainWindow.bringAppToForeground(); |
101 mMainWindow.bringAppToForeground(); |
102 mComponentsRepository->dialpad()->editor().setText(dialpadText); |
102 mComponentsRepository->dialpad()->editor().setText(dialpadText); |
103 changeRecentView(view, showDialpad); |
103 changeRecentView(view, showDialpad); |
120 // ----------------------------------------------------------------------------- |
120 // ----------------------------------------------------------------------------- |
121 // LogsViewManager::changeRecentView |
121 // LogsViewManager::changeRecentView |
122 // ----------------------------------------------------------------------------- |
122 // ----------------------------------------------------------------------------- |
123 // |
123 // |
124 void LogsViewManager::changeRecentView( |
124 void LogsViewManager::changeRecentView( |
125 LogsServices::LogsView view, bool showDialpad) |
125 XQService::LogsViewIndex view, bool showDialpad) |
126 { |
126 { |
127 QVariant args(view); |
127 QVariant args(view); |
128 doActivateView(LogsRecentViewId, showDialpad, args); |
128 doActivateView(LogsRecentViewId, showDialpad, args); |
129 } |
129 } |
130 |
130 |
185 |
185 |
186 bool exitAllowed( true ); |
186 bool exitAllowed( true ); |
187 foreach ( LogsBaseView* view, mViewStack ){ |
187 foreach ( LogsBaseView* view, mViewStack ){ |
188 if ( !view->isExitAllowed() ){ |
188 if ( !view->isExitAllowed() ){ |
189 exitAllowed = false; |
189 exitAllowed = false; |
190 connect( view, SIGNAL(exitAllowed()), this, SLOT(proceedExit()) ); |
190 connect( view, SIGNAL(exitAllowed()), |
|
191 this, SLOT(proceedExit()), |
|
192 Qt::UniqueConnection ); |
191 } |
193 } |
192 } |
194 } |
193 if ( exitAllowed ){ |
195 if ( exitAllowed ){ |
194 LOGS_QDEBUG( "logs [UI] Handle exit immediataly" ); |
196 LOGS_QDEBUG( "logs [UI] Handle exit immediataly" ); |
195 proceedExit(); |
197 proceedExit(); |
241 newView = createView(viewId); |
243 newView = createView(viewId); |
242 } |
244 } |
243 |
245 |
244 if ( oldView && newView && oldView != newView ){ |
246 if ( oldView && newView && oldView != newView ){ |
245 oldView->deactivated(); |
247 oldView->deactivated(); |
246 disconnect( &mMainWindow, SIGNAL( callKeyPressed() ), oldView, 0 ); |
248 disconnect( &mMainWindow, SIGNAL(callKeyPressed()), oldView, SLOT(callKeyPressed()) ); |
|
249 disconnect( &mMainWindow, SIGNAL(localeChanged()), oldView, SLOT(localeChanged()) ); |
247 } |
250 } |
248 |
251 |
249 if ( newView ){ |
252 if ( newView ){ |
250 mViewStack.insert(0, newView); |
253 mViewStack.insert(0, newView); |
251 mMainWindow.setCurrentView(newView); |
254 mMainWindow.setCurrentView(newView); |
271 { |
274 { |
272 LOGS_QDEBUG_2( "logs [UI] -> LogsViewManager::completeViewActivation(), first", |
275 LOGS_QDEBUG_2( "logs [UI] -> LogsViewManager::completeViewActivation(), first", |
273 mFirstActivation ); |
276 mFirstActivation ); |
274 if ( mFirstActivation ){ |
277 if ( mFirstActivation ){ |
275 mFirstActivation = false; |
278 mFirstActivation = false; |
276 connect( &mMainWindow, SIGNAL(viewReady()), this, SLOT(completeViewActivation()) ); |
279 connect( &mMainWindow, SIGNAL(viewReady()), |
|
280 this, SLOT(completeViewActivation()), |
|
281 Qt::UniqueConnection ); |
277 } else { |
282 } else { |
278 disconnect( &mMainWindow, SIGNAL(viewReady()), this, SLOT(completeViewActivation()) ); |
283 disconnect( &mMainWindow, SIGNAL(viewReady()), this, SLOT(completeViewActivation()) ); |
279 LogsBaseView* newView = mViewStack.at(0); |
284 LogsBaseView* newView = mViewStack.at(0); |
280 newView->activated(mViewActivationShowDialpad, mViewActivationArgs); |
285 newView->activated(mViewActivationShowDialpad, mViewActivationArgs); |
281 connect( &mMainWindow, SIGNAL( callKeyPressed() ), newView, SLOT( callKeyPressed() ) ); |
286 connect( &mMainWindow, SIGNAL(callKeyPressed()), |
|
287 newView, SLOT(callKeyPressed()), |
|
288 Qt::UniqueConnection ); |
|
289 connect( &mMainWindow, SIGNAL(localeChanged()), |
|
290 newView, SLOT(localeChanged()), |
|
291 Qt::UniqueConnection ); |
282 |
292 |
283 // First activation completed, clear counter |
293 // First activation completed, clear counter |
284 mComponentsRepository->model()->clearMissedCallsCounter(); |
294 mComponentsRepository->model()->clearMissedCallsCounter(); |
285 } |
295 } |
286 LOGS_QDEBUG( "logs [UI] <- LogsViewManager::completeViewActivation()" ); |
296 LOGS_QDEBUG( "logs [UI] <- LogsViewManager::completeViewActivation()" ); |
429 if ( useSavedActivity && loadActivity() ){ |
439 if ( useSavedActivity && loadActivity() ){ |
430 LOGS_QDEBUG( "logs [UI] loaded saved activity" ); |
440 LOGS_QDEBUG( "logs [UI] loaded saved activity" ); |
431 mMainWindow.bringAppToForeground(); |
441 mMainWindow.bringAppToForeground(); |
432 } else if ( mFirstActivation && !mService.isStartedUsingService() && |
442 } else if ( mFirstActivation && !mService.isStartedUsingService() && |
433 !mServiceOld.isStartedUsingService()) { |
443 !mServiceOld.isStartedUsingService()) { |
434 changeRecentView( LogsServices::ViewAll, false ); |
444 changeRecentView( XQService::LogsViewAll, false ); |
435 mMainWindow.bringAppToForeground(); |
445 mMainWindow.bringAppToForeground(); |
436 } |
446 } |
437 |
447 |
438 // Clear previously stored activations |
448 // Clear previously stored activations |
439 |
449 |
474 if (mViewStack.count()) { |
484 if (mViewStack.count()) { |
475 mViewStack.at(0)->cancelServiceRequest(); |
485 mViewStack.at(0)->cancelServiceRequest(); |
476 } |
486 } |
477 LOGS_QDEBUG( "logs [UI] <- LogsViewManager::closeEmbeddedApplication()" ); |
487 LOGS_QDEBUG( "logs [UI] <- LogsViewManager::closeEmbeddedApplication()" ); |
478 } |
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // If application comes back to foreground while exit is pending due unfinished |
|
492 // operations, finising of those operations does not cause anymore real exit. |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 void LogsViewManager::appGainedForeground() |
|
496 { |
|
497 LOGS_QDEBUG( "logs [UI] -> LogsViewManager::appGainedForeground()" ); |
|
498 foreach ( LogsBaseView* view, mViewStack ){ |
|
499 disconnect( view, SIGNAL(exitAllowed()), this, SLOT(proceedExit()) ); |
|
500 } |
|
501 LOGS_QDEBUG( "logs [UI] <- LogsViewManager::appGainedForeground()" ); |
|
502 } |