44
55
66import typing
7+ from collections .abc import Callable
78from pathlib import Path
89
910import structlog
@@ -85,7 +86,7 @@ class MainMenuBar(QMenuBar):
8586 help_menu : QMenu
8687 about_action : QAction
8788
88- def __init__ (self , parent = ... ):
89+ def __init__ (self , parent : QWidget | None = None ):
8990 super ().__init__ (parent )
9091
9192 self .setup_file_menu ()
@@ -381,8 +382,8 @@ def rebuild_open_recent_library_menu(
381382 self ,
382383 libraries : list [Path ],
383384 show_filepath : ShowFilepathOption ,
384- open_library_callback ,
385- clear_libraries_callback ,
385+ open_library_callback : Callable [[ Path ], None ] ,
386+ clear_libraries_callback : Callable [[], None ] ,
386387 ):
387388 actions : list [QAction ] = []
388389 for path in libraries :
@@ -427,9 +428,42 @@ class MainWindow(QMainWindow):
427428 (Translations ["home.thumbnail_size.mini" ], 76 ),
428429 ]
429430
430- def __init__ (self , driver : "QtDriver" , parent = None ) -> None :
431+ def __init__ (self , driver : "QtDriver" , parent : QWidget | None = None ) -> None :
431432 super ().__init__ (parent )
432433
434+ # region Type declarations for variables that will be initialized in methods
435+ # initialized in setup_search_bar
436+ self .search_bar_layout : QHBoxLayout
437+ self .back_button : QPushButton
438+ self .forward_button : QPushButton
439+ self .search_field : QLineEdit
440+ self .search_field_completion_list : QStringListModel
441+ self .search_field_completer : QCompleter
442+ self .search_button : QPushButton
443+
444+ # initialized in setup_extra_input_bar
445+ self .extra_input_layout : QHBoxLayout
446+ self .sorting_mode_combobox : QComboBox
447+ self .sorting_direction_combobox : QComboBox
448+ self .thumb_size_combobox : QComboBox
449+
450+ # initialized in setup_content
451+ self .content_layout : QHBoxLayout
452+ self .content_splitter : QSplitter
453+
454+ # initialized in setup_entry_list
455+ self .entry_list_container : QWidget
456+ self .entry_list_layout : QVBoxLayout
457+ self .entry_scroll_area : QScrollArea
458+ self .thumb_grid : QWidget
459+ self .thumb_layout : FlowLayout
460+ self .landing_widget : LandingWidget
461+ self .pagination : Pagination
462+
463+ # initialized in setup_preview_panel
464+ self .preview_panel : PreviewPanel
465+ # endregion
466+
433467 if not self .objectName ():
434468 self .setObjectName ("MainWindow" )
435469 self .resize (1300 , 720 )
@@ -596,7 +630,7 @@ def setup_entry_list(self, driver: "QtDriver"):
596630 self .entry_scroll_area .setWidgetResizable (True )
597631 self .entry_scroll_area .setHorizontalScrollBarPolicy (Qt .ScrollBarPolicy .ScrollBarAlwaysOff )
598632
599- self .thumb_grid : QWidget = QWidget ()
633+ self .thumb_grid = QWidget ()
600634 self .thumb_grid .setObjectName ("thumb_grid" )
601635 self .thumb_layout = FlowLayout ()
602636 self .thumb_layout .enable_grid_optimizations (value = True )
@@ -607,7 +641,7 @@ def setup_entry_list(self, driver: "QtDriver"):
607641
608642 self .entry_list_layout .addWidget (self .entry_scroll_area )
609643
610- self .landing_widget : LandingWidget = LandingWidget (driver , self .devicePixelRatio ())
644+ self .landing_widget = LandingWidget (driver , self .devicePixelRatio ())
611645 self .entry_list_layout .addWidget (self .landing_widget )
612646
613647 self .pagination = Pagination ()
@@ -633,14 +667,6 @@ def setup_status_bar(self):
633667
634668 # endregion
635669
636- def moveEvent (self , event ) -> None : # noqa: N802
637- # time.sleep(0.02) # sleep for 20ms
638- pass
639-
640- def resizeEvent (self , event ) -> None : # noqa: N802
641- # time.sleep(0.02) # sleep for 20ms
642- pass
643-
644670 def toggle_landing_page (self , enabled : bool ):
645671 if enabled :
646672 self .entry_scroll_area .setHidden (True )
0 commit comments