Windows: E-book viewer: Fix switching away from viewer while in fullscreen and switching back causing some corruption until the page is scrolled. Fixes #1918591 [[Viewer] Using Alt + Tab to switch programs in Windows when using the viewer in full screen, the text is adjusted as it was not in full screen](https://bugs.launchpad.net/calibre/+bug/1918591)

This commit is contained in:
Kovid Goyal 2021-04-20 11:50:17 +05:30
parent 1857483eb0
commit 09470577fe
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 22 additions and 4 deletions

View File

@ -17,7 +17,7 @@ from qt.core import (
from threading import Thread
from calibre import prints
from calibre.constants import ismacos
from calibre.constants import ismacos, iswindows
from calibre.customize.ui import available_input_formats
from calibre.db.annotations import merge_annotations
from calibre.gui2 import choose_files, error_dialog, sanitize_env_vars
@ -289,6 +289,7 @@ class EbookViewer(MainWindow):
def toggle_full_screen(self):
self.set_full_screen(not self.isFullScreen())
# }}}
# Docks (ToC, Bookmarks, Lookup, etc.) {{{
@ -743,11 +744,16 @@ class EbookViewer(MainWindow):
t.start()
def eventFilter(self, obj, ev):
if ev.type() == QEvent.Type.MouseMove:
et = ev.type()
if et == QEvent.Type.MouseMove:
if self.cursor_hidden:
self.cursor_hidden = False
QApplication.instance().restoreOverrideCursor()
self.hide_cursor_timer.start()
elif et == QEvent.Type.FocusIn:
if iswindows and obj and obj.objectName() == 'EbookViewerClassWindow' and self.isFullScreen():
# See https://bugs.launchpad.net/calibre/+bug/1918591
self.web_view.repair_after_fullscreen_switch()
return False
def hide_cursor(self):

View File

@ -291,6 +291,7 @@ class ViewerBridge(Bridge):
generic_action = to_js()
show_search_result = to_js()
prepare_for_close = to_js()
repair_after_fullscreen_switch = to_js()
viewer_font_size_changed = to_js()
tts_event = to_js()
@ -742,3 +743,6 @@ class WebView(RestartingWebEngineView):
def show_book_folder(self):
path = os.path.dirname(os.path.abspath(set_book_path.pathtoebook))
safe_open_url(QUrl.fromLocalFile(path))
def repair_after_fullscreen_switch(self):
self.execute_when_ready('repair_after_fullscreen_switch')

View File

@ -1255,11 +1255,13 @@ class View:
}
return pos
def show_status_message(self, msg):
def show_status_message(self, msg, timeout):
self.current_status_message = msg or ''
self.update_header_footer()
if self.current_status_message:
window.setTimeout(def(): self.show_status_message();, 10000)
if not timeout?:
timeout = 10000
window.setTimeout(def(): self.show_status_message();, timeout)
def create_template_renderer(self):
if not self.book:

View File

@ -283,6 +283,12 @@ def prepare_for_close():
ui_operations.close_prep_finished(None)
@from_python
def repair_after_fullscreen_switch():
if view:
view.show_status_message('...', 200)
@from_python
def viewer_font_size_changed():
if view: