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

Added hide to tray option #6915

Open
wants to merge 22 commits into
base: development
Choose a base branch
from
Open

Conversation

Devenor
Copy link

@Devenor Devenor commented Feb 24, 2025

Added hide to tray option

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

#59

Description

Adds optional hide to system tray behaviour on closing and/or minimizing the main window. The settings have an option to enable or disable it in the general section. The tray icon has a small menu for closing the app or opening the window again, and it can be opened by clicking on the icon too.

Screenshots

https://imgur.com/a/1TVWBJp
https://imgur.com/a/xvBEqFe

Testing

Fully tested on Windows.
The closing behaviour has been adapted for Darwin but has not been tested.

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: v0.23.2 Beta

Additional context

@github-actions github-actions bot added PR: dependencies Pull requests that update a dependency file PR: waiting for review For PRs that are complete, tested, and ready for review labels Feb 24, 2025
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) February 24, 2025 22:48
auto-merge was automatically disabled February 24, 2025 23:12

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) February 24, 2025 23:12
@absidue
Copy link
Member

absidue commented Feb 25, 2025

Please fix the build and revert all unrelated changes such as the dependency additions, there is no need to manually extract anything from the asar file and the translations are overkill at the moment (especially pulling in multiple dependencies just to translate 2 strings).

Even after the corrections there are still open questions such as how to handle multiple windows.

@absidue absidue added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels Feb 25, 2025
auto-merge was automatically disabled February 25, 2025 18:18

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) February 25, 2025 18:18
auto-merge was automatically disabled February 25, 2025 18:22

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) February 25, 2025 18:23
@Devenor
Copy link
Author

Devenor commented Feb 25, 2025

Thanks for the review, I reverted the new dependencies (I didn't know you could read asar directly from node fs! It's much better now). About the i18n, if needed maybe we could send the translated text via IPC and recreate the tray.

As for how to handle multiple windows, I didn't know you could have more than one, is there some kind of setting for that?

Copy link
Contributor

github-actions bot commented Mar 3, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

auto-merge was automatically disabled March 3, 2025 21:02

Head branch was pushed to by a user without write access

Copy link
Contributor

github-actions bot commented Mar 3, 2025

Conflicts have been resolved. A maintainer will review the pull request shortly.

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 3, 2025 21:02
@absidue
Copy link
Member

absidue commented Mar 3, 2025

Looks like you may have mistakenly used npm instead of yarn to install the dependencies and pushed a package-lock.json file, additionally there seem to be changes to the yarn.lock file which shouldn't really be there as the dependencies are no longer changing in this PR.

auto-merge was automatically disabled March 3, 2025 21:38

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 3, 2025 21:38
auto-merge was automatically disabled March 3, 2025 21:43

Head branch was pushed to by a user without write access

@Devenor
Copy link
Author

Devenor commented Mar 10, 2025

@absidue Thanks a lot, seems to be working fine now.

Right now there's no need to do anything to the PR on my side for the review, right?

@absidue
Copy link
Member

absidue commented Mar 10, 2025

The biggest open question is how to handle multiple windows with this tray stuff.

You can open new windows in many different ways, it is not an obscure feature:

  • Opening to the home page
    • Clicking the New Window button in the top bar
    • CTRL/Command+N
    • --new-window command line flag
  • Opening in-app links in a new window
    • Middle click
    • CTRL + click
    • Right click -> Open in New Window
  • Opening a search in a new window
    • Hold SHIFT while pressing the search button
    • SHIFT+ENTER while focused on the main search bar
  • Opening links redirected from a browser in a new window
    • Settings -> General -> Open URLs Passed to FreeTube in a New Window

auto-merge was automatically disabled March 11, 2025 21:18

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 11, 2025 21:18
@Devenor
Copy link
Author

Devenor commented Mar 11, 2025

@absidue I've pushed some changes to add support for multiple windows, now the tray looks like this:

tray

For every window you hide, there will be a menu in the tray with the window's title and a submenu for showing or closing it. If there's only one hidden window, you can show it by clicking on the tray icon too. If every window is closed using the submenu option and there are no opened windows, or if you select the Quit option, the app will exit.

@PikachuEXE
Copy link
Collaborator

Reminder that you can post images on GitHub directly

e.g.

image

@Devenor
Copy link
Author

Devenor commented Mar 11, 2025

Reminder that you can post images on GitHub directly

Thanks for the tip! I've updated my previous comment.

@absidue absidue removed the PR: dependencies Pull requests that update a dependency file label Mar 12, 2025
Copy link
Member

@absidue absidue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is essentially just a more complicated way of minimising a window, lets treat it the same way. Please remove the hide on close option and make sure when the mainWindow is hidden that it gets shown when opening a link from a web browser, the behaviour should match what happens when a window is minimised the normal way.

Additionally if the Hide to tray on minimise setting is disabled while some windows are hidden and the tray icon exists, all windows should be shown and the tray icon removed.

@efb4f5ff-1298-471a-8973-3d47447115dc
Copy link
Member

efb4f5ff-1298-471a-8973-3d47447115dc commented Mar 12, 2025

Seeing 2 tray icons and show and close doenst work if there is two of them.
Also if i have 1 tray icon and go back into FT i expect the tray option to be gone

VirtualBoxVM_weorUSYvw5.mp4

auto-merge was automatically disabled March 12, 2025 22:58

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 12, 2025 22:58
auto-merge was automatically disabled March 12, 2025 23:09

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 12, 2025 23:09
@Devenor
Copy link
Author

Devenor commented Mar 12, 2025

@absidue Everything is changed as you asked, though I couldn't test the mainWindow behaviour for MacOS when opening a link from the web browser (line 1842 at src/main/index.js)

@efb4f5ff-1298-471a-8973-3d47447115dc thanks for reporting this, unfortunately it seems to be an Electron bug in Linux as stated here. I tried a couple of things to fix it with no success, I'll see if I can find some workaround tomorrow.

auto-merge was automatically disabled March 13, 2025 21:59

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 13, 2025 21:59
@Devenor
Copy link
Author

Devenor commented Mar 13, 2025

@efb4f5ff-1298-471a-8973-3d47447115dc @absidue I've pushed a workaround for the Linux issue. I wasn't able to make the tray disappear, so I decided to keep it always visible (only on Linux) and just update the menu, which seems to work fine. It shows the tray when enabling the option and when starting the app if the option is enabled, but I couldn't make it disappear when disabling the option for obvious reasons.

I've also fixed the submenu close option, which wasn't working as intended after the last changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants