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
# search widget is a singleton alongside the godwidget
search = _search.SearchWidget(godwidget=godwidget)
search.bar.unfocus()
godwidget.hbox.addWidget(search)
# search.bar.unfocus()
# godwidget.hbox.addWidget(search)
godwidget.search = search
symbol, _, provider = sym.rpartition('.')

View File

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

View File

@ -866,7 +866,8 @@ async def display_symbol_data(
feed.hist_shm,
# in the case of history chart we explicitly set `False`
# to avoid internal pane creation.
sidepane=False,
# sidepane=False,
sidepane=godwidget.search,
)
# don't show when not focussed
hist_linked.cursor.always_show_xlabel = False
@ -1037,6 +1038,7 @@ async def display_symbol_data(
await trio.sleep(0)
rt_linked.resize_sidepanes()
rt_linked.set_split_sizes()
hist_linked.resize_sidepanes(from_linked=rt_linked)
# NOTE: we pop the volume chart from the subplots set so
# 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,
}
):
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
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
async def on_pressed(self, idx: QModelIndex) -> None:
'''Mouse pressed on view handler.
'''
Mouse pressed on view handler.
'''
search = self.parent()
@ -555,16 +556,24 @@ class SearchWidget(QtWidgets.QWidget):
def focus(self) -> None:
godw = self.godwidget
if self.view.model().rowCount(QModelIndex()) == 0:
# fill cache list if nothing existing
self.view.set_section_entries(
'cache',
list(reversed(self.godwidget._chart_cache)),
list(reversed(godw._chart_cache)),
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.bar.focus()
def get_current_item(self) -> Optional[tuple[str, str]]:
'''Return the current completer tree selection as
@ -603,7 +612,8 @@ class SearchWidget(QtWidgets.QWidget):
clear_to_cache: bool = True,
) -> 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.
Return any loaded symbol.
@ -650,6 +660,8 @@ class SearchWidget(QtWidgets.QWidget):
clear_all=True,
)
self.focus()
self.bar.focus()
return fqsn
@ -717,10 +729,11 @@ async def fill_results(
max_pause_time: float = 6/16 + 0.001,
) -> None:
"""Task to search through providers and fill in possible
'''
Task to search through providers and fill in possible
completion results.
"""
'''
global _search_active, _search_enabled, _searcher_cache
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_Alt,
}:
search.bar.unfocus()
#bar.unfocus()
# kill the search and focus back on main chart
if godwidget: