@@ -54,8 +54,12 @@ def __init__(self, parent=None):
5454 self .image_label = QLabel ("No Image" )
5555 self .layout .addWidget (self .image_label )
5656
57- # check ddnet
58- self .ddnet_push_button = QPushButton ("Check with ddnet" )
57+ # check map
58+ self .check_map_button = QPushButton ("Check mapping rules" )
59+ self .layout .addWidget (self .check_map_button )
60+
61+ # check map with ddnet
62+ self .ddnet_push_button = QPushButton ("Check mapping rules with ddnet" )
5963 self .layout .addWidget (self .ddnet_push_button )
6064 if ConfigManager .instance ().config ()["client_path" ] is None :
6165 self .ddnet_push_button .setDisabled (True )
@@ -65,6 +69,7 @@ def __init__(self, parent=None):
6569
6670 # Generate button
6771 self .generate_button = QPushButton ("Generate" )
72+ self .generate_button .setEnabled (False ) # no rule name yet
6873 self .layout .addWidget (self .generate_button )
6974
7075 self .setLayout (self .layout )
@@ -74,8 +79,10 @@ def __init__(self, parent=None):
7479 # handle connections
7580 for radio_button in self .radio_buttons :
7681 radio_button .toggled .connect (self .ruleNameToggle )
77- self .generate_button .clicked .connect (self .openFileDialog )
82+ self .generate_button .clicked .connect (self .startRuleGeneration )
7883 self .ddnet_push_button .clicked .connect (self .startDDNetCheck )
84+ self .check_map_button .clicked .connect (self .checkMappingRules )
85+ self .new_mapper_line_edit .textChanged .connect (self .mappingRuleNameChanged )
7986
8087 # some configuration
8188 # configure validator new_mapper_line_edit
@@ -94,11 +101,11 @@ def setImage(self, image_path):
94101 self .image_label .setScaledContents (True )
95102 self .image_label .setMaximumSize (200 , 200 )
96103
97- def openFileDialog (self ):
104+ def startRuleGeneration (self ):
98105 rule_name = self .new_mapper_line_edit .text ()
99106 if not AppState .imagePath () or not len (rule_name ):
100107 return
101- cmd = CheckMapDialog (self )
108+ cmd = CheckMapDialog (self , title = f"Do you want to save your mapping rule ' { rule_name } '?" , cancel = True )
102109 ret = cmd .exec ()
103110 if ret :
104111 loaded_image_path = Path (AppState .imagePath ())
@@ -115,6 +122,16 @@ def openFileDialog(self):
115122 else:
116123 QMessageBox.warning(self, "Warning", "Please select an image first.")
117124 """
125+ def checkMappingRules (self ):
126+ cmd = CheckMapDialog (self , title = "Check Mapping Rules" , cancel = False )
127+ cmd .exec ()
128+
129+ def mappingRuleNameChanged (self ):
130+ rule_name = self .new_mapper_line_edit .text ()
131+ if not rule_name or len (rule_name ) == 0 :
132+ self .generate_button .setDisabled (True )
133+ else :
134+ self .generate_button .setEnabled (True )
118135
119136 def ruleNameToggle (self ):
120137 if self .radio_buttons [0 ].isChecked ():
0 commit comments