Use font scaled delegate from forms module
parent
5ec00ee762
commit
d1244608bd
|
@ -63,37 +63,21 @@ from PyQt5.QtWidgets import (
|
||||||
QTreeView,
|
QTreeView,
|
||||||
# QListWidgetItem,
|
# QListWidgetItem,
|
||||||
# QAbstractScrollArea,
|
# QAbstractScrollArea,
|
||||||
QStyledItemDelegate,
|
# QStyledItemDelegate,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
from ..log import get_logger
|
from ..log import get_logger
|
||||||
from ._style import (
|
from ._style import (
|
||||||
_font,
|
_font,
|
||||||
DpiAwareFont,
|
# DpiAwareFont,
|
||||||
)
|
)
|
||||||
from ._forms import FontAndChartAwareLineEdit
|
from ._forms import FontAndChartAwareLineEdit, FontScaledDelegate
|
||||||
|
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SimpleDelegate(QStyledItemDelegate):
|
|
||||||
"""
|
|
||||||
Super simple view delegate to render text in the same
|
|
||||||
font size as the search widget.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
parent=None,
|
|
||||||
font: DpiAwareFont = _font,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(parent)
|
|
||||||
self.dpi_font = font
|
|
||||||
|
|
||||||
|
|
||||||
class CompleterView(QTreeView):
|
class CompleterView(QTreeView):
|
||||||
|
|
||||||
mode_name: str = 'search-nav'
|
mode_name: str = 'search-nav'
|
||||||
|
@ -130,7 +114,7 @@ class CompleterView(QTreeView):
|
||||||
self.labels = labels
|
self.labels = labels
|
||||||
|
|
||||||
# a std "tabular" config
|
# a std "tabular" config
|
||||||
self.setItemDelegate(SimpleDelegate())
|
self.setItemDelegate(FontScaledDelegate(self))
|
||||||
self.setModel(model)
|
self.setModel(model)
|
||||||
self.setAlternatingRowColors(True)
|
self.setAlternatingRowColors(True)
|
||||||
# TODO: size this based on DPI font
|
# TODO: size this based on DPI font
|
||||||
|
|
Loading…
Reference in New Issue