Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

Implementing "close to minimize" by throwing out quit() from MainWindow's close event handler#169

Closed
lighterowl wants to merge 1 commit intokeepassx:masterfrom
lighterowl:no-quit-from-mainwindow-close
Closed

Implementing "close to minimize" by throwing out quit() from MainWindow's close event handler#169
lighterowl wants to merge 1 commit intokeepassx:masterfrom
lighterowl:no-quit-from-mainwindow-close

Conversation

@lighterowl
Copy link
Copy Markdown

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 in main.cxx since commit 4cdb9a6. However, because MainWindow::closeEvent calls QApplication::quit, the fact that the application should remain running after closing its last window is effectively ignored.
Since MainWindow::closeEvent automatically ceases being synonymous with closing the main application when "close to minimize" is in effect, it is not possible to call QApplication::quit from 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 the actionQuit object 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.

@VukoDrakkeinen
Copy link
Copy Markdown

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.

@tmst
Copy link
Copy Markdown

tmst commented Nov 27, 2016

Build fails on openSuse 13.2:
...
[36%] Building CXX object src/CMakeFiles/keepassx_core.dir/crypto/Crypto.cpp.o
/home/tom/Software/keepassx/src/crypto/Crypto.cpp:50:37: warning: ‘gcry_thread_cbs’ is deprecated (declared at /usr/include/gcrypt.h:213) [-Wdeprecated-declarations]
static const struct gcry_thread_cbs gcry_threads_qt =
^
/home/tom/Software/keepassx/src/crypto/Crypto.cpp:59:1: error: too many initializers for ‘const gcry_thread_cbs’
};
^
src/CMakeFiles/keepassx_core.dir/build.make:1002: recipe for target 'src/CMakeFiles/keepassx_core.dir/crypto/Crypto.cpp.o' failed
make[2]: *** [src/CMakeFiles/keepassx_core.dir/crypto/Crypto.cpp.o] Error 1
CMakeFiles/Makefile2:114: recipe for target 'src/CMakeFiles/keepassx_core.dir/all' failed
make[1]: *** [src/CMakeFiles/keepassx_core.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

daniellandau pushed a commit to daniellandau/keepassx that referenced this pull request Feb 9, 2017
…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.
daniellandau pushed a commit to daniellandau/keepassx that referenced this pull request Feb 9, 2017
…l-handlers

Implement clean shutdown after receiving Unix signals, resolves keepassx#169
@lighterowl lighterowl closed this May 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants