1414from convert2ebrl .settings .keys import CONVERSION_LAST_DIR as LAST_DIR_SETTING_KEY
1515from convert2ebrl .widgets import FilePickerWidget
1616
17- # noinspection PyUnresolvedReferences
18- from __feature__ import snake_case , true_property
19-
2017class ConversionGeneralSettingsWidget (QWidget ):
2118 inputBrfChanged = Signal (str )
2219 imagesDirectoryChanged = Signal (str )
@@ -26,47 +23,47 @@ def __init__(self, parent: QObject | None = None):
2623 super ().__init__ (parent )
2724 layout = QFormLayout (self )
2825 self ._input_type_combo = QComboBox ()
29- self ._input_type_combo .editable = False
30- self ._input_type_combo .add_items (["List of BRF" , "Directory of BRF" ])
31- layout .add_row ("Input type" , self ._input_type_combo )
26+ self ._input_type_combo .setEditable ( False )
27+ self ._input_type_combo .addItems (["List of BRF" , "Directory of BRF" ])
28+ layout .addRow ("Input type" , self ._input_type_combo )
3229 self ._input_brf_edit = FilePickerWidget (self ._get_input_brf_from_user )
33- layout .add_row ("Input BRF" , self ._input_brf_edit )
30+ layout .addRow ("Input BRF" , self ._input_brf_edit )
3431 self ._include_images_checkbox = QCheckBox ()
35- layout .add_row ("Include images" , self ._include_images_checkbox )
32+ layout .addRow ("Include images" , self ._include_images_checkbox )
3633
3734 def get_images_dir_from_user (x ) -> list [str ]:
3835 settings = QSettings ()
3936 default_dir = str (settings .value (LAST_DIR_SETTING_KEY , DEFAULT_LAST_DIR ))
40- image_dir = QFileDialog .get_existing_directory (parent = x , dir = default_dir )
37+ image_dir = QFileDialog .getExistingDirectory (parent = x , dir = default_dir )
4138 if image_dir :
42- settings .set_value (LAST_DIR_SETTING_KEY , image_dir )
39+ settings .setValue (LAST_DIR_SETTING_KEY , image_dir )
4340 return [image_dir ]
4441
4542 self ._image_dir_edit = FilePickerWidget (
4643 get_images_dir_from_user )
47- layout .add_row ("Image directory" , self ._image_dir_edit )
44+ layout .addRow ("Image directory" , self ._image_dir_edit )
4845
4946 def get_output_ebrf_file_from_user (x ) -> list [str ]:
5047 settings = QSettings ()
5148 default_dir = str (settings .value (LAST_DIR_SETTING_KEY , DEFAULT_LAST_DIR ))
52- save_path = QFileDialog .get_save_file_name (
49+ save_path = QFileDialog .getSaveFileName (
5350 parent = x , dir = default_dir , filter = "eBraille Files (*.zip)" ,
5451 options = QFileDialog .Option .DontConfirmOverwrite
5552 )[0 ]
5653 if save_path :
57- settings .set_value (LAST_DIR_SETTING_KEY , os .path .dirname (save_path ))
54+ settings .setValue (LAST_DIR_SETTING_KEY , os .path .dirname (save_path ))
5855 return [save_path ]
5956
6057 self ._output_ebrf_edit = FilePickerWidget (get_output_ebrf_file_from_user )
61- layout .add_row ("Output eBraille" , self ._output_ebrf_edit )
62- self ._update_include_images_state (self ._include_images_checkbox .checked )
58+ layout .addRow ("Output eBraille" , self ._output_ebrf_edit )
59+ self ._update_include_images_state (self ._include_images_checkbox .isChecked () )
6360 def restore_from_settings ():
6461 settings = QSettings ()
65- self ._input_type_combo .current_index = int (bool (settings .value ("Conversion/input_type" , defaultValue = False , type = bool )))
62+ self ._input_type_combo .setCurrentIndex ( int (bool (settings .value ("Conversion/input_type" , defaultValue = False , type = bool ) )))
6663 restore_from_settings ()
6764 def on_input_type_changed (index ):
6865 settings = QSettings ()
69- settings .set_value ("Conversion/input_type" , bool (index ))
66+ settings .setValue ("Conversion/input_type" , bool (index ))
7067 self ._input_type_combo .currentIndexChanged .connect (on_input_type_changed )
7168 self ._include_images_checkbox .toggled .connect (self ._update_include_images_state )
7269 self ._input_type_combo .currentIndexChanged .connect (self ._clear_input_brf )
@@ -76,26 +73,26 @@ def on_input_type_changed(index):
7673
7774 @Slot (bool )
7875 def _update_include_images_state (self , checked : bool ):
79- self ._image_dir_edit .enabled = checked
76+ self ._image_dir_edit .setEnabled ( checked )
8077 if not checked :
8178 self ._image_dir_edit .file_name = ""
8279
8380 def _get_input_brf_from_user (self , x ) -> list [str ]:
8481 settings = QSettings ()
8582 default_dir = str (settings .value (LAST_DIR_SETTING_KEY , DEFAULT_LAST_DIR ))
86- if self ._input_type_combo .current_index :
87- input_dir = QFileDialog .get_existing_directory (
83+ if self ._input_type_combo .currentIndex () :
84+ input_dir = QFileDialog .getExistingDirectory (
8885 parent = x , dir = default_dir
8986 )
9087 if input_dir :
91- settings .set_value (LAST_DIR_SETTING_KEY , input_dir )
88+ settings .setValue (LAST_DIR_SETTING_KEY , input_dir )
9289 return [input_dir ]
9390 else :
94- input_files = QFileDialog .get_open_file_names (
91+ input_files = QFileDialog .getOpenFileNames (
9592 parent = x , dir = default_dir , filter = "Braille Ready Files (*.brf)"
9693 )[0 ]
9794 if input_files :
98- settings .set_value (LAST_DIR_SETTING_KEY , os .path .dirname (input_files [0 ]))
95+ settings .setValue (LAST_DIR_SETTING_KEY , os .path .dirname (input_files [0 ]))
9996 return input_files
10097
10198 @property
@@ -104,22 +101,22 @@ def input_brfs(self) -> list[str]:
104101
105102 @input_brfs .setter
106103 def input_brfs (self , value : list [str ]):
107- self ._input_type_combo .current_index = 1 if len (value ) == 1 and os .path .isdir (value [0 ]) else 0
104+ self ._input_type_combo .setCurrentIndex ( 1 if len (value ) == 1 and os .path .isdir (value [0 ]) else 0 )
108105 self ._input_brf_edit .files = value
109106
110107 def _clear_input_brf (self ):
111108 self ._input_brf_edit .files = []
112109
113110 @property
114111 def image_directory (self ) -> str | None :
115- return self ._image_dir_edit .file_name if self ._include_images_checkbox .checked else None
112+ return self ._image_dir_edit .file_name if self ._include_images_checkbox .isChecked () else None
116113
117114 @image_directory .setter
118115 def image_directory (self , value : str | None ):
119116 if value is None :
120- self ._include_images_checkbox .checked = False
117+ self ._include_images_checkbox .setChecked ( False )
121118 else :
122- self ._include_images_checkbox .checked = True
119+ self ._include_images_checkbox .setChecked ( True )
123120 self ._image_dir_edit .file_name = value
124121
125122 @property
@@ -128,4 +125,4 @@ def output_ebrf(self) -> str:
128125
129126 @output_ebrf .setter
130127 def output_ebrf (self , value : str ):
131- self ._output_ebrf_edit .text = value
128+ self ._output_ebrf_edit .file_name = value
0 commit comments