feat(ui_builders_shared): implement def _icon_color_from_palette
This commit is contained in:
parent
3333a7f4d1
commit
1574e77a22
1 changed files with 15 additions and 0 deletions
|
|
@ -20,3 +20,18 @@ from PySide6.QtWidgets import (
|
||||||
|
|
||||||
|
|
||||||
# _icon_color_from_palette: function definition for ScanSlicer behavior.
|
# _icon_color_from_palette: function definition for ScanSlicer behavior.
|
||||||
|
def _icon_color_from_palette(palette):
|
||||||
|
if palette is None:
|
||||||
|
return "#f2f2f2"
|
||||||
|
|
||||||
|
button_text_color = palette.buttonText().color()
|
||||||
|
if button_text_color.isValid():
|
||||||
|
return button_text_color.name()
|
||||||
|
|
||||||
|
window_color = palette.window().color()
|
||||||
|
luma = (
|
||||||
|
(0.2126 * window_color.redF())
|
||||||
|
+ (0.7152 * window_color.greenF())
|
||||||
|
+ (0.0722 * window_color.blueF())
|
||||||
|
)
|
||||||
|
return "#1f1f1f" if luma >= 0.5 else "#f2f2f2"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue