From 0d0b752bed61829f72ee2403b97ecac9bd053be2 Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Wed, 18 Nov 2026 20:56:43 +0100 Subject: [PATCH] Show in the wizard's summary what Save leaves on On a station left unchanged the summary read the log page's answers, which cannot express a DX cluster server or a frequency source running without a log source; it said no while Save left both on. The summary now shows the stored switches until the log page is part of the run. Ports, names, host and identifiers are reloaded on a source change, like the antenna values. Written-by: Claude Fable 5.2 --- .../view/compose/wizard/SetupWizardContent.kt | 4 +- .../view/compose/wizard/SetupWizardState.kt | 13 +++++ .../view/compose/wizard/WizardIntegrations.kt | 57 ++++++++++++++++--- .../compose/wizard/SetupWizardStateTest.kt | 30 ++++++++++ .../compose/wizard/WizardIntegrationsTest.kt | 51 +++++++++++++++++ 5 files changed, 144 insertions(+), 11 deletions(-) diff --git a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardContent.kt b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardContent.kt index a2676c3d..339edd9d 100644 --- a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardContent.kt +++ b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardContent.kt @@ -418,8 +418,8 @@ private fun SummaryPage(state: SetupWizardState, strings: Strings, saveFailed: B Form.section(strings.wizardSummaryLog) { if (state.logPageEditable) { SummaryRow(strings.wizardSummaryLog, logProgramName(integrations.logProgram, strings)) - SummaryRow(strings.wizardSummaryQrgFollow, yesNo(integrations.qrgFollow)) - SummaryRow(strings.wizardSummaryClusterServer, yesNo(integrations.networked && integrations.clusterServer)) + SummaryRow(strings.wizardSummaryQrgFollow, yesNo(state.summaryQrgFollow)) + SummaryRow(strings.wizardSummaryClusterServer, yesNo(state.summaryClusterServer)) Form.button(strings.wizardChange) { state.edit(WizardPage.LOG) } } else { /* Several sources are on; the page cannot show that and must not be opened. */ diff --git a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt index 2c4fe4ae..ea6a9ef8 100644 --- a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt +++ b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt @@ -327,6 +327,19 @@ class SetupWizardState(prefs: ChatPreferences) { page = target } + /** + * Whether the frequency is taken from a log program after Save, for the summary: the + * page's answer once the log page is part of the run, and what the profile holds before. + * The two differ where a frequency source is on without its log source, which the + * settings window allows and the page cannot show. + */ + val summaryQrgFollow: Boolean + get() = if (logShown) integrations.qrgFollow else integrations.storedQrgFollow + + /** Whether the DX cluster server runs after Save; see [summaryQrgFollow]. */ + val summaryClusterServer: Boolean + get() = if (logShown) integrations.networked && integrations.clusterServer else integrations.storedClusterServer + /** * What was on in the profile and will be off after Save, for the summary. Pages that are * not part of this run change nothing and contribute nothing. diff --git a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/WizardIntegrations.kt b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/WizardIntegrations.kt index f02886a9..2977320c 100644 --- a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/WizardIntegrations.kt +++ b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/WizardIntegrations.kt @@ -71,10 +71,30 @@ class WizardIntegrations(prefs: ChatPreferences) { var logProgram: WizardLogProgram by mutableStateOf(WizardLogProgram.NONE) private set - var udpPort: Int by mutableStateOf(prefs.getLogsynch_ucxUDPWkdCallListenerPort()) - var wintestPort: Int by mutableStateOf(prefs.getLogsynch_wintestNetworkPort()) - var wintestStationName: String by mutableStateOf(prefs.getLogsynch_wintestNetworkStationNameOfKST().orEmpty()) - var filePath: String by mutableStateOf(prefs.getLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly().orEmpty()) + private val storedUdpPort = prefs.getLogsynch_ucxUDPWkdCallListenerPort() + private val storedWintestPort = prefs.getLogsynch_wintestNetworkPort() + private val storedWintestStationName = prefs.getLogsynch_wintestNetworkStationNameOfKST().orEmpty() + private val storedFilePath = prefs.getLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly().orEmpty() + private val storedRotatorHost = prefs.getStn_pstRotatorHost().orEmpty() + private val storedRotatorPort = prefs.getStn_pstRotatorPort() + private val storedAirScoutPort = prefs.getAirScout_asCommunicationPort() + private val storedAirScoutServerName = prefs.getAirScout_asServerNameString().orEmpty() + private val storedAirScoutClientName = prefs.getAirScout_asClientNameString().orEmpty() + + /** + * Whether the profile takes its own frequency from a log program, whichever one. Known + * apart from [qrgFollow] because the settings window allows a frequency source without + * the matching log source, which the page's single choice cannot show. + */ + val storedQrgFollow: Boolean = storedUdpQrg || storedWintestQrg + + /** Whether the profile runs the local DX cluster server, with or without a log source. */ + val storedClusterServer: Boolean = storedCluster + + var udpPort: Int by mutableStateOf(storedUdpPort) + var wintestPort: Int by mutableStateOf(storedWintestPort) + var wintestStationName: String by mutableStateOf(storedWintestStationName) + var filePath: String by mutableStateOf(storedFilePath) /** Take the own frequency from the chosen network program. */ var qrgFollow: Boolean by mutableStateOf(false) @@ -83,13 +103,13 @@ class WizardIntegrations(prefs: ChatPreferences) { var clusterServer: Boolean by mutableStateOf(false) var rotator: Boolean by mutableStateOf(false) - var rotatorHost: String by mutableStateOf(prefs.getStn_pstRotatorHost().orEmpty()) - var rotatorPort: Int by mutableStateOf(prefs.getStn_pstRotatorPort()) + var rotatorHost: String by mutableStateOf(storedRotatorHost) + var rotatorPort: Int by mutableStateOf(storedRotatorPort) var airScout: Boolean by mutableStateOf(false) - var airScoutPort: Int by mutableStateOf(prefs.getAirScout_asCommunicationPort()) - var airScoutServerName: String by mutableStateOf(prefs.getAirScout_asServerNameString().orEmpty()) - var airScoutClientName: String by mutableStateOf(prefs.getAirScout_asClientNameString().orEmpty()) + var airScoutPort: Int by mutableStateOf(storedAirScoutPort) + var airScoutServerName: String by mutableStateOf(storedAirScoutServerName) + var airScoutClientName: String by mutableStateOf(storedAirScoutClientName) init { loadStored() @@ -111,6 +131,7 @@ class WizardIntegrations(prefs: ChatPreferences) { clusterServer = networked && storedCluster rotator = storedRotator airScout = storedAirScout + loadStoredDetails() } /** A station set up anew: every switch off, every number left as a proposal. */ @@ -120,6 +141,24 @@ class WizardIntegrations(prefs: ChatPreferences) { clusterServer = false rotator = false airScout = false + loadStoredDetails() + } + + /** + * Ports, names, host and identifiers back to what the profile holds. Both loads do this: + * they run when the operator changes his mind about where the station comes from, and a + * number typed under one choice must not turn up under the other. + */ + private fun loadStoredDetails() { + udpPort = storedUdpPort + wintestPort = storedWintestPort + wintestStationName = storedWintestStationName + filePath = storedFilePath + rotatorHost = storedRotatorHost + rotatorPort = storedRotatorPort + airScoutPort = storedAirScoutPort + airScoutServerName = storedAirScoutServerName + airScoutClientName = storedAirScoutClientName } /** Only a network program can deliver a frequency or take spots. */ diff --git a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt index 819dba97..b80fe1a1 100644 --- a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt +++ b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt @@ -595,4 +595,34 @@ class SetupWizardStateTest { "the summary must not show a value that Save will not write", ) } + + @Test + fun theSummaryOfAKeptStationShowsWhatSaveLeavesOn() { + // No log source, but the DX cluster server and a frequency source are on. + val state = SetupWizardState(duplicatedWinTestStation().apply { + setLogsynch_wintestNetworkListenerEnabled(false) + setLogsynch_wintestQrgSyncEnabled(true) + setNotify_dxClusterServerEnabled(true) + }) + state.chooseStationSource(WizardSource.KEEP) + state.next() + state.name = "Philipp" + state.next() + state.callsign = "DL0TEST" + state.password = "secret" + state.next() + assertEquals(WizardPage.SUMMARY, state.page) + + assertTrue(state.summaryClusterServer, "Save leaves it on, so the summary must not say no") + assertTrue(state.summaryQrgFollow) + assertFalse(state.switchedOff.contains(WizardSwitch.CLUSTER_SERVER)) + + // Once the log page is part of the run its answers count, and what they drop is named. + state.edit(WizardPage.LOG) + state.next() + + assertFalse(state.summaryClusterServer) + assertFalse(state.summaryQrgFollow) + assertTrue(state.switchedOff.containsAll(listOf(WizardSwitch.QRG_FOLLOW, WizardSwitch.CLUSTER_SERVER))) + } } diff --git a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/WizardIntegrationsTest.kt b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/WizardIntegrationsTest.kt index 7020f612..8dee2ba8 100644 --- a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/WizardIntegrationsTest.kt +++ b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/WizardIntegrationsTest.kt @@ -297,4 +297,55 @@ class WizardIntegrationsTest { answers.rotatorPort = 0 assertFalse(answers.gearComplete) } + + @Test + fun loadingAgainPutsTheDetailsBackToTheStoredOnes() { + val answers = WizardIntegrations(winTestStation()) + answers.udpPort = 1 + answers.wintestPort = 2 + answers.wintestStationName = "typed" + answers.filePath = "/typed" + answers.rotatorHost = "typed" + answers.rotatorPort = 3 + answers.airScoutPort = 4 + answers.airScoutServerName = "typed" + answers.airScoutClientName = "typed" + + answers.loadFresh() + + assertEquals(12060, answers.udpPort) + assertEquals(9999, answers.wintestPort) + assertEquals("KST", answers.wintestStationName) + assertEquals("127.0.0.1", answers.rotatorHost) + assertEquals(12000, answers.rotatorPort) + assertEquals(9872, answers.airScoutPort) + assertEquals("AS", answers.airScoutServerName) + assertEquals("KST", answers.airScoutClientName) + + answers.filePath = "/typed" + answers.rotatorPort = 3 + answers.loadStored() + + assertFalse(answers.filePath == "/typed", "the stored file name is back") + assertEquals(12000, answers.rotatorPort) + } + + @Test + fun theStoredSwitchesAreKnownWhateverTheLogProgram() { + // The settings window lets the DX cluster server and a frequency source run without + // a log source; the page's own answers cannot express that. + val answers = WizardIntegrations(allOff { + setNotify_dxClusterServerEnabled(true) + setTrxSynch_ucxLogUDPListenerEnabled(true) + }) + + assertEquals(WizardLogProgram.NONE, answers.logProgram) + assertFalse(answers.clusterServer, "the page shows none of it") + assertTrue(answers.storedClusterServer) + assertTrue(answers.storedQrgFollow) + + val off = WizardIntegrations(allOff()) + assertFalse(off.storedClusterServer) + assertFalse(off.storedQrgFollow) + } }