Changes to eliminate the black box cover_flow startup flash due to slow

smart device driver initialization
This commit is contained in:
Charles Haley 2023-12-02 14:56:42 +00:00 committed by Kovid Goyal
parent 76ec0583df
commit 8415effd8f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 4 deletions

View File

@ -209,6 +209,11 @@ class CoverFlow(pictureflow.PictureFlow):
else: else:
super().paintEvent(ev) super().paintEvent(ev)
def resizeEvent(self, ev):
if ev.oldSize() == QSize(-1, -1):
self.created_at = time.monotonic()
super().resizeEvent(ev)
def __init__(self, parent=None): def __init__(self, parent=None):
pictureflow.PictureFlow.__init__(self, parent, pictureflow.PictureFlow.__init__(self, parent,
config['cover_flow_queue_length']+1) config['cover_flow_queue_length']+1)

View File

@ -428,7 +428,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
QTimer.singleShot(10, self.show_gui_debug_msg) QTimer.singleShot(10, self.show_gui_debug_msg)
self.iactions['Connect Share'].check_smartdevice_menus() self.iactions['Connect Share'].check_smartdevice_menus()
QTimer.singleShot(1, self.start_smartdevice)
QTimer.singleShot(100, self.update_toggle_to_tray_action) QTimer.singleShot(100, self.update_toggle_to_tray_action)
def post_initialize_actions(self, show_gui, do_hide_windows): def post_initialize_actions(self, show_gui, do_hide_windows):
@ -452,6 +451,13 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
# up with the wrong size. I don't know why. # up with the wrong size. I don't know why.
self.bd_splitter.repaint() self.bd_splitter.repaint()
# Start the smartdevice later so that the network time doesn't affect
# the gui repaint debouncing. Wait 3 seconds before starting to be sure
# that all other initialization (plugins etc) has completed. Yes, 3
# seconds is an arbitrary value and probably too long, but it will do
# until the underlying structure changes to make it unnecessary.
QTimer.singleShot(3000, self.start_smartdevice)
def start_quickview(self): def start_quickview(self):
from calibre.gui2.actions.show_quickview import get_quickview_action_plugin from calibre.gui2.actions.show_quickview import get_quickview_action_plugin
qv = get_quickview_action_plugin() qv = get_quickview_action_plugin()
@ -487,13 +493,15 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.focus_current_view() self.focus_current_view()
def start_smartdevice(self): def start_smartdevice(self):
timed_print('Starting the smartdevice driver')
message = None message = None
if self.device_manager.get_option('smartdevice', 'autostart'): if self.device_manager.get_option('smartdevice', 'autostart'):
try: try:
message = self.device_manager.start_plugin('smartdevice') message = self.device_manager.start_plugin('smartdevice')
except: timed_print('Finished starting smartdevice')
message = 'start smartdevice unknown exception' except Exception as e:
prints(message) message = str(e)
timed_print(f'Starting smartdevice driver failed: {message}')
import traceback import traceback
traceback.print_exc() traceback.print_exc()
if message: if message: