From 2befd2927a1409cbb59bdf02ec3e41c2a622a838 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Fri, 3 Aug 2018 14:21:55 +0300 Subject: [PATCH 1/2] Revert "Set "close to tray" to false as default" This reverts commit dc9ec0e40875f2562cd2130d6bcbc33b1cf63d88. --- src/base/preferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index d0a37c21a..b02b1e5b5 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -185,7 +185,7 @@ void Preferences::setMinimizeToTray(bool b) bool Preferences::closeToTray() const { - return value("Preferences/General/CloseToTray", false).toBool(); + return value("Preferences/General/CloseToTray", true).toBool(); } void Preferences::setCloseToTray(bool b) From fd30bf7423b006d107d839b989d2940c066229e0 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Fri, 3 Aug 2018 14:55:20 +0300 Subject: [PATCH 2/2] Notify users on 1st time close/minimize to tray --- src/base/preferences.cpp | 20 ++++++++++++++++++++ src/base/preferences.h | 4 ++++ src/gui/mainwindow.cpp | 18 ++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index b02b1e5b5..e3fa74f33 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -183,6 +183,16 @@ 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", true).toBool(); @@ -192,6 +202,16 @@ 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; } }