From 40629915f74eb23118c3079ab80df9fdf42fa894 Mon Sep 17 00:00:00 2001 From: Boyuan Yang Date: Fri, 25 Sep 2020 22:03:35 -0400 Subject: [PATCH] Explicitly hide tray icon before exit on Windows Currently flameshot tray icon will not disappear after program terminates on Windows. This is a known issue and need to be explicitly handled. This commit connects the aboutToQuit signal to QSystemTrayIcon::hide slot to ensure that the tray icon is removed before program terminates. --- src/core/controller.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 3d2343f9..b0cf0b3d 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -234,6 +234,13 @@ void Controller::enableTrayIcon() } }; connect(m_trayIcon, &QSystemTrayIcon::activated, this, trayIconActivated); + +#ifdef Q_OS_WIN + // Ensure proper removal of tray icon when program quits on Windows. + connect( + qApp, &QCoreApplication::aboutToQuit, m_trayIcon, &QSystemTrayIcon::hide); +#endif + m_trayIcon->show(); }