mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Changes to eliminate the black box cover_flow startup flash due to slow
smart device driver initialization
This commit is contained in:
		
							parent
							
								
									76ec0583df
								
							
						
					
					
						commit
						8415effd8f
					
				@ -209,6 +209,11 @@ class CoverFlow(pictureflow.PictureFlow):
 | 
			
		||||
        else:
 | 
			
		||||
            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):
 | 
			
		||||
        pictureflow.PictureFlow.__init__(self, parent,
 | 
			
		||||
                            config['cover_flow_queue_length']+1)
 | 
			
		||||
 | 
			
		||||
@ -428,7 +428,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin,  # {{{
 | 
			
		||||
            QTimer.singleShot(10, self.show_gui_debug_msg)
 | 
			
		||||
 | 
			
		||||
        self.iactions['Connect Share'].check_smartdevice_menus()
 | 
			
		||||
        QTimer.singleShot(1, self.start_smartdevice)
 | 
			
		||||
        QTimer.singleShot(100, self.update_toggle_to_tray_action)
 | 
			
		||||
 | 
			
		||||
    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.
 | 
			
		||||
        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):
 | 
			
		||||
        from calibre.gui2.actions.show_quickview import get_quickview_action_plugin
 | 
			
		||||
        qv = get_quickview_action_plugin()
 | 
			
		||||
@ -487,13 +493,15 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin,  # {{{
 | 
			
		||||
        self.focus_current_view()
 | 
			
		||||
 | 
			
		||||
    def start_smartdevice(self):
 | 
			
		||||
        timed_print('Starting the smartdevice driver')
 | 
			
		||||
        message = None
 | 
			
		||||
        if self.device_manager.get_option('smartdevice', 'autostart'):
 | 
			
		||||
            try:
 | 
			
		||||
                message = self.device_manager.start_plugin('smartdevice')
 | 
			
		||||
            except:
 | 
			
		||||
                message = 'start smartdevice unknown exception'
 | 
			
		||||
                prints(message)
 | 
			
		||||
                timed_print('Finished starting smartdevice')
 | 
			
		||||
            except Exception as e:
 | 
			
		||||
                message = str(e)
 | 
			
		||||
                timed_print(f'Starting smartdevice driver failed: {message}')
 | 
			
		||||
                import traceback
 | 
			
		||||
                traceback.print_exc()
 | 
			
		||||
        if message:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user