From f0d9b06ef4817f1f4b752ad6401c41f09c767e7f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 28 Nov 2025 16:31:36 +0000 Subject: [PATCH] Add validation for station selection to require at least one station Co-authored-by: nmemmert <67961292+nmemmert@users.noreply.github.com> --- journey_fm_app.py | 10 +++++++++- main.py | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/journey_fm_app.py b/journey_fm_app.py index e4417d2..1d38d0c 100644 --- a/journey_fm_app.py +++ b/journey_fm_app.py @@ -155,7 +155,7 @@ class SetupWizard(QDialog): buttons = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel ) - buttons.accepted.connect(self.accept) + buttons.accepted.connect(self.validate_and_accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) @@ -192,6 +192,14 @@ class SetupWizard(QDialog): 'SELECTED_STATIONS': ','.join(selected_stations) } + def validate_and_accept(self): + """Validate configuration before accepting""" + if not self.journey_fm_checkbox.isChecked() and not self.spirit_fm_checkbox.isChecked(): + QMessageBox.warning(self, "Validation Error", + "Please select at least one station to monitor.") + return + self.accept() + class LogViewer(QWidget): """Widget for viewing application logs""" def __init__(self, parent=None): diff --git a/main.py b/main.py index d2ab5dd..df5e50b 100644 --- a/main.py +++ b/main.py @@ -326,8 +326,9 @@ def main(): PLAYLIST_NAME = config.get('PLAYLIST_NAME', PLAYLIST_NAME) # Load selected stations selected_stations_str = config.get('SELECTED_STATIONS', 'journey_fm,spirit_fm') - if isinstance(selected_stations_str, str): - selected_stations = selected_stations_str.split(',') + if isinstance(selected_stations_str, str) and selected_stations_str: + selected_stations = [s for s in selected_stations_str.split(',') if s] + # If empty or invalid, keep default else: # If no config file, use defaults (GUI should handle this) pass