From f36e1e651371871099488cf406de9c5549b6a8b4 Mon Sep 17 00:00:00 2001 From: Odizinne Date: Sun, 15 Sep 2024 13:01:38 +0200 Subject: [PATCH] Do not send tray notification if user exit program from tray on first launch --- src/HeadsetControlQt/headsetcontrolqt.cpp | 6 ++++++ src/HeadsetControlQt/headsetcontrolqt.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/HeadsetControlQt/headsetcontrolqt.cpp b/src/HeadsetControlQt/headsetcontrolqt.cpp index 87d45fc..e2c5b3b 100644 --- a/src/HeadsetControlQt/headsetcontrolqt.cpp +++ b/src/HeadsetControlQt/headsetcontrolqt.cpp @@ -36,6 +36,7 @@ HeadsetControlQt::HeadsetControlQt(QWidget *parent) , notificationSent(false) , soundNotificationSent(false) , firstRun(false) + , closing(false) , worker(new Worker()) { ui->setupUi(this); @@ -529,6 +530,7 @@ void HeadsetControlQt::trayIconActivated(QSystemTrayIcon::ActivationReason reaso void HeadsetControlQt::closeEvent(QCloseEvent *event) { + closing = true; event->accept(); trayIcon->contextMenu()->actions().first()->setText(tr("Show")); sendFirstMinimizeNotification(); @@ -536,6 +538,10 @@ void HeadsetControlQt::closeEvent(QCloseEvent *event) void HeadsetControlQt::sendFirstMinimizeNotification() { + if (closing) { + return; + } + if (firstRun) { sendNotification(tr("HeadsetControl-Qt"), QString(tr("The application is still running in the background.")), QIcon(":/icons/icon.png"), 5000); firstRun = false; diff --git a/src/HeadsetControlQt/headsetcontrolqt.h b/src/HeadsetControlQt/headsetcontrolqt.h index 7299ea7..1692bca 100644 --- a/src/HeadsetControlQt/headsetcontrolqt.h +++ b/src/HeadsetControlQt/headsetcontrolqt.h @@ -72,6 +72,7 @@ private slots: bool notificationSent; bool soundNotificationSent; bool firstRun; + bool closing; QThread workerThread; Worker *worker;