Implementing "close to minimize" by throwing out quit() from MainWindow's close event handler#169
Implementing "close to minimize" by throwing out quit() from MainWindow's close event handler#169lighterowl wants to merge 1 commit intokeepassx:masterfrom lighterowl:no-quit-from-mainwindow-close
Conversation
|
It is said that great minds think alike. It seems that we had the same idea :D I would withdraw my pull request, since you were faster, but mine also adds a toggle in the settings widget. Anyways, I hope either gets merged. |
|
Build fails on openSuse 13.2: |
…ssx#169 The database wasn't saved properly and lockfiles were not removed when receiving the signals SIGINT, SIGTERM, SIGQUIT or SIGHUP. This patch implements signal handling and performs a clean shutdown after receiving SIGINT SIGTERM or SIGQUIT and ignores SIGHUP. Since this uses POSIX syscalls for signal and socket handling, there is no Windows implementation at the moment.
…l-handlers Implement clean shutdown after receiving Unix signals, resolves keepassx#169
Although pull requests #100 and #140 both mention this issue, I would like to bring it to the developers' attention once again.
Qt natively supports "persistent" applications, e.g. ones that don't quit after closing their main window. This is done by calling
QApplication::setQuitOnLastWindowClosed(false), which has been present inmain.cxxsince commit 4cdb9a6. However, becauseMainWindow::closeEventcallsQApplication::quit, the fact that the application should remain running after closing its last window is effectively ignored.Since
MainWindow::closeEventautomatically ceases being synonymous with closing the main application when "close to minimize" is in effect, it is not possible to callQApplication::quitfrom within it, as it brings down the entire application. My solution proposes moving code related to quitting the application to a dedicated function that's only called when theactionQuitobject is triggered : effectively, when choosing "Quit Application" from the file menu or the analogous option from within the tray icon's right-click menu.You'll notice that this commit does not introduce a configuration option for selecting whether the application should remain running after clicking "close" : since KeePassX is an application that the user should want running all the time, I don't think that there's any value in introducing it. If you disagree, it can be added without much hassle - simply call
QApplication::setQuitOnLastWindowClosed()again.