@@ -174,8 +174,8 @@ def initEvet(self):
174174 self .updateClientsSignal .connect (self .updateClients )
175175 self .protoclTcpRadioBtn .clicked .connect (lambda : self .changeProtocol ("tcp" ))
176176 self .protoclUdpRadioBtn .clicked .connect (lambda : self .changeProtocol ("udp" ))
177- self .modeServerRadioBtn .clicked .connect (lambda : self .changeMode ("server" ))
178- self .modeClientRadioBtn .clicked .connect (lambda : self .changeMode ("client" ))
177+ self .modeServerRadioBtn .clicked .connect (lambda : self .changeMode ("server" , self . config [ "protocol" ] ))
178+ self .modeClientRadioBtn .clicked .connect (lambda : self .changeMode ("client" , self . config [ "protocol" ] ))
179179 self .clientsCombobox .currentIndexChanged .connect (self .serverModeClientChanged )
180180 self .disconnetClientBtn .clicked .connect (self .serverModeDisconnectClient )
181181 self .autoReconnect .stateChanged .connect (lambda x : self .setVar ("auto_reconnect" , value = x ))
@@ -190,46 +190,46 @@ def changeProtocol(self, protocol, init=False):
190190 self .modeClientRadioBtn .show ()
191191 self .modeServerRadioBtn .show ()
192192 self .modeLabel .show ()
193- self .changeMode (self .config ["mode" ], init = True )
193+ self .changeMode (self .config ["mode" ], protocol , init = True )
194194 else :
195- self .targetCombobox .show ()
196- self .targetLabel .show ()
197- self .selfIPandPortLabel .show ()
198- self .selfIPandPort .show ()
199- self .porttEdit .show ()
200- self .portLabel .show ()
201- self .clientsCombobox .hide ()
202- self .disconnetClientBtn .hide ()
203- self .autoReconnect .hide ()
204- self .autoReconnectIntervalEdit .hide ()
205- self .autoReconnetLable .hide ()
206- self .modeClientRadioBtn .hide ()
207- self .modeServerRadioBtn .hide ()
208- self .modeLabel .hide ()
209- self .widget .adjustSize ()
195+ self .modeClientRadioBtn .show ()
196+ self .modeServerRadioBtn .show ()
197+ self .modeLabel .show ()
198+ self .changeMode (self .config ["mode" ], protocol , init = True )
210199 self .config ["protocol" ] = protocol
211200
212- def changeMode (self , mode , init = False ):
201+ def changeMode (self , mode , protocol , init = False ):
213202 if init or mode != self .config ["mode" ]:
214203 if self .isConnected ():
215204 self .openCloseSerial ()
216205 if mode == "server" :
206+ if protocol == "tcp" :
207+ self .clientsCombobox .show ()
208+ self .disconnetClientBtn .show ()
209+ else :
210+ self .clientsCombobox .hide ()
211+ self .disconnetClientBtn .hide ()
212+
217213 self .targetCombobox .hide ()
218214 self .targetLabel .hide ()
219215 self .selfIPandPortLabel .hide ()
220216 self .selfIPandPort .hide ()
221217 self .porttEdit .show ()
222218 self .portLabel .show ()
223- self .clientsCombobox .show ()
224- self .disconnetClientBtn .show ()
225219 self .autoReconnect .hide ()
226220 self .autoReconnectIntervalEdit .hide ()
227221 self .autoReconnetLable .hide ()
228222 else :
223+ if protocol == "tcp" :
224+ self .selfIPandPortLabel .show ()
225+ self .selfIPandPort .show ()
226+ self .selfIPandPort .setReadOnly (True )
227+ else :
228+ self .selfIPandPortLabel .hide ()
229+ self .selfIPandPort .hide ()
230+
229231 self .targetCombobox .show ()
230232 self .targetLabel .show ()
231- self .selfIPandPortLabel .show ()
232- self .selfIPandPort .show ()
233233 self .porttEdit .hide ()
234234 self .portLabel .hide ()
235235 self .clientsCombobox .hide ()
@@ -308,11 +308,11 @@ def setSerialConfig(self, conf_type, obj, value):
308308 elif conf_type == "mode" :
309309 if value == "client" :
310310 obj .setChecked (True )
311- self .changeMode ("client" , init = True )
311+ self .changeMode ("client" , self . config [ "protocol" ], init = True )
312312 else :
313313 obj .setChecked (False )
314314 self .modeServerRadioBtn .setChecked (True )
315- self .changeMode ("server" , init = True )
315+ self .changeMode ("server" , self . config [ "protocol" ], init = True )
316316 elif conf_type == "target" :
317317 for i , target in enumerate (self .config ["target" ][1 ]):
318318 self .targetCombobox .addItem (target )
0 commit comments