@@ -285,6 +285,28 @@ def __init__(self, parent=None):
285
285
# Checks for new release
286
286
Thread (target = lambda : asyncio .run (self .updateCheck ()), daemon = True ).start ()
287
287
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
+
288
310
async def updateCheck (self ):
289
311
nurl = "https://raw.github.com/shahinism/python-negar/master/negar/constants.py"
290
312
ngurl = "https://raw.github.com/javadr/negar-gui/master/negar_gui/constants.py"
@@ -377,28 +399,8 @@ def connectSlots(self):
377
399
self .actionReport_Bugs .triggered .connect (
378
400
lambda : QDesktopServices .openUrl (QUrl ("https://github.com/javadr/negar-gui/issues" )),
379
401
)
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 :
402
404
menu_item .triggered .connect (lambda : (self .option_control (), self .autoedit_handler ()))
403
405
404
406
self .actionUntouchable_Words .triggered .connect (
@@ -464,6 +466,26 @@ def connectSlots(self):
464
466
self .input_editor .verticalScrollBar ().valueChanged .connect (self ._sync_inout_scroll )
465
467
self .output_editor .verticalScrollBar ().valueChanged .connect (self ._sync_inout_scroll )
466
468
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
+
467
489
####################### SLOTs ###############################
468
490
def _sync_inout_scroll (self , value ):
469
491
max_in_scroll = self .input_editor .verticalScrollBar ().maximum ()
@@ -492,6 +514,7 @@ def full_screen_input_slot(self):
492
514
493
515
# Change GridLayout Orientation
494
516
def _grid_layout (self , layout = "h" ):
517
+ assert layout in ("v" , "h" ), "Layout must be 'v' or 'h'"
495
518
if layout == "v" :
496
519
self .gridLayout .setHorizontalSpacing (5 )
497
520
elif layout == "h" :
@@ -788,7 +811,10 @@ def autoedit_handler(self):
788
811
else :
789
812
self .edit_btn .setEnabled (True )
790
813
# 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
792
818
self ._set_font_size ()
793
819
794
820
def _set_font_size (self ):
0 commit comments