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

Add system theme support #806

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

zwimer
Copy link
Member

@zwimer zwimer commented Dec 1, 2022

Implements: #780
Fixes: #805

@zwimer zwimer linked an issue Dec 1, 2022 that may be closed by this pull request
@zwimer zwimer self-assigned this Dec 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

Unit Test Results

1 tests   - 7   1 ✔️  - 7   0s ⏱️ - 1m 0s
1 suites  - 7   0 💤 ±0 
1 files    - 7   0 ±0 

Results for commit d2474ae. ± Comparison against base commit c2d5747.

This pull request removes 7 tests.
test_qaddress_input.TestQaddressInput ‑ test_address_conversion
test_qaddress_input.TestQaddressInput ‑ test_function_name
test_rename_functions.TestRenameFunctions ‑ test_rename_a_callee_in_pseudocode_view
test_rename_functions.TestRenameFunctions ‑ test_rename_a_function_in_disasm_and_pseudocode_views
test_rename_variables.TestRenameVariables ‑ test_rename_a_global_variable_in_pseudocode_view
test_rename_variables.TestRenameVariables ‑ test_rename_a_local_variable_in_pseudocode_view
test_workflow.TestWorkflow ‑ test_workflow

♻️ This comment has been updated with latest results.

@zwimer zwimer marked this pull request as ready for review December 1, 2022 04:30
@zwimer
Copy link
Member Author

zwimer commented Dec 2, 2022

A better way to do this would be to add an observer with a callback, rather than polling. I'll investigate this.

A possible example: https://github.com/mborgerson/TrayPlay/blob/5a9e43ca4c32283f6253761b69858ba43ee48720/TrayPlay/AppDelegate.m#L52

@zwimer zwimer marked this pull request as draft December 2, 2022 07:26
@zwimer zwimer mentioned this pull request Dec 2, 2022
@zwimer
Copy link
Member Author

zwimer commented Dec 6, 2022

I made a PR on dark detect to add a listener for macoOS: albertosottile/darkdetect#30

Once it is merged and updated on pypi, I can update the PR to use the listeners instead of doing polling.

@zwimer
Copy link
Member Author

zwimer commented Dec 8, 2022

In order to avoid leaving potentially orphaned subprocesses around, I've filed this issue: albertosottile/darkdetect#31

@zwimer
Copy link
Member Author

zwimer commented Dec 8, 2022

Once albertosottile/darkdetect#32 is merged I'll update this PR; hopefully a new PyPi release will be out soon at that point.

@zwimer
Copy link
Member Author

zwimer commented Jan 19, 2023

CI will continue to fail until the darkdetect PR is merged and a new pypi release is made.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 25, 2023

Test Results

19 tests  ±0   19 ✔️ ±0   1m 54s ⏱️ +20s
10 suites ±0     0 💤 ±0 
10 files   ±0     0 ±0 

Results for commit 1b1092f. ± Comparison against base commit 0b37a4b.

♻️ This comment has been updated with latest results.

@zwimer
Copy link
Member Author

zwimer commented Apr 26, 2023

The test failures are also failing on master.

@zwimer zwimer marked this pull request as ready for review April 26, 2023 02:43
@zwimer
Copy link
Member Author

zwimer commented Apr 26, 2023

Upon merging, #780 and #805 should both be marked as complete.

angrmanagement/ui/dialogs/preferences.py Show resolved Hide resolved
@@ -235,6 +259,9 @@ def save_config(self):
for i in self._font_options:
i.update()

def revert_unsaved(self):
Copy link
Member

Choose a reason for hiding this comment

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

Identical to base class implemantation

Copy link
Member Author

Choose a reason for hiding this comment

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

The base class raises NotImpelementedError.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I guess I was looking at the wrong thing

Why not have the default implementation do nothing instead of raising an error? Or just drop the method because there's not an implementation that does anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was generally thinking of the page class as abstract and the functions that raise NotImpelemented as 'things derived classes should implement' (even if they are just no-op's). It's just a different paradigm but either way should be equivalent in this context. I don't have strong preferences either way so I can nuke the function if you prefer.

angrmanagement/ui/dialogs/preferences.py Show resolved Hide resolved
angrmanagement/utils/track_system_theme.py Outdated Show resolved Hide resolved
@@ -29,6 +29,7 @@ install_requires =
qtterm
requests[socks]
tomlkit
darkdetect-angr[macos-listener]
Copy link
Member

Choose a reason for hiding this comment

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

  • It's unfortunate that we have to maintain a forked release of darkdetect now, but I appreicate the work on it
  • Did Windows/Linux get tested?

Copy link
Member Author

Choose a reason for hiding this comment

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

The majority of the fork has a PR into the main repo, so once that is merged we might not need to hopefully. TBD. I've tested the PR'd version on all three OS's, though less throughly on Windows as I lack said OS. The version we are using is mostly the same so it ought to work. Feel free to test them yourself but the relevant logic that distinguished between OSes wasn't really the code that changed between the PR'd version and the hardfork version.

Copy link
Member

Choose a reason for hiding this comment

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

I've tested the PR'd version on all three OS's

But not the forked version with extra changes?

Feel free to test them yourself

I don't plan to test this PR. Will you please test it

Copy link
Member Author

Choose a reason for hiding this comment

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

The extra changes are copyright, README, and __version__, and pyproject.toml to change the package name. Not really the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you are curious, here is the diff stats:

 LICENSE                     |  4 ++--
 README.md                   |  8 ++++----
 darkdetect/__init__.py      |  4 ++--
 darkdetect/__main__.py      |  2 +-
 darkdetect/_dummy.py        |  2 +-
 darkdetect/_linux_detect.py |  2 +-
 docs/api.md                 |  2 +-
 docs/examples.md            |  2 +-
 pyproject.toml              | 10 +++++-----

Note the 2 line changes are copyright comments. I don't have access to a Windows device at the moment so I can't really test these changes easily, but they aren't really code changes just the changes necessary to hard-fork a project (changing the name on pypi, copyright, documentation, and version).

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not know how to automate GUI test cases on windows changing system theme and detecting of the colors properly all changed over. Feel free. The actions to test this would be launch app, open preferences, select 'Track System Theme', then toggle the Windows System Theme and visually ensure it tracks the theme.

Copy link
Member

Choose a reason for hiding this comment

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

You don't need to "visually ensure" it, you just need to make sure after the theme is changed the correct behavior occurs in the library. I'm sure applescript and powershell each have ways to adjust the system theme.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you want to write these test cases, I can tell you how to do it in applescript (via System Events), I don't know powershell. I imagine for Gnome specifically there is a gsettings option you could find? For detecting if it worked, you'll have to query the QApplication to check that all the colors and such have been updated and also ensure that any visual refresh functions have been called (i.e. redrawing the GUI app).

Copy link
Member

Choose a reason for hiding this comment

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

That's on the angr management side, but not necessary for the library itself which is is the subject of this thread.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll happily take a PR for them here: https://github.com/zwimer/darkdetect but I don't have plans to write tests myself for them at the moment. If you do PR them, I'll also merge them into the branch that is PR-ing into the original repo https://github.com/albertosottile/darkdetect so as to avoid actively diverging the hard fork from the original more than necessary; my plan is to get rid of the fork once the PR albertosottile/darkdetect#32 in the original is merged.

Right now that PR has been tested on all three OSes and my fork's master branch doesn't meaningfully diverge from said code. I know the maintainer desired to do more thorough testing before merging the PR though, so I'm sure the test cases would be appreciated by all parties.

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.

No 'current' theme Allow theme based on system preferences
3 participants