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
This commit is contained in:
Rsclub2_2 committed 2026-11-18 21:32:14 +01:00
1 parent 175b6350c2
commit 0d0b752bed
5 files changed
+144 -11

No files matched your search

@@ -418,8 +418,8 @@ private fun SummaryPage(state: SetupWizardState, strings: Strings, saveFailed: B
Form.section(strings.wizardSummaryLog) { Form.section(strings.wizardSummaryLog) {
if (state.logPageEditable) { if (state.logPageEditable) {
SummaryRow(strings.wizardSummaryLog, logProgramName(integrations.logProgram, strings)) SummaryRow(strings.wizardSummaryLog, logProgramName(integrations.logProgram, strings))
SummaryRow(strings.wizardSummaryQrgFollow, yesNo(integrations.qrgFollow)) SummaryRow(strings.wizardSummaryQrgFollow, yesNo(state.summaryQrgFollow))
SummaryRow(strings.wizardSummaryClusterServer, yesNo(integrations.networked && integrations.clusterServer)) SummaryRow(strings.wizardSummaryClusterServer, yesNo(state.summaryClusterServer))
Form.button(strings.wizardChange) { state.edit(WizardPage.LOG) } Form.button(strings.wizardChange) { state.edit(WizardPage.LOG) }
} else { } else {
/* Several sources are on; the page cannot show that and must not be opened. */ /* Several sources are on; the page cannot show that and must not be opened. */
@@ -327,6 +327,19 @@ class SetupWizardState(prefs: ChatPreferences) {
page = target 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 * 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. * not part of this run change nothing and contribute nothing.
@@ -71,10 +71,30 @@ class WizardIntegrations(prefs: ChatPreferences) {
var logProgram: WizardLogProgram by mutableStateOf(WizardLogProgram.NONE) var logProgram: WizardLogProgram by mutableStateOf(WizardLogProgram.NONE)
private set private set
var udpPort: Int by mutableStateOf(prefs.getLogsynch_ucxUDPWkdCallListenerPort()) private val storedUdpPort = prefs.getLogsynch_ucxUDPWkdCallListenerPort()
var wintestPort: Int by mutableStateOf(prefs.getLogsynch_wintestNetworkPort()) private val storedWintestPort = prefs.getLogsynch_wintestNetworkPort()
var wintestStationName: String by mutableStateOf(prefs.getLogsynch_wintestNetworkStationNameOfKST().orEmpty()) private val storedWintestStationName = prefs.getLogsynch_wintestNetworkStationNameOfKST().orEmpty()
var filePath: String by mutableStateOf(prefs.getLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly().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. */ /** Take the own frequency from the chosen network program. */
var qrgFollow: Boolean by mutableStateOf(false) var qrgFollow: Boolean by mutableStateOf(false)
@@ -83,13 +103,13 @@ class WizardIntegrations(prefs: ChatPreferences) {
var clusterServer: Boolean by mutableStateOf(false) var clusterServer: Boolean by mutableStateOf(false)
var rotator: Boolean by mutableStateOf(false) var rotator: Boolean by mutableStateOf(false)
var rotatorHost: String by mutableStateOf(prefs.getStn_pstRotatorHost().orEmpty()) var rotatorHost: String by mutableStateOf(storedRotatorHost)
var rotatorPort: Int by mutableStateOf(prefs.getStn_pstRotatorPort()) var rotatorPort: Int by mutableStateOf(storedRotatorPort)
var airScout: Boolean by mutableStateOf(false) var airScout: Boolean by mutableStateOf(false)
var airScoutPort: Int by mutableStateOf(prefs.getAirScout_asCommunicationPort()) var airScoutPort: Int by mutableStateOf(storedAirScoutPort)
var airScoutServerName: String by mutableStateOf(prefs.getAirScout_asServerNameString().orEmpty()) var airScoutServerName: String by mutableStateOf(storedAirScoutServerName)
var airScoutClientName: String by mutableStateOf(prefs.getAirScout_asClientNameString().orEmpty()) var airScoutClientName: String by mutableStateOf(storedAirScoutClientName)
init { init {
loadStored() loadStored()
@@ -111,6 +131,7 @@ class WizardIntegrations(prefs: ChatPreferences) {
clusterServer = networked && storedCluster clusterServer = networked && storedCluster
rotator = storedRotator rotator = storedRotator
airScout = storedAirScout airScout = storedAirScout
loadStoredDetails()
} }
/** A station set up anew: every switch off, every number left as a proposal. */ /** A station set up anew: every switch off, every number left as a proposal. */
@@ -120,6 +141,24 @@ class WizardIntegrations(prefs: ChatPreferences) {
clusterServer = false clusterServer = false
rotator = false rotator = false
airScout = 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. */ /** Only a network program can deliver a frequency or take spots. */
@@ -595,4 +595,34 @@ class SetupWizardStateTest {
"the summary must not show a value that Save will not write", "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)))
}
} }
@@ -297,4 +297,55 @@ class WizardIntegrationsTest {
answers.rotatorPort = 0 answers.rotatorPort = 0
assertFalse(answers.gearComplete) 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)
}
} }