Skip to content

feat: support icon color - followup#277

Open
brisvag wants to merge 16 commits intopyapp-kit:mainfrom
brisvag:icon-color
Open

feat: support icon color - followup#277
brisvag wants to merge 16 commits intopyapp-kit:mainfrom
brisvag:icon-color

Conversation

@brisvag
Copy link
Copy Markdown

@brisvag brisvag commented Apr 3, 2026

Trying to pick up #130!

I fixed conflicts and brought it up to date. @tlambert03 was there something specific with that PR that was incomplete or you wanted to finish?

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 84.78261% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.27%. Comparing base (7f1e493) to head (17b44e0).

Files with missing lines Patch % Lines
src/app_model/types/_icon.py 66.66% 4 Missing ⚠️
src/app_model/_app.py 66.66% 3 Missing ⚠️

❌ Your patch check has failed because the patch coverage (84.78%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #277      +/-   ##
==========================================
- Coverage   99.62%   99.27%   -0.36%     
==========================================
  Files          31       31              
  Lines        1878     1918      +40     
==========================================
+ Hits         1871     1904      +33     
- Misses          7       14       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tlambert03
Copy link
Copy Markdown
Member

@brisvag, I think the main reason that PR stalled is because of the problem with theme changes. as mentioned in the first comment:

note that svg-colored icons don't currently change if the parent style sheet changes. This is just a generally harder thing to solve (and one of the few benefits of font-icons). However, we could, as magicgui does, attach QPallete change events here and auto-change icon colors in a future PR.

so, currently here:

  app = Application("myapp")
  app.theme_mode = "dark"  # or let it auto-detect

  Action(
      id="my.action",
      title="Do Thing",
      icon={"dark": "mdi:some-icon", "color_dark": "#FFFFFF", "color_light": "#000000"},
      ...
  )

The icon color is resolved once — at the moment the QAction or QMenuSubMenu is constructed. The resulting QIcon is a static pixmap/SVG baked with whatever color was chosen at creation time. If the user later, changes app.theme_mode from "dark" to "light", or wwitches their OS/Qt theme (causing the QPalette to change), nothing re-runs to_qicon(). The icons stay the old color. There's no signal, no QPalette change event listener, no theme_mode change signal — nothing triggers a re-render.

so, it feels like a partially implemented thing that will pretty quickly have a bug report or feature request

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants