mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
Notify users on 1st time close/minimize to tray
This commit is contained in:
parent
2befd2927a
commit
fd30bf7423
3 changed files with 40 additions and 2 deletions
|
@ -183,6 +183,16 @@ void Preferences::setMinimizeToTray(bool b)
|
||||||
setValue("Preferences/General/MinimizeToTray", 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
|
bool Preferences::closeToTray() const
|
||||||
{
|
{
|
||||||
return value("Preferences/General/CloseToTray", true).toBool();
|
return value("Preferences/General/CloseToTray", true).toBool();
|
||||||
|
@ -192,6 +202,16 @@ void Preferences::setCloseToTray(bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/CloseToTray", 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
|
#endif
|
||||||
|
|
||||||
bool Preferences::isToolbarDisplayed() const
|
bool Preferences::isToolbarDisplayed() const
|
||||||
|
|
|
@ -286,10 +286,14 @@ public:
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
bool systrayIntegration() const;
|
bool systrayIntegration() const;
|
||||||
void setSystrayIntegration(bool enabled);
|
void setSystrayIntegration(bool enabled);
|
||||||
|
bool minimizeToTrayNotified() const;
|
||||||
|
void setMinimizeToTrayNotified(bool b);
|
||||||
bool minimizeToTray() const;
|
bool minimizeToTray() const;
|
||||||
void setMinimizeToTray(bool b);
|
void setMinimizeToTray(bool b);
|
||||||
bool closeToTray() const;
|
bool closeToTray() const;
|
||||||
void setCloseToTray(bool b);
|
void setCloseToTray(bool b);
|
||||||
|
bool closeToTrayNotified() const;
|
||||||
|
void setCloseToTrayNotified(bool b);
|
||||||
TrayIcon::Style trayIconStyle() const;
|
TrayIcon::Style trayIconStyle() const;
|
||||||
void setTrayIconStyle(TrayIcon::Style style);
|
void setTrayIconStyle(TrayIcon::Style style);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -414,8 +414,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
else if (pref->startMinimized()) {
|
else if (pref->startMinimized()) {
|
||||||
showMinimized();
|
showMinimized();
|
||||||
if (pref->minimizeToTray())
|
if (pref->minimizeToTray()) {
|
||||||
hide();
|
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 {
|
else {
|
||||||
|
@ -1139,6 +1144,10 @@ void MainWindow::closeEvent(QCloseEvent *e)
|
||||||
if (!m_forceExit && m_systrayIcon && goToSystrayOnExit && !this->isHidden()) {
|
if (!m_forceExit && m_systrayIcon && goToSystrayOnExit && !this->isHidden()) {
|
||||||
hide();
|
hide();
|
||||||
e->accept();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
@ -1208,7 +1217,8 @@ bool MainWindow::event(QEvent *e)
|
||||||
// Now check to see if the window is minimised
|
// Now check to see if the window is minimised
|
||||||
if (isMinimized()) {
|
if (isMinimized()) {
|
||||||
qDebug("minimisation");
|
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);
|
qDebug() << "Has active window:" << (qApp->activeWindow() != nullptr);
|
||||||
// Check if there is a modal window
|
// Check if there is a modal window
|
||||||
bool hasModalWindow = false;
|
bool hasModalWindow = false;
|
||||||
|
@ -1223,6 +1233,10 @@ bool MainWindow::event(QEvent *e)
|
||||||
qDebug("Minimize to Tray enabled, hiding!");
|
qDebug("Minimize to Tray enabled, hiding!");
|
||||||
e->ignore();
|
e->ignore();
|
||||||
QTimer::singleShot(0, this, &QWidget::hide);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue