WIP search pane always shown..

history_view
Tyler Goodlet 2022-09-07 17:50:10 -04:00
parent 1fa6e8d9ba
commit addedc20f1
5 changed files with 63 additions and 17 deletions

View File

@ -107,9 +107,8 @@ async def _async_main(
# setup search widget and focus main chart view at startup # setup search widget and focus main chart view at startup
# search widget is a singleton alongside the godwidget # search widget is a singleton alongside the godwidget
search = _search.SearchWidget(godwidget=godwidget) search = _search.SearchWidget(godwidget=godwidget)
search.bar.unfocus() # search.bar.unfocus()
# godwidget.hbox.addWidget(search)
godwidget.hbox.addWidget(search)
godwidget.search = search godwidget.search = search
symbol, _, provider = sym.rpartition('.') symbol, _, provider = sym.rpartition('.')

View File

@ -72,6 +72,7 @@ from ._forms import FieldsForm
from .._profile import pg_profile_enabled, ms_slower_then from .._profile import pg_profile_enabled, ms_slower_then
from ._overlay import PlotItemOverlay from ._overlay import PlotItemOverlay
from ._flows import Flow from ._flows import Flow
from ._search import SearchWidget
if TYPE_CHECKING: if TYPE_CHECKING:
from ._display import DisplayState from ._display import DisplayState
@ -89,6 +90,8 @@ class GodWidget(QWidget):
modify them. modify them.
''' '''
search: SearchWidget
def __init__( def __init__(
self, self,
@ -98,6 +101,8 @@ class GodWidget(QWidget):
super().__init__(parent) super().__init__(parent)
self.search: Optional[SearchWidget] = None
self.hbox = QHBoxLayout(self) self.hbox = QHBoxLayout(self)
self.hbox.setContentsMargins(0, 0, 0, 0) self.hbox.setContentsMargins(0, 0, 0, 0)
self.hbox.setSpacing(6) self.hbox.setSpacing(6)
@ -239,6 +244,7 @@ class GodWidget(QWidget):
linked.show() linked.show()
linked.focus() linked.focus()
self.search.focus()
await trio.sleep(0) await trio.sleep(0)
else: else:
@ -352,6 +358,17 @@ class ChartnPane(QFrame):
hbox.setContentsMargins(0, 0, 0, 0) hbox.setContentsMargins(0, 0, 0, 0)
hbox.setSpacing(3) hbox.setSpacing(3)
def set_sidepane(
self,
sidepane: FieldsForm,
) -> None:
# add sidepane **after** chart; place it on axis side
self.hbox.addWidget(
sidepane,
alignment=Qt.AlignTop
)
class LinkedSplits(QWidget): class LinkedSplits(QWidget):
''' '''
@ -583,10 +600,11 @@ class LinkedSplits(QWidget):
assert cpw.parent() == qframe assert cpw.parent() == qframe
# add sidepane **after** chart; place it on axis side # add sidepane **after** chart; place it on axis side
qframe.hbox.addWidget( qframe.set_sidepane(sidepane)
sidepane, # qframe.hbox.addWidget(
alignment=Qt.AlignTop # sidepane,
) # alignment=Qt.AlignTop
# )
cpw.sidepane = sidepane cpw.sidepane = sidepane
@ -681,19 +699,31 @@ class LinkedSplits(QWidget):
def resize_sidepanes( def resize_sidepanes(
self, self,
from_linked: Optional[LinkedSplits] = None,
) -> None: ) -> None:
''' '''
Size all sidepanes based on the OHLC "main" plot and its Size all sidepanes based on the OHLC "main" plot and its
sidepane width. sidepane width.
''' '''
main_chart = self.chart if from_linked:
main_chart = from_linked.chart
else:
main_chart = self.chart
if main_chart and main_chart.sidepane: if main_chart and main_chart.sidepane:
sp_w = main_chart.sidepane.width() sp_w = main_chart.sidepane.width()
for name, cpw in self.subplots.items(): for name, cpw in self.subplots.items():
cpw.sidepane.setMinimumWidth(sp_w) cpw.sidepane.setMinimumWidth(sp_w)
cpw.sidepane.setMaximumWidth(sp_w) cpw.sidepane.setMaximumWidth(sp_w)
if from_linked:
self.chart.sidepane.setMinimumWidth(sp_w)
self.chart.sidepane.setMaximumWidth(sp_w)
else:
self.godwidget.hist_linked.resize_sidepanes(from_linked=self)
class ChartPlotWidget(pg.PlotWidget): class ChartPlotWidget(pg.PlotWidget):
''' '''

View File

@ -866,7 +866,8 @@ async def display_symbol_data(
feed.hist_shm, feed.hist_shm,
# in the case of history chart we explicitly set `False` # in the case of history chart we explicitly set `False`
# to avoid internal pane creation. # to avoid internal pane creation.
sidepane=False, # sidepane=False,
sidepane=godwidget.search,
) )
# don't show when not focussed # don't show when not focussed
hist_linked.cursor.always_show_xlabel = False hist_linked.cursor.always_show_xlabel = False
@ -1037,6 +1038,7 @@ async def display_symbol_data(
await trio.sleep(0) await trio.sleep(0)
rt_linked.resize_sidepanes() rt_linked.resize_sidepanes()
rt_linked.set_split_sizes() rt_linked.set_split_sizes()
hist_linked.resize_sidepanes(from_linked=rt_linked)
# NOTE: we pop the volume chart from the subplots set so # NOTE: we pop the volume chart from the subplots set so
# that it isn't double rendered in the display loop # that it isn't double rendered in the display loop

View File

@ -141,7 +141,9 @@ async def handle_viewmode_kb_inputs(
Qt.Key_Space, Qt.Key_Space,
} }
): ):
view._chart.linked.godwidget.search.focus() godw = view._chart.linked.godwidget
godw.search.focus()
# godw.hist_linked.resize_sidepanes(from_linked=godw.rt_linked)
# esc and ctrl-c # esc and ctrl-c
if key == Qt.Key_Escape or (ctrl and key == Qt.Key_C): if key == Qt.Key_Escape or (ctrl and key == Qt.Key_C):

View File

@ -140,7 +140,8 @@ class CompleterView(QTreeView):
self._font_size: int = 0 # pixels self._font_size: int = 0 # pixels
async def on_pressed(self, idx: QModelIndex) -> None: async def on_pressed(self, idx: QModelIndex) -> None:
'''Mouse pressed on view handler. '''
Mouse pressed on view handler.
''' '''
search = self.parent() search = self.parent()
@ -555,16 +556,24 @@ class SearchWidget(QtWidgets.QWidget):
def focus(self) -> None: def focus(self) -> None:
godw = self.godwidget
if self.view.model().rowCount(QModelIndex()) == 0: if self.view.model().rowCount(QModelIndex()) == 0:
# fill cache list if nothing existing # fill cache list if nothing existing
self.view.set_section_entries( self.view.set_section_entries(
'cache', 'cache',
list(reversed(self.godwidget._chart_cache)), list(reversed(godw._chart_cache)),
clear_all=True, clear_all=True,
) )
self.bar.focus() hist_linked = godw.hist_linked
hist_chart = hist_linked.chart
if hist_chart:
rt_linked = godw.rt_linked
hist_chart.qframe.set_sidepane(self)
hist_linked.resize_sidepanes(from_linked=rt_linked)
self.show() self.show()
self.bar.focus()
def get_current_item(self) -> Optional[tuple[str, str]]: def get_current_item(self) -> Optional[tuple[str, str]]:
'''Return the current completer tree selection as '''Return the current completer tree selection as
@ -603,7 +612,8 @@ class SearchWidget(QtWidgets.QWidget):
clear_to_cache: bool = True, clear_to_cache: bool = True,
) -> Optional[str]: ) -> Optional[str]:
'''Attempt to load and switch the current selected '''
Attempt to load and switch the current selected
completion result to the affiliated chart app. completion result to the affiliated chart app.
Return any loaded symbol. Return any loaded symbol.
@ -650,6 +660,8 @@ class SearchWidget(QtWidgets.QWidget):
clear_all=True, clear_all=True,
) )
self.focus()
self.bar.focus()
return fqsn return fqsn
@ -717,10 +729,11 @@ async def fill_results(
max_pause_time: float = 6/16 + 0.001, max_pause_time: float = 6/16 + 0.001,
) -> None: ) -> None:
"""Task to search through providers and fill in possible '''
Task to search through providers and fill in possible
completion results. completion results.
""" '''
global _search_active, _search_enabled, _searcher_cache global _search_active, _search_enabled, _searcher_cache
bar = search.bar bar = search.bar
@ -892,7 +905,7 @@ async def handle_keyboard_input(
Qt.Key_Space, # i feel like this is the "native" one Qt.Key_Space, # i feel like this is the "native" one
Qt.Key_Alt, Qt.Key_Alt,
}: }:
search.bar.unfocus() #bar.unfocus()
# kill the search and focus back on main chart # kill the search and focus back on main chart
if godwidget: if godwidget: