@@ -285,6 +285,28 @@ def __init__(self, parent=None):
285285 # Checks for new release
286286 Thread (target = lambda : asyncio .run (self .updateCheck ()), daemon = True ).start ()
287287
288+ self .options_action_menu = (
289+ self .actionFix_Dashes ,
290+ self .actionFix_three_dots ,
291+ self .actionFix_English_quotes ,
292+ self .actionFix_hamzeh ,
293+ self .actionUse_Persian_yeh_to_show_hamzeh ,
294+ self .actionFix_spacing_braces_and_quotes ,
295+ self .actionFix_Arabic_numbers ,
296+ self .actionFix_English_numbers ,
297+ self .actionFix_non_Persian_chars ,
298+ self .actionFix_prefix_spacing ,
299+ self .actionFix_prefix_separating ,
300+ self .actionFix_suffix_spacing ,
301+ self .actionFix_suffix_separating ,
302+ self .actionFix_aggressive_punctuation ,
303+ self .actionCleanup_kashidas ,
304+ self .actionCleanup_extra_marks ,
305+ self .actionCleanup_spacing ,
306+ self .actionTrim_Leading_Trailing_Whitespaces ,
307+ self .actionExaggerating_ZWNJ ,
308+ )
309+
288310 async def updateCheck (self ):
289311 nurl = "https://raw.github.com/shahinism/python-negar/master/negar/constants.py"
290312 ngurl = "https://raw.github.com/javadr/negar-gui/master/negar_gui/constants.py"
@@ -377,28 +399,8 @@ def connectSlots(self):
377399 self .actionReport_Bugs .triggered .connect (
378400 lambda : QDesktopServices .openUrl (QUrl ("https://github.com/javadr/negar-gui/issues" )),
379401 )
380-
381- for menu_item in (
382- self .actionFix_Dashes ,
383- self .actionFix_three_dots ,
384- self .actionFix_English_quotes ,
385- self .actionFix_hamzeh ,
386- self .actionUse_Persian_yeh_to_show_hamzeh ,
387- self .actionFix_spacing_braces_and_quotes ,
388- self .actionFix_Arabic_numbers ,
389- self .actionFix_English_numbers ,
390- self .actionFix_non_Persian_chars ,
391- self .actionFix_prefix_spacing ,
392- self .actionFix_prefix_separating ,
393- self .actionFix_suffix_spacing ,
394- self .actionFix_suffix_separating ,
395- self .actionFix_aggressive_punctuation ,
396- self .actionCleanup_kashidas ,
397- self .actionCleanup_extra_marks ,
398- self .actionCleanup_spacing ,
399- self .actionTrim_Leading_Trailing_Whitespaces ,
400- self .actionExaggerating_ZWNJ ,
401- ):
402+ # connecting the option menu items to their handlers
403+ for menu_item in self .options_action_menu :
402404 menu_item .triggered .connect (lambda : (self .option_control (), self .autoedit_handler ()))
403405
404406 self .actionUntouchable_Words .triggered .connect (
@@ -464,6 +466,26 @@ def connectSlots(self):
464466 self .input_editor .verticalScrollBar ().valueChanged .connect (self ._sync_inout_scroll )
465467 self .output_editor .verticalScrollBar ().valueChanged .connect (self ._sync_inout_scroll )
466468
469+ def check (value : bool ):
470+ return lambda : (
471+ [checkbox .setChecked (value ) for checkbox in self .options_action_menu ],
472+ self .option_control (),
473+ self .autoedit_handler (),
474+ )
475+
476+ self .actionSelect_All .triggered .connect (check (True ))
477+ self .actionUnselect_All .triggered .connect (check (False ))
478+ self .actionInvert_Selection .triggered .connect (
479+ lambda : (
480+ [
481+ checkbox .setChecked (not checkbox .isChecked ())
482+ for checkbox in self .options_action_menu
483+ ],
484+ self .option_control (),
485+ self .autoedit_handler (),
486+ )
487+ )
488+
467489 ####################### SLOTs ###############################
468490 def _sync_inout_scroll (self , value ):
469491 max_in_scroll = self .input_editor .verticalScrollBar ().maximum ()
@@ -492,6 +514,7 @@ def full_screen_input_slot(self):
492514
493515 # Change GridLayout Orientation
494516 def _grid_layout (self , layout = "h" ):
517+ assert layout in ("v" , "h" ), "Layout must be 'v' or 'h'"
495518 if layout == "v" :
496519 self .gridLayout .setHorizontalSpacing (5 )
497520 elif layout == "h" :
@@ -788,7 +811,10 @@ def autoedit_handler(self):
788811 else :
789812 self .edit_btn .setEnabled (True )
790813 # This line will disconnect autoedit signal and will disable autoamtic edit option
791- self .input_editor .textChanged .disconnect (self .edit_text )
814+ try :
815+ self .input_editor .textChanged .disconnect (self .edit_text )
816+ except :
817+ pass
792818 self ._set_font_size ()
793819
794820 def _set_font_size (self ):
0 commit comments