Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Qt5Agg support darkmode icon by using svg#30565

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
LangQi99 wants to merge13 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromLangQi99:qt5icon

Conversation

LangQi99
Copy link
Contributor

@LangQi99LangQi99 commentedSep 16, 2025
edited
Loading

PR summary

Addresses issue#27590

I noticed in a screenshot from another PR that out of the six backends displayed, only the Qt5Agg icon fails to adapt to dark mode. It remains black and blends in with the background, making it difficult to distinguish.

Old behavior
image

New behavior
image

Old behavior
image

New behavior
image

PR checklist

@LangQi99LangQi99 marked this pull request as ready for reviewSeptember 16, 2025 03:03
@LangQi99LangQi99 marked this pull request as draftSeptember 16, 2025 04:25
@LangQi99LangQi99 changed the titlefix: Qt5Agg support darkmode iconfix: Qt5Agg support darkmode icon by using svgSep 16, 2025
@LangQi99LangQi99 marked this pull request as ready for reviewSeptember 16, 2025 07:52
@timhoffm
Copy link
Member

Not sure, but would using aQIconEngine remove the need for a manual refresh? As far as I read it, the engine could provide the right-sized image on demand (pull principle), instead of explicitly updating on a dpi-change event (push principle).

LangQi99 reacted with thumbs up emoji

Comment on lines 740 to 744
def_render_svg(self,svg_path,pixmap,size,dpr):
"""Render SVG content to pixmap."""
QSvgRenderer=qt_compat.get_qsvg_renderer()
ifQSvgRendererisNone:
returnQtGui.QPixmap()
Copy link
Member

Choose a reason for hiding this comment

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

I find the logic not quite clean. You passpixmap and sometimes return that pixmap with something rendered into, and sometimes you return a different pixmap. I'd rather have that we either only draw into the pixmap (and then do not need to return anything, or that we change to_create_pixmap_from_* and not pass a pixmap in.

LangQi99 reacted with eyes emoji
Comment on lines 712 to 713
# Get the current device pixel ratio
dpr= (self.toolbar.devicePixelRatioF()or1)ifself.toolbarelse1
Copy link
Member

Choose a reason for hiding this comment

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

Idea for further simplification:

move this into a private function_devicePixelRatio().

Then ...

Comment on lines 718 to 726
returnself._create_pixmap_from_svg(svg_path,size,dpr)
else:
large_path=self.image_path.with_name(self.image_path.stem+'_large.png')
path=large_pathiflarge_path.exists()elseself.image_path
scaled_size=QtCore.QSize(
int(size.width()*dpr),
int(size.height()*dpr)
)
returnself._create_pixmap_from_png(path,scaled_size,dpr)
Copy link
Member

Choose a reason for hiding this comment

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

Interpretsize as logical display size for the scope of this function and hide the calculation of the physical size fully inside the_create_pixmap_from_* functions, usingself._devicePixelRatio() in there.

This reduces here to

Suggested change
returnself._create_pixmap_from_svg(svg_path,size,dpr)
else:
large_path=self.image_path.with_name(self.image_path.stem+'_large.png')
path=large_pathiflarge_path.exists()elseself.image_path
scaled_size=QtCore.QSize(
int(size.width()*dpr),
int(size.height()*dpr)
)
returnself._create_pixmap_from_png(path,scaled_size,dpr)
returnself._create_pixmap_from_svg(svg_path,size)
else:
returnself._create_pixmap_from_png(self.image_path,size)

All the type-dependent implementation details (dpi handling, using a possibly available_large PNG image) are then hidden in the respective function.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks for your patient feedback and guidance. I've really learned a lot from it.💡

timhoffm reacted with heart emoji
Copy link
Member

Choose a reason for hiding this comment

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

@LangQi99 thanks as well for the patience to go through the sequence of review cycles! We try to keep them low, but in this case, the proper solution only revealed itself step-by-step. But maybe seeing the evolution of thoughts is also instructive 😃.

LangQi99 reacted with heart emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@QuLogicQuLogicQuLogic left review comments

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@LangQi99@timhoffm@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp