Add validation for station selection to require at least one station

Co-authored-by: nmemmert <67961292+nmemmert@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]andnmemmert committed 2025-11-28 16:31:36 +00:00
1 parent 013edb952f
commit f0d9b06ef4
2 files changed
+12 -3

No files matched your search

+9 -1
View File
@@ -155,7 +155,7 @@ class SetupWizard(QDialog):
buttons = QDialogButtonBox( buttons = QDialogButtonBox(
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
) )
buttons.accepted.connect(self.accept) buttons.accepted.connect(self.validate_and_accept)
buttons.rejected.connect(self.reject) buttons.rejected.connect(self.reject)
layout.addWidget(buttons) layout.addWidget(buttons)
@@ -192,6 +192,14 @@ class SetupWizard(QDialog):
'SELECTED_STATIONS': ','.join(selected_stations) '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): class LogViewer(QWidget):
"""Widget for viewing application logs""" """Widget for viewing application logs"""
def __init__(self, parent=None): def __init__(self, parent=None):
+3 -2
View File
@@ -326,8 +326,9 @@ def main():
PLAYLIST_NAME = config.get('PLAYLIST_NAME', PLAYLIST_NAME) PLAYLIST_NAME = config.get('PLAYLIST_NAME', PLAYLIST_NAME)
# Load selected stations # Load selected stations
selected_stations_str = config.get('SELECTED_STATIONS', 'journey_fm,spirit_fm') selected_stations_str = config.get('SELECTED_STATIONS', 'journey_fm,spirit_fm')
if isinstance(selected_stations_str, str): if isinstance(selected_stations_str, str) and selected_stations_str:
selected_stations = selected_stations_str.split(',') selected_stations = [s for s in selected_stations_str.split(',') if s]
# If empty or invalid, keep default
else: else:
# If no config file, use defaults (GUI should handle this) # If no config file, use defaults (GUI should handle this)
pass pass