8787parser .add_argument ("--payload-id-list" , type = str , default = None , help = "Use supplied Payload ID List instead of downloading a new one." )
8888parser .add_argument ("--custom-field-list" , type = str , default = None , help = "Use supplied Custom Field List instead of downloading a new one." )
8989parser .add_argument ("--libfix" , action = "store_true" , default = False , help = "Search for libhorus.dll/so in ./ instead of on the path." )
90+ parser .add_argument ("--reset" , action = "store_true" , default = False , help = "Reset all configuration information on startup." )
9091parser .add_argument ("-v" , "--verbose" , action = "store_true" , default = False , help = "Verbose output (set logging level to DEBUG)" )
9192args  =  parser .parse_args ()
9293
229230    "Your station callsign, which doesn't necessarily need to be an\n " \
230231    "amateur radio callsign, just something unique!" 
231232)
232- widgets ["userLocationLabel" ] =  QtWidgets .QLabel ("<b>Lat/Lon :</b>" )
233+ widgets ["userLocationLabel" ] =  QtWidgets .QLabel ("<b>Latitude / Longitude :</b>" )
233234widgets ["userLatEntry" ] =  QtWidgets .QLineEdit ("0.0" )
234235widgets ["userLatEntry" ].setToolTip ("Station Latitude in Decimal Degrees, e.g. -34.123456" )
235236widgets ["userLonEntry" ] =  QtWidgets .QLineEdit ("0.0" )
244245widgets ["userRadioEntry" ] =  QtWidgets .QLineEdit ("Horus-GUI "  +  __version__ )
245246widgets ["userRadioEntry" ].setToolTip (
246247    "A text description of your station's radio setup.\n " \
247-     "This field will be automatically prefixed with Horus-GUI." 
248+     "This field will be automatically prefixed with Horus-GUI\n " \
249+     "and the Horus-GUI software version." 
248250)
249- widgets ["habitatUploadPosition" ] =  QtWidgets .QPushButton ("Re-upload Position " )
251+ widgets ["habitatUploadPosition" ] =  QtWidgets .QPushButton ("Re-upload Station Info " )
250252widgets ["habitatUploadPosition" ].setToolTip (
251-     "Manually re-upload your position information to SondeHub-Amateur.\n " \
252-     "Note that it can take a few minutes for your new information to\n " \
253-     "appear on the map." 
253+     "Manually re-upload your station information to SondeHub-Amateur.\n " \
254254)
255255widgets ["dialFreqLabel" ] =  QtWidgets .QLabel ("<b>Radio Dial Freq (MHz):</b>" )
256256widgets ["dialFreqEntry" ] =  QtWidgets .QLineEdit ("" )
257257widgets ["dialFreqEntry" ].setToolTip (
258258    "Optional entry of your radio's dial frequency in MHz (e.g. 437.600).\n " \
259259    "Used to provide frequency information on SondeHub-Amateur." \
260260)
261+ widgets ["sondehubPositionNotesLabel" ] =  QtWidgets .QLabel ("" )
261262
262263widgets ["saveSettingsButton" ] =  QtWidgets .QPushButton ("Save Settings" )
263264
277278w1_habitat .addWidget (widgets ["dialFreqLabel" ], 6 , 0 , 1 , 1 )
278279w1_habitat .addWidget (widgets ["dialFreqEntry" ], 6 , 1 , 1 , 2 )
279280w1_habitat .addWidget (widgets ["habitatUploadPosition" ], 7 , 0 , 1 , 3 )
280- w1_habitat .layout .setRowStretch (8 , 1 )
281- w1_habitat .addWidget (widgets ["saveSettingsButton" ], 9 , 0 , 1 , 3 )
281+ w1_habitat .addWidget (widgets ["sondehubPositionNotesLabel" ], 8 , 0 , 1 , 3 )
282+ w1_habitat .layout .setRowStretch (9 , 1 )
283+ w1_habitat .addWidget (widgets ["saveSettingsButton" ], 10 , 0 , 1 , 3 )
282284
283285d0_habitat .addWidget (w1_habitat )
284286
@@ -679,8 +681,12 @@ def set_logging_format():
679681
680682widgets ["loggingFormatSelector" ].currentIndexChanged .connect (set_logging_format )
681683
682- # Read in configuration file settings 
683- read_config (widgets )
684+ # Clear the configuration if we have been asked to, otherwise read it in from Qt stores 
685+ if  args .reset :
686+     logging .info ("Clearing configuration." )
687+     write_config ()
688+ else :
689+     read_config (widgets )
684690
685691
686692try :
@@ -708,9 +714,12 @@ def set_logging_format():
708714)
709715
710716# Handlers for various checkboxes and push-buttons 
711- 
712717def  habitat_position_reupload (dummy_arg , upload = True ):
713-     """ Trigger a re-upload of user position information """ 
718+     """  
719+     Trigger a re-upload of user position information  
720+     Note that this requires a dummy argument, as the Qt  
721+     'connect' callback supplies an argument which we don't want. 
722+     """ 
714723    global  widgets , sondehub_uploader 
715724
716725    sondehub_uploader .user_callsign  =  widgets ["userCallEntry" ].text ()
@@ -720,22 +729,39 @@ def habitat_position_reupload(dummy_arg, upload=True):
720729        if  float (widgets ["userLatEntry" ].text ()) ==  0.0  and  float (widgets ["userLonEntry" ].text ()) ==  0.0 :
721730            sondehub_uploader .user_position  =  None 
722731        else :
723-             sondehub_uploader .user_position  =  [float (widgets ["userLatEntry" ].text ()), float (widgets ["userLonEntry" ].text ()), 0.0 ]
724-     except :
732+             sondehub_uploader .user_position  =  [
733+                 float (widgets ["userLatEntry" ].text ()), 
734+                 float (widgets ["userLonEntry" ].text ()), 
735+                 float (widgets ["userAltEntry" ].text ())]
736+     except  Exception  as  e :
737+         logging .error (f"Error parsing station location - { str (e )}  " )
725738        sondehub_uploader .user_position  =  None 
726739
727740    if  upload :
728741        sondehub_uploader .last_user_position_upload  =  0 
742+         widgets ["sondehubPositionNotesLabel" ].setText ("" )
729743        logging .info ("Triggered user position re-upload." )
730744
745+ # Connect the 'Re-upload Position' button to the above function. 
731746widgets ["habitatUploadPosition" ].clicked .connect (habitat_position_reupload )
732747
733748
734749# Update uploader info as soon as it's edited, to ensure we upload with the latest user callsign 
735750def  update_uploader_details ():
736-     habitat_position_reupload (upload = False )
751+     """ 
752+     Wrapper function for position re-upload, called when the user callsign entry is changed. 
753+     """ 
754+     #habitat_position_reupload("unused arg",upload=False) 
755+     widgets ["sondehubPositionNotesLabel" ].setText ("<center><b>Station Info out of date - click Re-Upload!</b></center>" )
737756
757+ # Connect all the station information fields to this function, so that when the user 
758+ # changes any of them they get a prompt to click the re-upload button. 
738759widgets ["userCallEntry" ].textEdited .connect (update_uploader_details )
760+ widgets ["userRadioEntry" ].textEdited .connect (update_uploader_details )
761+ widgets ["userAntennaEntry" ].textEdited .connect (update_uploader_details )
762+ widgets ["userLatEntry" ].textEdited .connect (update_uploader_details )
763+ widgets ["userLonEntry" ].textEdited .connect (update_uploader_details )
764+ widgets ["userAltEntry" ].textEdited .connect (update_uploader_details )
739765
740766
741767def  habitat_inhibit ():
0 commit comments