Skip to content

Commit c2ccbce

Browse files
Mark JessopMark Jessop
authored andcommitted
Changed behaviour of station information area. Add config reset command-line option.
1 parent edb3ccf commit c2ccbce

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
lines changed

horusgui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.18"
1+
__version__ = "0.3.19"

horusgui/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def read_config(widgets):
7676
global qt_settings, default_config
7777

7878
# This is getting a bit ridiculous, need to re-think this approach.
79-
OK_VERSIONS = [__version__, '0.3.17', '0.3.16', '0.3.15', '0.3.14', '0.3.13', '0.3.12', '0.3.11', '0.3.10', '0.3.9', '0.3.8', '0.3.7', '0.3.6', '0.3.5', '0.3.4', '0.3.1', '0.2.1']
79+
OK_VERSIONS = [__version__, '0.3.18', '0.3.17', '0.3.16', '0.3.15', '0.3.14', '0.3.13', '0.3.12', '0.3.11', '0.3.10', '0.3.9', '0.3.8', '0.3.7', '0.3.6', '0.3.5', '0.3.4', '0.3.1', '0.2.1']
8080

8181
# Try and read in the version parameter from QSettings
8282
if qt_settings.value("version") not in OK_VERSIONS:

horusgui/gui.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
parser.add_argument("--payload-id-list", type=str, default=None, help="Use supplied Payload ID List instead of downloading a new one.")
8888
parser.add_argument("--custom-field-list", type=str, default=None, help="Use supplied Custom Field List instead of downloading a new one.")
8989
parser.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.")
9091
parser.add_argument("-v", "--verbose", action="store_true", default=False, help="Verbose output (set logging level to DEBUG)")
9192
args = parser.parse_args()
9293

@@ -229,7 +230,7 @@
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>")
233234
widgets["userLatEntry"] = QtWidgets.QLineEdit("0.0")
234235
widgets["userLatEntry"].setToolTip("Station Latitude in Decimal Degrees, e.g. -34.123456")
235236
widgets["userLonEntry"] = QtWidgets.QLineEdit("0.0")
@@ -244,20 +245,20 @@
244245
widgets["userRadioEntry"] = QtWidgets.QLineEdit("Horus-GUI " + __version__)
245246
widgets["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")
250252
widgets["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
)
255255
widgets["dialFreqLabel"] = QtWidgets.QLabel("<b>Radio Dial Freq (MHz):</b>")
256256
widgets["dialFreqEntry"] = QtWidgets.QLineEdit("")
257257
widgets["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

262263
widgets["saveSettingsButton"] = QtWidgets.QPushButton("Save Settings")
263264

@@ -277,8 +278,9 @@
277278
w1_habitat.addWidget(widgets["dialFreqLabel"], 6, 0, 1, 1)
278279
w1_habitat.addWidget(widgets["dialFreqEntry"], 6, 1, 1, 2)
279280
w1_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

283285
d0_habitat.addWidget(w1_habitat)
284286

@@ -679,8 +681,12 @@ def set_logging_format():
679681

680682
widgets["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

686692
try:
@@ -708,9 +714,12 @@ def set_logging_format():
708714
)
709715

710716
# Handlers for various checkboxes and push-buttons
711-
712717
def 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.
731746
widgets["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
735750
def 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.
738759
widgets["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

741767
def habitat_inhibit():

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "horusgui"
3-
version = "0.3.18"
3+
version = "0.3.19"
44
description = ""
55
authors = ["Mark Jessop <[email protected]>"]
66

0 commit comments

Comments
 (0)