diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-09-28 15:52:22 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-09-29 07:06:27 (GMT) |
commit | 8aec69a5cae285174b41df6d268f007edcdec84b (patch) | |
tree | 588ec77100d8cff6381674de2d63de0787b6ad5e /src/gui | |
parent | ff6c8f9439630c2ea3bf78d5568a44521e915898 (diff) | |
download | Qt-8aec69a5cae285174b41df6d268f007edcdec84b.zip Qt-8aec69a5cae285174b41df6d268f007edcdec84b.tar.gz Qt-8aec69a5cae285174b41df6d268f007edcdec84b.tar.bz2 |
Add a more proper shutdown sequence for Symbian applications.
Previously both EEikCmdExit and EAknSoftkeyExit were hard coded to call
exit() which promptly exited the event loop without the chance to do
any UI operations. With this patch, we handle the two cases
differently and allow people to essentially make the right soft key
a hide instead of an exit simply by reimplementing closeEvent() and
ignoring the event.
EAknSoftkeyExit is now a soft exit since this does not seem to be a
mandatory exit in S60. By sending a QCloseEvent to QApplication this
has the effect that all windows are closed (sent another QCloseEvent)
and if one of them chooses to ignore this event, the application and
UI are both kept alive. This is similar to how Qt behaves on other
platforms. If all windows accept the close event (default), then the
application will quit() as normal. This command is sent from the
right soft key.
EEikCmdExit is mapped similarly as before, but calls quit() instead of
exit() to be aligned with other platforms. This will cause the
aboutToQuit signal to be emitted which maps very well to Qt because UI
interaction is not permitted from this signal and wouldn't work in S60
anyway because in the case of EEikCmdExit, the UI has already been torn
down by the UI framework. This command is sent by the End key.
We could take this one step further and intercept the key event and
prevent it from going to the UI framework and tearing down the UI,
but this is a little too evil IMHO. If people really want to
intercept that event, they can do it by reimplementing the platform
specific event filter. This is equivalent to how it would be done in
S60 (reimplementing HandleWsEvent).
Reviewed-by: axis
Reviewed-by: mread
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 0637652..99d188e 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1458,11 +1458,17 @@ bool QApplication::s60EventFilter(TWsEvent * /* aEvent */) void QApplication::symbianHandleCommand(int command) { switch (command) { - case EEikCmdExit: #ifdef Q_WS_S60 - case EAknSoftkeyExit: + case EAknSoftkeyExit: { + QCloseEvent ev; + QApplication::sendSpontaneousEvent(this, &ev); + if (ev.isAccepted()) + quit(); + break; + } #endif - exit(); + case EEikCmdExit: + quit(); break; default: bool handled = QSoftKeyManager::handleCommand(command); |