18 #include "logsmainwindow.h" |
18 #include "logsmainwindow.h" |
19 #include "logslogger.h" |
19 #include "logslogger.h" |
20 #include <QKeyEvent> |
20 #include <QKeyEvent> |
21 #include <QApplication> |
21 #include <QApplication> |
22 #include <xqserviceutil.h> |
22 #include <xqserviceutil.h> |
|
23 #include <xqkeycapture.h> |
23 |
24 |
24 // ----------------------------------------------------------------------------- |
25 // ----------------------------------------------------------------------------- |
25 // LogsMainWindow::LogsMainWindow |
26 // |
26 // ----------------------------------------------------------------------------- |
27 // ----------------------------------------------------------------------------- |
27 // |
28 // |
28 LogsMainWindow::LogsMainWindow() |
29 LogsMainWindow::LogsMainWindow() |
29 : HbMainWindow(), mForeground(false), mLocaleChanged(false) |
30 : HbMainWindow(), mForeground(false), mLocaleChanged(false) |
30 { |
31 { |
31 qApp->installEventFilter(this); |
32 qApp->installEventFilter(this); |
|
33 mKeyCapture = new XQKeyCapture; |
32 } |
34 } |
33 |
35 |
34 // ----------------------------------------------------------------------------- |
36 // ----------------------------------------------------------------------------- |
35 // LogsMainWindow::~LogsMainWindow |
37 // |
36 // ----------------------------------------------------------------------------- |
38 // ----------------------------------------------------------------------------- |
37 // |
39 // |
38 LogsMainWindow::~LogsMainWindow() |
40 LogsMainWindow::~LogsMainWindow() |
39 { |
41 { |
|
42 stopKeyCapture(); |
|
43 delete mKeyCapture; |
40 } |
44 } |
41 |
45 |
42 // ----------------------------------------------------------------------------- |
46 // ----------------------------------------------------------------------------- |
43 // LogsMainWindow::sendAppToBackground |
47 // |
44 // ----------------------------------------------------------------------------- |
48 // ----------------------------------------------------------------------------- |
45 // |
49 // |
46 void LogsMainWindow::sendAppToBackground() |
50 void LogsMainWindow::sendAppToBackground() |
47 { |
51 { |
48 LOGS_QDEBUG( "logs [UI] -> LogsMainWindow::sendAppToBackground" ); |
52 LOGS_QDEBUG( "logs [UI] -> LogsMainWindow::sendAppToBackground" ); |
49 XQServiceUtil::toBackground(true); |
53 XQServiceUtil::toBackground(true); |
50 LOGS_QDEBUG( "logs [UI] <- LogsMainWindow::sendAppToBackground" ); |
54 LOGS_QDEBUG( "logs [UI] <- LogsMainWindow::sendAppToBackground" ); |
51 } |
55 } |
52 |
56 |
53 // ----------------------------------------------------------------------------- |
57 // ----------------------------------------------------------------------------- |
54 // LogsMainWindow::bringAppToForeground |
58 // |
55 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
56 // |
60 // |
57 void LogsMainWindow::bringAppToForeground() |
61 void LogsMainWindow::bringAppToForeground() |
58 { |
62 { |
59 LOGS_QDEBUG( "logs [UI] -> LogsMainWindow::bringAppToForeground" ); |
63 LOGS_QDEBUG( "logs [UI] -> LogsMainWindow::bringAppToForeground" ); |
61 raise(); |
65 raise(); |
62 LOGS_QDEBUG( "logs [UI] <- LogsMainWindow::bringAppToForeground" ); |
66 LOGS_QDEBUG( "logs [UI] <- LogsMainWindow::bringAppToForeground" ); |
63 } |
67 } |
64 |
68 |
65 // ----------------------------------------------------------------------------- |
69 // ----------------------------------------------------------------------------- |
66 // LogsMainWindow::isForeground |
70 // |
67 // ----------------------------------------------------------------------------- |
71 // ----------------------------------------------------------------------------- |
68 // |
72 // |
69 bool LogsMainWindow::isForeground() const |
73 bool LogsMainWindow::isForeground() const |
70 { |
74 { |
71 return mForeground; |
75 return mForeground; |
72 } |
76 } |
73 |
77 |
74 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
75 // LogsMainWindow::keyPressEvent |
79 // |
76 // ----------------------------------------------------------------------------- |
80 // ----------------------------------------------------------------------------- |
77 // |
81 // |
78 void LogsMainWindow::keyPressEvent( QKeyEvent *event ) |
82 void LogsMainWindow::keyPressEvent( QKeyEvent *event ) |
79 { |
83 { |
80 LOGS_QDEBUG_2( "LogsMainWindow::keyPressEvent, key", event->key() ); |
84 LOGS_QDEBUG_2( "LogsMainWindow::keyPressEvent, key", event->key() ); |
81 if ( event->key() == Qt::Key_Call || event->key() == Qt::Key_Yes ) { |
85 if ( event->key() == Qt::Key_Call |
82 // Handling at window level seems to be only way to avoid other |
86 || event->key() == Qt::Key_Yes |
83 // applications to handle call key as well. |
87 || event->key() == Qt::Key_Enter ) { |
84 emit callKeyPressed(); |
88 emit callKeyPressed(); |
85 event->accept(); |
89 event->accept(); |
86 return; |
90 return; |
87 } |
91 } |
88 HbMainWindow::keyPressEvent(event); |
92 HbMainWindow::keyPressEvent(event); |
89 } |
93 } |
90 |
94 |
91 // ----------------------------------------------------------------------------- |
95 // ----------------------------------------------------------------------------- |
92 // LogsMainWindow::eventFilter |
96 // |
93 // ----------------------------------------------------------------------------- |
97 // ----------------------------------------------------------------------------- |
94 // |
98 // |
95 bool LogsMainWindow::eventFilter(QObject *obj, QEvent *event) |
99 bool LogsMainWindow::eventFilter(QObject *obj, QEvent *event) |
96 { |
100 { |
97 if (event->type() == QEvent::ApplicationActivate) { |
101 if (event->type() == QEvent::ApplicationActivate) { |
98 LOGS_QDEBUG( "logs [UI] -> eventFilter(), QEvent::ApplicationActivate" ); |
102 LOGS_QDEBUG( "logs [UI] -> eventFilter(), QEvent::ApplicationActivate" ); |
|
103 startKeyCapture(); |
99 mForeground = true; |
104 mForeground = true; |
100 if (mLocaleChanged) { |
105 if (mLocaleChanged) { |
101 LOGS_QDEBUG( "logs [UI] -> locale changed when we were on BG" ); |
106 LOGS_QDEBUG( "logs [UI] -> locale changed when we were on BG" ); |
102 emit localeChanged(); |
107 emit localeChanged(); |
103 mLocaleChanged = false; |
108 mLocaleChanged = false; |
104 } |
109 } |
105 emit appGainedForeground(); |
110 emit appGainedForeground(); |
106 } else if (event->type() == QEvent::ApplicationDeactivate) { |
111 } else if (event->type() == QEvent::ApplicationDeactivate ) { |
107 LOGS_QDEBUG( "logs [UI] -> eventFilter(), QEvent::ApplicationDeactivate" ); |
112 LOGS_QDEBUG( "logs [UI] -> eventFilter(), QEvent::ApplicationDeactivate" ); |
|
113 stopKeyCapture(); |
108 mForeground = false; |
114 mForeground = false; |
109 } else if (event->type() == QEvent::LocaleChange) { |
115 } else if (event->type() == QEvent::LocaleChange) { |
110 if (mForeground) { |
116 if (mForeground) { |
111 emit localeChanged(); |
117 emit localeChanged(); |
112 } else { |
118 } else { |