mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Consolidate the various modal overlays
This commit is contained in:
parent
763fc88171
commit
af59788c71
@ -21,6 +21,8 @@ STOPPED = 4
|
|||||||
|
|
||||||
class ReadAloud:
|
class ReadAloud:
|
||||||
|
|
||||||
|
dont_hide_on_content_loaded = True
|
||||||
|
|
||||||
def __init__(self, view):
|
def __init__(self, view):
|
||||||
self.view = view
|
self.view = view
|
||||||
self._state = HIDDEN
|
self._state = HIDDEN
|
||||||
|
@ -321,6 +321,7 @@ class View:
|
|||||||
self.selection_bar = SelectionBar(self)
|
self.selection_bar = SelectionBar(self)
|
||||||
self.read_aloud = ReadAloud(self)
|
self.read_aloud = ReadAloud(self)
|
||||||
self.hints = Hints(self)
|
self.hints = Hints(self)
|
||||||
|
self.modal_overlays = v'[self.selection_bar, self.read_aloud, self.hints]'
|
||||||
self.processing_spine_item_display = False
|
self.processing_spine_item_display = False
|
||||||
self.pending_load = None
|
self.pending_load = None
|
||||||
self.currently_showing = {'selection': {'empty': True}}
|
self.currently_showing = {'selection': {'empty': True}}
|
||||||
@ -457,9 +458,8 @@ class View:
|
|||||||
if ui_operations.overlay_visibility_changed:
|
if ui_operations.overlay_visibility_changed:
|
||||||
ui_operations.overlay_visibility_changed(visible)
|
ui_operations.overlay_visibility_changed(visible)
|
||||||
if visible:
|
if visible:
|
||||||
self.selection_bar.hide()
|
for x in self.modal_overlays:
|
||||||
self.read_aloud.hide()
|
x.hide()
|
||||||
self.hints.hide()
|
|
||||||
else:
|
else:
|
||||||
self.selection_bar.update_position()
|
self.selection_bar.update_position()
|
||||||
|
|
||||||
@ -679,18 +679,16 @@ class View:
|
|||||||
self.focus_iframe()
|
self.focus_iframe()
|
||||||
|
|
||||||
def focus_iframe(self):
|
def focus_iframe(self):
|
||||||
if self.selection_bar.is_visible:
|
for x in self.modal_overlays:
|
||||||
self.selection_bar.focus()
|
if x.is_visible:
|
||||||
elif self.read_aloud.is_visible:
|
x.focus()
|
||||||
self.read_aloud.focus()
|
return
|
||||||
elif self.hints.is_visible:
|
|
||||||
self.hints.focus()
|
|
||||||
else:
|
|
||||||
self.iframe.contentWindow.focus()
|
self.iframe.contentWindow.focus()
|
||||||
|
|
||||||
def start_read_aloud(self, dont_start_talking):
|
def start_read_aloud(self, dont_start_talking):
|
||||||
self.selection_bar.hide()
|
for x in self.modal_overlays:
|
||||||
self.hints.hide()
|
if x is not self.read_aloud:
|
||||||
|
x.hide()
|
||||||
self.read_aloud.show()
|
self.read_aloud.show()
|
||||||
if not dont_start_talking:
|
if not dont_start_talking:
|
||||||
self.read_aloud.play()
|
self.read_aloud.play()
|
||||||
@ -705,8 +703,9 @@ class View:
|
|||||||
if self.hints.is_visible:
|
if self.hints.is_visible:
|
||||||
self.hints.hide()
|
self.hints.hide()
|
||||||
else:
|
else:
|
||||||
self.selection_bar.hide()
|
for x in self.modal_overlays:
|
||||||
self.read_aloud.hide()
|
if x is not self.hints:
|
||||||
|
x.hide()
|
||||||
self.hints.show()
|
self.hints.show()
|
||||||
|
|
||||||
def show_chrome(self, data):
|
def show_chrome(self, data):
|
||||||
@ -1306,7 +1305,9 @@ class View:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_content_loaded(self, data):
|
def on_content_loaded(self, data):
|
||||||
self.selection_bar.hide()
|
for x in self.modal_overlays:
|
||||||
|
if not x.dont_hide_on_content_loaded:
|
||||||
|
x.hide()
|
||||||
self.processing_spine_item_display = False
|
self.processing_spine_item_display = False
|
||||||
self.currently_showing.loading = False
|
self.currently_showing.loading = False
|
||||||
self.hide_loading()
|
self.hide_loading()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user