ScanSlicer/scanslicer/ui_builders_shared.py

37 lines
921 B
Python

import base64
from PySide6.QtCore import QPoint, QRect, Qt
from PySide6.QtGui import QFont, QFontInfo, QIcon, QPainter, QPixmap
from PySide6.QtSvg import QSvgRenderer
from PySide6.QtWidgets import (
QComboBox,
QGridLayout,
QGroupBox,
QHBoxLayout,
QLabel,
QPushButton,
QScrollArea,
QSizePolicy,
QSlider,
QSpacerItem,
QVBoxLayout,
QWidget,
)
# _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"