diff -r c5af8598d22c -r e4c884866116 logsui/logsapp/src/logsmainwindow.cpp --- a/logsui/logsapp/src/logsmainwindow.cpp Thu Sep 02 20:27:05 2010 +0300 +++ b/logsui/logsapp/src/logsmainwindow.cpp Fri Sep 17 08:29:34 2010 +0300 @@ -20,27 +20,31 @@ #include #include #include +#include // ----------------------------------------------------------------------------- -// LogsMainWindow::LogsMainWindow +// // ----------------------------------------------------------------------------- // LogsMainWindow::LogsMainWindow() : HbMainWindow(), mForeground(false), mLocaleChanged(false) { qApp->installEventFilter(this); + mKeyCapture = new XQKeyCapture; } // ----------------------------------------------------------------------------- -// LogsMainWindow::~LogsMainWindow +// // ----------------------------------------------------------------------------- // LogsMainWindow::~LogsMainWindow() { + stopKeyCapture(); + delete mKeyCapture; } // ----------------------------------------------------------------------------- -// LogsMainWindow::sendAppToBackground +// // ----------------------------------------------------------------------------- // void LogsMainWindow::sendAppToBackground() @@ -51,7 +55,7 @@ } // ----------------------------------------------------------------------------- -// LogsMainWindow::bringAppToForeground +// // ----------------------------------------------------------------------------- // void LogsMainWindow::bringAppToForeground() @@ -63,7 +67,7 @@ } // ----------------------------------------------------------------------------- -// LogsMainWindow::isForeground +// // ----------------------------------------------------------------------------- // bool LogsMainWindow::isForeground() const @@ -72,15 +76,15 @@ } // ----------------------------------------------------------------------------- -// LogsMainWindow::keyPressEvent +// // ----------------------------------------------------------------------------- // void LogsMainWindow::keyPressEvent( QKeyEvent *event ) { LOGS_QDEBUG_2( "LogsMainWindow::keyPressEvent, key", event->key() ); - if ( event->key() == Qt::Key_Call || event->key() == Qt::Key_Yes ) { - // Handling at window level seems to be only way to avoid other - // applications to handle call key as well. + if ( event->key() == Qt::Key_Call + || event->key() == Qt::Key_Yes + || event->key() == Qt::Key_Enter ) { emit callKeyPressed(); event->accept(); return; @@ -89,13 +93,14 @@ } // ----------------------------------------------------------------------------- -// LogsMainWindow::eventFilter +// // ----------------------------------------------------------------------------- // bool LogsMainWindow::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::ApplicationActivate) { LOGS_QDEBUG( "logs [UI] -> eventFilter(), QEvent::ApplicationActivate" ); + startKeyCapture(); mForeground = true; if (mLocaleChanged) { LOGS_QDEBUG( "logs [UI] -> locale changed when we were on BG" ); @@ -103,8 +108,9 @@ mLocaleChanged = false; } emit appGainedForeground(); - } else if (event->type() == QEvent::ApplicationDeactivate) { + } else if (event->type() == QEvent::ApplicationDeactivate ) { LOGS_QDEBUG( "logs [UI] -> eventFilter(), QEvent::ApplicationDeactivate" ); + stopKeyCapture(); mForeground = false; } else if (event->type() == QEvent::LocaleChange) { if (mForeground) { @@ -116,3 +122,23 @@ return HbMainWindow::eventFilter(obj,event); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsMainWindow::startKeyCapture() +{ + mKeyCapture->captureKey(Qt::Key_Yes); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsMainWindow::stopKeyCapture() +{ + if ( mKeyCapture ){ + mKeyCapture->cancelCaptureKey(Qt::Key_Yes); + } +}