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

Change tray icon color based on system tray color #1694

Closed
wants to merge 0 commits into from

Conversation

i1sm3ky
Copy link
Contributor

@i1sm3ky i1sm3ky commented Apr 17, 2023

Description

This PR changes tray icon color based on the system tray color which increases the contrast between the tray icon and the system tray.

Related Issue

Issue: #1220 requesting for white icons for menu bar on MacOS

Motivation and Context

This change provides white icons for dark themed Gnome based linux and MacOS which look better as solid white icons instead of the dark black ones.

How Has This Been Tested?

I've run and tested these icons and they look more native than the previous one.
This change doesn't affect any other part of the code.

Screenshots:

Screenshot 2023-04-02 at 6 02 31 AM

Screenshot 2023-04-02 at 6 05 23 AM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

@i1sm3ky
Copy link
Contributor Author

i1sm3ky commented Apr 17, 2023

@real-yfprojects Could you please cross check and review these changes once.

@m3nu
Copy link
Contributor

m3nu commented Apr 17, 2023

No need to notify individual people. Someone will see it in time and review it.

@i1sm3ky
Copy link
Contributor Author

i1sm3ky commented Apr 17, 2023

No need to notify individual people. Someone will see it in time and review it.

Ok, Thanks!

src/vorta/views/utils.py Outdated Show resolved Hide resolved
src/vorta/tray_menu.py Outdated Show resolved Hide resolved
@@ -73,10 +73,19 @@ def build_menu(self):
exit_action = menu.addAction(self.tr('Quit'))
exit_action.triggered.connect(self.app.quit)

def is_taskbar_dark(self):
app = QApplication.instance()
system_tray_color = int(QScreen.grabWindow(app.primaryScreen()).toImage().pixel(0, 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

This only works if the task bar is on top. So it's true for Mac and Gnome, but not everywhere.

It also triggers a privacy warning on Mac.

Screenshot 2023-04-18 at 08 24 07

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's possible to create the task bar icon and then record it's color only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only works if the task bar is on top. So it's true for Mac and Gnome, but not everywhere.

I can check which os it's using and check for tray color on either top or bottom based on it.

It also triggers a privacy warning on Mac.

It didn't on mine for some reason.

Maybe it's possible to create the task bar icon and then record it's color only?

Any ideas on how can I create the initial icon to have a contrasting color to the tray color?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can check which os it's using and check for tray color on either top or bottom based on it.

KDE Plasma allows the task bar to be on any edge of the screen and it can be shorter than the edge it sits on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

KDE Plasma allows the task bar to be on any edge of the screen and it can be shorter than the edge it sits on.

Oh, Then I think I might have to find another way to locate and scan the tray color.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But there's a slight issue, they only work as black and white so the coloured dots which represented the backing up of data in progress don't render in colours and instead just render as white or black.

Can we somehow determine how a template tray icon was rendered and extract information about the tray through that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively we could add a setting and let the user pick the tray colour manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose template images do not work in Linux. Let's first add the code for MacOs and think about linux later.

Are linux system tray's theme also based on the desktop wallpaper or they follow the system's theme?

Can we somehow determine how a template tray icon was rendered and extract information about the tray through that?

I tried that but the colour change is based on the system os as the template is a transparent image only having information about the dimensions and the shape and when trying to extract its colour by converting the current qicon to a pixmap and checking the colour of a pixel on there returns same for both light and dark icons.

Alternatively we could add a setting and let the user pick the tray colour manually.

Yes we can do that as well, but that too will require some logic to check if the selected colour is in range of the dots indicating the working of vorta while backing and converting them to some different colour.

I'll check further into these and let you know if I find any alternatives.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are linux system tray's theme also based on the desktop wallpaper or they follow the system's theme?

Usually they follow the system theme, but on KDE you can use custom themes that can customize every single bit of the appearance.

Yes we can do that as well, but that too will require some logic to check if the selected colour is in range of the dots indicating the working of vorta while backing and converting them to some different colour.

This might actually be the best solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might actually be the best solution.

I think so. I'll work on that after I get home in a few days.

@stale
Copy link

stale bot commented Jul 19, 2023

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@real-yfprojects
Copy link
Collaborator

Are you still working on this @i1sm3ky?

@i1sm3ky
Copy link
Contributor Author

i1sm3ky commented Jul 21, 2023

Are you still working on this @i1sm3ky?

Hey there! Sorry for the delay. Actually I was a little confused as per which solution to implement, also I was on a vacation and I'll be heading to my university in the first week of august then I can start implementing the solution.

Could you please confirm which solution will be better to implement?

@real-yfprojects
Copy link
Collaborator

I think this is were we left of:

Alternatively we could add a setting and let the user pick the tray colour manually.

Yes we can do that as well, but that too will require some logic to check if the selected colour is in range of the dots indicating the working of vorta while backing and converting them to some different colour.

That would be neat. However if you find that this is too complicated you can simply add a setting for toggling the icon between dark and light mode.

@i1sm3ky
Copy link
Contributor Author

i1sm3ky commented Jul 22, 2023

That would be neat. However if you find that this is too complicated you can simply add a setting for toggling the icon between dark and light mode.

I think I can do that, I'll start working on it as soon as possible.

@i1sm3ky
Copy link
Contributor Author

i1sm3ky commented Aug 20, 2023

@real-yfprojects I've a few questions.

  1. Where should we have the option to change the icon color?
  2. Could you please point me towards where the settings are saved?

@real-yfprojects
Copy link
Collaborator

Settings are defined in

def get_misc_settings() -> List[Dict[str, str]]:
and stored in
class SettingsModel(BaseModel):
, while
# Create missing settings and update labels.
# Leave only setting values untouched.
for setting in get_misc_settings():
s, created = SettingsModel.get_or_create(key=setting['key'], defaults=setting)
s.label = setting['label']
s.type = setting['type']
if 'group' in setting:
s.group = setting['group']
if 'tooltip' in setting:
s.tooltip = setting['tooltip']
s.save()
ensures the settings model always contains the correct settings.
The widgets are generated in
def populate(self):
.

@i1sm3ky
Copy link
Contributor Author

i1sm3ky commented Aug 21, 2023

Settings are defined in

def get_misc_settings() -> List[Dict[str, str]]:

and stored in

class SettingsModel(BaseModel):

, while

# Create missing settings and update labels.
# Leave only setting values untouched.
for setting in get_misc_settings():
s, created = SettingsModel.get_or_create(key=setting['key'], defaults=setting)
s.label = setting['label']
s.type = setting['type']
if 'group' in setting:
s.group = setting['group']
if 'tooltip' in setting:
s.tooltip = setting['tooltip']
s.save()

ensures the settings model always contains the correct settings.
The widgets are generated in

def populate(self):

.

Thanks for the help. Should the option to change the icon color be added in the misc tab?

@real-yfprojects
Copy link
Collaborator

Should the option to change the icon color be added in the misc tab?

That would be great!

@alecdwm alecdwm mentioned this pull request Oct 9, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants