Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus qBittorrent on tray icon click instead of minimizing it #11424

Open
Imsvale opened this issue Oct 30, 2019 · 7 comments · May be fixed by #19940
Open

Focus qBittorrent on tray icon click instead of minimizing it #11424

Imsvale opened this issue Oct 30, 2019 · 7 comments · May be fixed by #19940
Labels
GUI GUI-related issues/changes OS: Linux Issues specific to Linux distributions OS: Windows Issues specific to Windows Waiting info Waiting for participants to supply more info/fulfill template requirements

Comments

@Imsvale
Copy link

Imsvale commented Oct 30, 2019

qBittorrent version and Operating System

qBittorrent 4.1.9 (64-bit) on Windows 10 x64 (10.0.1xxxx)

What is the problem

When qBittorrent is open but out of focus, clicking the icon in the notification area (tray) minimizes the app to the tray. This is awkward, as I want my first click to bring it into focus.

What is the expected behavior

Clicking the tray icon should bring the app into focus first. If already in focus, only then should it minimize to the tray when the tray icon is clicked.

Steps to reproduce

  1. Open the app such that the app window is in focus
  2. Change focus to another window, e.g. by opening an Explorer window
  3. Click the qBittorrent tray icon

The app will minimize to the tray instead of being brought into focus, as I would want.

Extra info(if any)

Opinions on this may vary.

There's a similar problem with the taskbar icon (pinned) when opening the app from a minimized-to-tray state. It first takes a moment, seemingly to attempt to start the app, before realizing it's already running. It then lights up the taskbar icon, but doesn't bring the app into focus. That takes another click.

I suppose I could disable the tray icon altogether and get the behavior I want from the taskbar icon. But I like tray icons. :p It gives me the illusion that the app is running "more" in the background than on the taskbar, so it's less intrusive in my mind when not currently working with that window. I'm sure someone out there can appreciate this. It sounds like such a tiny insignificant issue, but it's been enough to turn me off from using qBittorrent for years.

@thalieht thalieht added the GUI GUI-related issues/changes label Oct 30, 2019
@Ryrynz
Copy link

Ryrynz commented Feb 24, 2021

@xavier2k6 some low hanging fruit here, makes sense to do this yeah?

@luzpaz
Copy link
Contributor

luzpaz commented Oct 18, 2023

Is this still not possible in windows ?

@luzpaz luzpaz added the Waiting info Waiting for participants to supply more info/fulfill template requirements label Oct 18, 2023
@xavier2k6
Copy link
Member

Is this still not possible in windows ?

No.

@luzpaz luzpaz added the OS: Windows Issues specific to Windows label Nov 13, 2023
@luzpaz luzpaz changed the title Minimize to tray logic Minimize Qbittorrent to tray on Windows platform Nov 13, 2023
@luzpaz
Copy link
Contributor

luzpaz commented Nov 13, 2023

Maybe add this to the 5.0 roadmap ?

@xavier2k6
Copy link
Member

Maybe add this to the 5.0 roadmap ?

Nobody is working on it

@thalieht thalieht changed the title Minimize Qbittorrent to tray on Windows platform Focus qBittorrent on tray icon click instead of minimizing it on Windows platform Nov 13, 2023
@thalieht
Copy link
Contributor

This seems to do the trick (didn't see any problems) but... these window flags look tricky and i'm not fully aware of what they do.

--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -998,9 +998,13 @@ void MainWindow::notifyOfUpdate(const QString &)
 // Toggle Main window visibility
 void MainWindow::toggleVisibility()
 {
-    if (isHidden())
+    if (isActiveWindow())
+    {
+        hide();
+    }
+    else
     {
-        if (m_uiLocked && !unlockUI())  // Ask for UI lock password
+        if (isHidden() && m_uiLocked && !unlockUI())  // Ask for UI lock password
             return;
 
         // Make sure the window is not minimized
@@ -1011,10 +1015,6 @@ void MainWindow::toggleVisibility()
         raise();
         activateWindow();
     }
-    else
-    {
-        hide();
-    }
 }
 #endif // Q_OS_MACOS
 
@@ -1530,7 +1530,7 @@ QMenu *MainWindow::createDesktopIntegrationMenu()
 #ifndef Q_OS_MACOS
     connect(menu, &QMenu::aboutToShow, this, [this]()
     {
-        m_ui->actionToggleVisibility->setText(isVisible() ? tr("Hide") : tr("Show"));
+        m_ui->actionToggleVisibility->setText(isActiveWindow() ? tr("Hide") : tr("Show"));
     });
 
     menu->addAction(m_ui->actionToggleVisibility);

@thalieht thalieht changed the title Focus qBittorrent on tray icon click instead of minimizing it on Windows platform Focus qBittorrent on tray icon click instead of minimizing it Nov 13, 2023
@thalieht thalieht added the OS: Linux Issues specific to Linux distributions label Nov 13, 2023
@glassez
Copy link
Member

glassez commented Nov 13, 2023

When qBittorrent is open but out of focus, clicking the icon in the notification area (tray) minimizes the app to the tray. This is awkward, as I want my first click to bring it into focus.

👍

This seems to do the trick (didn't see any problems)

Could you provide a PR?

@thalieht thalieht linked a pull request Nov 13, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI GUI-related issues/changes OS: Linux Issues specific to Linux distributions OS: Windows Issues specific to Windows Waiting info Waiting for participants to supply more info/fulfill template requirements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants