1414from microscope .widgets .rubberband import ResizableRubberBand
1515from microscope .widgets .color_button import ColorButton
1616from microscope .plugins .base_plugin import BasePlugin
17+ from microscope .utils import convert_str_bool
1718from qtpy .QtGui import QMouseEvent
1819from collections import defaultdict
1920
@@ -50,19 +51,6 @@ def __init__(self, parent: "Optional[Microscope]" = None):
5051 self ._x_divs = 5
5152 self ._y_divs = 5
5253
53- def convert_str_bool (self , val ):
54- """Converts a string representation of a boolean to a boolean value.
55-
56- Args:
57- val (str): The string representation of the boolean.
58-
59- Returns:
60- bool: The boolean value.
61- """
62- if isinstance (val , str ):
63- return True if val .lower () == "true" else False
64- return val
65-
6654 def read_settings (self , settings : Dict [str , Any ]):
6755 """Reads the plugin's settings from a dictionary.
6856
@@ -72,13 +60,13 @@ def read_settings(self, settings: Dict[str, Any]):
7260 self ._grid_color = settings .get ("color" , QColor .fromRgb (0 , 255 , 0 ))
7361 self .start = settings .get ("start" , QPoint (0 , 0 ))
7462 self .end = settings .get ("end" , QPoint (1 , 1 ))
75- self .plugin_state ["grid_hidden" ] = self . convert_str_bool (
63+ self .plugin_state ["grid_hidden" ] = convert_str_bool (
7664 settings .get ("grid_hidden" , False )
7765 )
78- self .plugin_state ["selector_hidden" ] = self . convert_str_bool (
66+ self .plugin_state ["selector_hidden" ] = convert_str_bool (
7967 settings .get ("selector_hidden" , False )
8068 )
81- self .plugin_state ["grid_defined" ] = self . convert_str_bool (
69+ self .plugin_state ["grid_defined" ] = convert_str_bool (
8270 settings .get ("grid_defined" , False )
8371 )
8472 self ._x_divs = int (settings .get ("x_divs" , 5 ))
0 commit comments