11from __future__ import annotations
2- from typing import Callable
3- from PyQt5 import QtCore , QtWidgets
4- from ..utils import separator , get_icon
2+ from PyQt5 import QtCore , QtWidgets , QtGui
3+ from ..utils import separator , get_icon , tr
54from ..views .filesystem_widget import (
65 MultipleFilesystemWidget ,
76 SingleFilesystemWidget ,
87 FilesystemTitle ,
98)
109from itertools import zip_longest
1110from ..application import GMCArguments
11+ from ..mdi_area import MdiArea
1212
1313Qt = QtCore .Qt
14- tr : Callable [[str ], str ] = lambda text : QtCore .QCoreApplication .translate (
15- "@default" , text
16- )
1714
1815
1916class MultipleSourcesOneDestination :
2017 NSOURCES = 2
2118 SOURCE_TITLES = ["First Image" , "Second Image" ]
2219
2320 @classmethod
24- def create_data_widget (cls , mdi_area , settings , extra_args : GMCArguments ):
25- def _on_open_src (view_idx , new_tab ):
21+ def create_data_widget (
22+ cls , mdi_area : MdiArea , settings , extra_args : GMCArguments
23+ ):
24+ def _on_open_src (view_idx : int , new_tab : bool ) -> None :
2625 view = cls ._source_widget .views ()[view_idx ]
2726 dst_dir = cls ._destination_widget .get_root_qdir ()
2827 if dst_dir is None :
@@ -50,15 +49,15 @@ def _on_open_src(view_idx, new_tab):
5049 )
5150 new_tab = True
5251
53- def _on_open_dst (self , new = False ):
54- def selected_files (root_path ):
52+ def _on_open_dst (self , new : bool = False ) -> None :
53+ def selected_files (root_path : QtCore . QFileInfo ):
5554 for path in self ._destination_view .selected_files_relative :
5655 path = path [: - len (".json" )]
5756 yield root_path .filePath (path )
5857
5958 self ._on_open (selected_files , new )
6059
61- def _on_view_dst_file ():
60+ def _on_view_dst_file () -> None :
6261 for path in cls ._destination_widget .view ().selected_files ():
6362 f = QtCore .QFile (path )
6463 if not f .open (f .ReadOnly | f .Text ):
@@ -139,7 +138,7 @@ def _on_view_dst_file():
139138 return splitter
140139
141140 @classmethod
142- def save_settings (cls , settings ):
141+ def save_settings (cls , settings ) -> None :
143142 settings .setValue (
144143 cls .__name__ + "_src_dir" , cls ._source_widget .get_root_string ()
145144 )
@@ -172,7 +171,9 @@ def __init__(self, schema):
172171 self ._all_files = [None ] * schema .NSOURCES
173172 self ._idx = [None ] * schema .NSOURCES
174173
175- def _create_go_actions (self , n , actions_name , actions , icon , where ):
174+ def _create_go_actions (
175+ self , n : int , actions_name : str , actions , icon : QtGui .QIcon , where : int
176+ ):
176177 for idx , (caption , shortcuts ) in zip_longest (
177178 range (n ), actions , fillvalue = (actions_name , None )
178179 ):
@@ -186,7 +187,7 @@ def _create_go_actions(self, n, actions_name, actions, icon, where):
186187 shortcuts and action .setShortcuts (shortcuts )
187188 yield action
188189
189- def _get_default_actions (self , n ):
190+ def _get_default_actions (self , n : int ):
190191 """:returns: actions, every markup window should have."""
191192 prev_shortcuts = (
192193 (
@@ -240,7 +241,14 @@ def _get_default_actions(self, n):
240241 ):
241242 yield prev_action , next_action , separator (self ), save_action
242243
243- def open_current (self , view_idx , dst_dir , src_dir , file_path , all_files ):
244+ def open_current (
245+ self ,
246+ view_idx : int ,
247+ dst_dir : QtCore .QDir ,
248+ src_dir : QtCore .QDir ,
249+ file_path : str ,
250+ all_files ,
251+ ) -> None :
244252 """The function is "public" only because it fixes focus issue."""
245253 self ._dst_dir = dst_dir
246254 self ._all_files [view_idx ] = all_files
0 commit comments