Implement the pixmap mask hack for long/short pp icons
parent
3de4b9afbb
commit
66199bfe6f
|
@ -26,7 +26,9 @@ from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QStyle
|
from PyQt5.QtWidgets import QStyle
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import (
|
||||||
|
QIcon, QPixmap, QColor
|
||||||
|
)
|
||||||
from pyqtgraph import functions as fn
|
from pyqtgraph import functions as fn
|
||||||
|
|
||||||
from ._annotate import LevelMarker
|
from ._annotate import LevelMarker
|
||||||
|
@ -40,7 +42,7 @@ from ..data._normalize import iterticks
|
||||||
from ..data.feed import Feed
|
from ..data.feed import Feed
|
||||||
from ._label import Label
|
from ._label import Label
|
||||||
from ._lines import LevelLine, order_line
|
from ._lines import LevelLine, order_line
|
||||||
from ._style import _font
|
from ._style import _font, hcolor
|
||||||
from ._forms import FieldsForm, FillStatusBar, QLabel
|
from ._forms import FieldsForm, FillStatusBar, QLabel
|
||||||
from ..log import get_logger
|
from ..log import get_logger
|
||||||
|
|
||||||
|
@ -114,8 +116,8 @@ async def display_pnl(
|
||||||
# https://www.pythonguis.com/faq/built-in-qicons-pyqt/
|
# https://www.pythonguis.com/faq/built-in-qicons-pyqt/
|
||||||
# account status icons taken from built-in set
|
# account status icons taken from built-in set
|
||||||
_icon_names: dict[str, str] = {
|
_icon_names: dict[str, str] = {
|
||||||
# 'connected': 'SP_DialogYesButton',
|
# these two seem to work for our mask hack done below to
|
||||||
'unavailable': 'SP_DockWidgetCloseButton',
|
# change the coloring.
|
||||||
'long_pp': 'SP_TitleBarShadeButton',
|
'long_pp': 'SP_TitleBarShadeButton',
|
||||||
'short_pp': 'SP_TitleBarUnshadeButton',
|
'short_pp': 'SP_TitleBarUnshadeButton',
|
||||||
'ready': 'SP_MediaPlay',
|
'ready': 'SP_MediaPlay',
|
||||||
|
@ -123,7 +125,6 @@ _icon_names: dict[str, str] = {
|
||||||
_icons: dict[str, QIcon] = {}
|
_icons: dict[str, QIcon] = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class SettingsPane:
|
class SettingsPane:
|
||||||
'''Composite set of widgets plus an allocator model for configuring
|
'''Composite set of widgets plus an allocator model for configuring
|
||||||
|
@ -156,18 +157,39 @@ class SettingsPane:
|
||||||
if not _icons:
|
if not _icons:
|
||||||
# load account selection using current style
|
# load account selection using current style
|
||||||
for name, icon_name in _icon_names.items():
|
for name, icon_name in _icon_names.items():
|
||||||
pixmap = getattr(QStyle, icon_name)
|
|
||||||
|
|
||||||
# TODO: set color to our default pp color
|
stdpixmap = getattr(QStyle, icon_name)
|
||||||
# https://stackoverflow.com/questions/13350631/simple-color-fill-qicons-in-qt
|
stdicon = form.style().standardIcon(stdpixmap)
|
||||||
# mask = pixmap.createMaskFromColor(
|
combo = form.fields['account']
|
||||||
# QColor('transparent'),
|
size = combo.iconSize()
|
||||||
# Qt.MaskOutColor
|
pixmap = stdicon.pixmap(combo.iconSize())
|
||||||
# )
|
|
||||||
# pixmap.fill((QColor(hcolor('default_light'))))
|
|
||||||
# pixmap.setMask(mask)
|
|
||||||
|
|
||||||
_icons[name] = form.style().standardIcon(pixmap)
|
# fill hack from SO to change icon color:
|
||||||
|
# https://stackoverflow.com/a/38369468
|
||||||
|
out_pixmap = QPixmap(size)
|
||||||
|
out_pixmap.fill(QColor(hcolor('default_spotlight')))
|
||||||
|
out_pixmap.setMask(pixmap.createHeuristicMask())
|
||||||
|
|
||||||
|
# TODO: not idea why this doesn't work / looks like
|
||||||
|
# trash. Sure would be nice to just generate our own
|
||||||
|
# pixmaps on the fly..
|
||||||
|
# p = QPainter(out_pixmap)
|
||||||
|
# p.setOpacity(1)
|
||||||
|
# p.setBrush(QColor(hcolor('papas_special')))
|
||||||
|
# p.setPen(QColor(hcolor('default_lightest')))
|
||||||
|
# path = mk_marker_path(style='|<')
|
||||||
|
# p.scale(6, 6)
|
||||||
|
# # p.translate(0, 0)
|
||||||
|
# p.drawPath(path)
|
||||||
|
# p.save()
|
||||||
|
# p.end()
|
||||||
|
# del p
|
||||||
|
# icon = QIcon(out_pixmap)
|
||||||
|
|
||||||
|
icon = QIcon()
|
||||||
|
icon.addPixmap(out_pixmap)
|
||||||
|
|
||||||
|
_icons[name] = icon
|
||||||
|
|
||||||
acct_select = form.fields['account']
|
acct_select = form.fields['account']
|
||||||
keys = list(keys or acct_select._items.keys())
|
keys = list(keys or acct_select._items.keys())
|
||||||
|
|
Loading…
Reference in New Issue