From 3302d21086a02d7d34aca0af57e61bf108e7ee7d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 25 Jul 2021 15:07:26 -0400 Subject: [PATCH] Use font scaled delegate from forms module --- piker/ui/_search.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/piker/ui/_search.py b/piker/ui/_search.py index 72a1bfa6..c8d25f41 100644 --- a/piker/ui/_search.py +++ b/piker/ui/_search.py @@ -63,37 +63,21 @@ from PyQt5.QtWidgets import ( QTreeView, # QListWidgetItem, # QAbstractScrollArea, - QStyledItemDelegate, + # QStyledItemDelegate, ) from ..log import get_logger from ._style import ( _font, - DpiAwareFont, + # DpiAwareFont, ) -from ._forms import FontAndChartAwareLineEdit +from ._forms import FontAndChartAwareLineEdit, FontScaledDelegate 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): mode_name: str = 'search-nav' @@ -130,7 +114,7 @@ class CompleterView(QTreeView): self.labels = labels # a std "tabular" config - self.setItemDelegate(SimpleDelegate()) + self.setItemDelegate(FontScaledDelegate(self)) self.setModel(model) self.setAlternatingRowColors(True) # TODO: size this based on DPI font