Coverage for graphica/gui/shell/icons.py: 100.0%

13 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-12 16:38 +0000

1"""上部バー・帯のアイコン。色はテーマのトークンで焼き込むので、テーマを替えたら作り直す(refresh_*)。""" 

2from PySide6.QtCore import QSize 

3from PySide6.QtGui import QIcon 

4 

5from graphica.gui import theme 

6from graphica.gui.icon_utils import icon 

7 

8 

9def themed_icon(name, size=18, token="text_secondary"): 

10 return icon(name, color=theme.current_tokens()[token], size=size) 

11 

12 

13def checkable_icon(name, size=20, off_token="text_secondary", on_token="on_accent"): 

14 """押していないときと押したとき(強調の色で塗った上)で色を変えるアイコン。""" 

15 tokens = theme.current_tokens() 

16 result = QIcon() 

17 for state, token in ((QIcon.State.Off, off_token), (QIcon.State.On, on_token)): 

18 pixmap = icon(name, color=tokens[token], size=size).pixmap(QSize(size, size)) 

19 result.addPixmap(pixmap, QIcon.Mode.Normal, state) 

20 return result