thamara / time-to-leave

Log work hours and get notified when it's time to leave the office and start to live.
http://timetoleave.app
GNU General Public License v3.0
463 stars 272 forks source link

No tooltip when the cursor hovers over tray icon #1081

Open diogoan opened 1 month ago

diogoan commented 1 month ago

Describe the issue There is no tooltip (like the app name) when the mouse cursor is on the application icon on the tray area. This is not a breaking issue, but I thought it could be reported. Also, some functionality may be added in the tooltip (like how many hours were worked today, or what is the time to leave).

To Reproduce Steps to reproduce the behavior:

  1. Just position the cursor on the app's icon in the tray area.

Expected behavior A tooltip should appear, containing, at least, the app's name.

Environment

Screenshots v0jETCRik7 (yep, I use my taskbar at the left of the screen)

Additional context Nothing to add.

diogoan commented 1 month ago

Adding a tooltip to the tray icon is as simple as inserting the following line: tray.setToolTip('Time to Leave') Source: https://www.electronjs.org/docs/latest/api/tray

I can volunteer to send a PR fixing this issue, but I'll need some work to figure out how to insert some more functionality to it, like it saying "You can leave by 6:05 PM".

thamara commented 1 month ago

I think having the tooltip is already a great start. From what I can tell, there is no event like "requested tooltip", so it might not be trivial to set the tooltip. An idea is to update the tooltip as necessary. For example: Whenever there's a new entry -> Update tool tip with "You can leave by XX:XX". This would work if you just started your day, or if you are leaving or coming back from lunch for example. We could even do some math to, let's say, if the person filled an even number of entries, we could say something like: "You worked XX:XX today." if the total time suppress the usual amount set on the preferences. Or "More XX:XX to go." if the total time is less. If going on this direction (even on a reduced scope of always saying just "You can leave by...", we should make sure to update the tooltip not only on adding/removing entries, but also refreshing for a new day (follow the REFRESH_ON_DAY_CHANGE).

Does this make sense? @diogoan do you want take on this?

diogoan commented 1 month ago

Hi @thamara, I was giving some thought to it and I think we should keep it simple. If we follow the same logic as the app, we only would have to display the "You can leave by XX:XX" message on the tooltip when there's a punch, and a "Today's balance: XX:XX" message when the time to leave is past.

This is because I don't see any feature for displaying the worked time or the "More XX:XX to go" phrase, so I believe it is not the purpose of the app (or is it? I'm just using the app since last week), and we would need extra logic to calculate the times. For the other two messages, we just need to reuse the existing logic in the code that is already working.

I can take on this, in fact I already did the tooltip just for the "Time to Leave" title, but for the other two strings, I need to research some more in the code to get acquainted to it.

Thank you!

thamara commented 1 month ago

Makes sense, I got a bit carried away with the possibility of being very dynamic with a sprinkle of a motivational coach. Hahahahha Please go ahead with the change.