diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index d0a37c21a..e3fa74f33 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -183,15 +183,35 @@ void Preferences::setMinimizeToTray(bool b) setValue("Preferences/General/MinimizeToTray", b); } +bool Preferences::minimizeToTrayNotified() const +{ + return value("Preferences/General/MinimizeToTrayNotified", false).toBool(); +} + +void Preferences::setMinimizeToTrayNotified(bool b) +{ + setValue("Preferences/General/MinimizeToTrayNotified", b); +} + bool Preferences::closeToTray() const { - return value("Preferences/General/CloseToTray", false).toBool(); + return value("Preferences/General/CloseToTray", true).toBool(); } void Preferences::setCloseToTray(bool b) { setValue("Preferences/General/CloseToTray", b); } + +bool Preferences::closeToTrayNotified() const +{ + return value("Preferences/General/CloseToTrayNotified", false).toBool(); +} + +void Preferences::setCloseToTrayNotified(bool b) +{ + setValue("Preferences/General/CloseToTrayNotified", b); +} #endif bool Preferences::isToolbarDisplayed() const diff --git a/src/base/preferences.h b/src/base/preferences.h index 136ad106f..c30b0ef7b 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -286,10 +286,14 @@ public: #ifndef Q_OS_MAC bool systrayIntegration() const; void setSystrayIntegration(bool enabled); + bool minimizeToTrayNotified() const; + void setMinimizeToTrayNotified(bool b); bool minimizeToTray() const; void setMinimizeToTray(bool b); bool closeToTray() const; void setCloseToTray(bool b); + bool closeToTrayNotified() const; + void setCloseToTrayNotified(bool b); TrayIcon::Style trayIconStyle() const; void setTrayIconStyle(TrayIcon::Style style); #endif diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 396e4a087..1f831dd5f 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -414,8 +414,13 @@ MainWindow::MainWindow(QWidget *parent) } else if (pref->startMinimized()) { showMinimized(); - if (pref->minimizeToTray()) + if (pref->minimizeToTray()) { hide(); + if (!pref->minimizeToTrayNotified()) { + showNotificationBaloon(tr("qBittorrent is minimized to tray"), tr("This behavior can be changed in the settings. You won't be reminded again.")); + pref->setMinimizeToTrayNotified(true); + } + } } } else { @@ -1139,6 +1144,10 @@ void MainWindow::closeEvent(QCloseEvent *e) if (!m_forceExit && m_systrayIcon && goToSystrayOnExit && !this->isHidden()) { hide(); e->accept(); + if (!pref->closeToTrayNotified()) { + showNotificationBaloon(tr("qBittorrent is closed to tray"), tr("This behavior can be changed in the settings. You won't be reminded again.")); + pref->setCloseToTrayNotified(true); + } return; } #endif // Q_OS_MAC @@ -1208,7 +1217,8 @@ bool MainWindow::event(QEvent *e) // Now check to see if the window is minimised if (isMinimized()) { qDebug("minimisation"); - if (m_systrayIcon && Preferences::instance()->minimizeToTray()) { + Preferences *const pref = Preferences::instance(); + if (m_systrayIcon && pref->minimizeToTray()) { qDebug() << "Has active window:" << (qApp->activeWindow() != nullptr); // Check if there is a modal window bool hasModalWindow = false; @@ -1223,6 +1233,10 @@ bool MainWindow::event(QEvent *e) qDebug("Minimize to Tray enabled, hiding!"); e->ignore(); QTimer::singleShot(0, this, &QWidget::hide); + if (!pref->minimizeToTrayNotified()) { + showNotificationBaloon(tr("qBittorrent is minimized to tray"), tr("This behavior can be changed in the settings. You won't be reminded again.")); + pref->setMinimizeToTrayNotified(true); + } return true; } }