Skip to content

Instantly share code, notes, and snippets.

@khaytsus
Created November 12, 2017 17:16
Show Gist options
  • Save khaytsus/5e67b4824eccda3530e26f62aa1b1461 to your computer and use it in GitHub Desktop.
Save khaytsus/5e67b4824eccda3530e26f62aa1b1461 to your computer and use it in GitHub Desktop.
Simple patch for keepassx to minimize to tray on window close rather than exit. For some reason the developer insists that this is a bad pattern, but at least the change is very simple. I'm not claiming this is the best way, some of the conditionals I'm removing should likely stay but this works fine.
--- keepassx-2.0.3/src/gui/MainWindow.cpp 2017-11-11 09:36:25.000000000 -0500
+++ keepassx-2.0.3-fixed/src/gui/MainWindow.cpp 2017-11-11 09:51:22.898728108 -0500
@@ -441,19 +441,20 @@
if (accept) {
- if ((event->type() == QEvent::WindowStateChange) && isMinimized()
- && isTrayIconEnabled() && m_trayIcon && m_trayIcon->isVisible()
+ if (isTrayIconEnabled() && m_trayIcon && m_trayIcon->isVisible()
&& config()->get("GUI/MinimizeToTray").toBool())
{
event->ignore();
QTimer::singleShot(0, this, SLOT(hide()));
}
-
-/* saveWindowInformation();
+ else
+ {
+ saveWindowInformation();
- event->accept();
- QApplication::quit();
-*/ }
+ event->accept();
+ QApplication::quit();
+ }
+ }
else {
event->ignore();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment