From 8352af911ef095d987e6de44b2f84b15e1aeab00 Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Wed, 18 Nov 2026 19:37:13 +0100 Subject: [PATCH] Reach the setup wizard from the Options menu Written-by: Codex (GPT-6.2 Sol) Written-by: Claude Fable 5.2 --- .../src/main/i18n/strings_de.properties | 6 ++++++ .../src/main/i18n/strings_en.properties | 6 ++++++ .../view/ApplicationRuntimeLauncher.java | 21 +++++++++++++++++++ .../kst4contest/view/ComposeMenuActions.java | 5 +++++ .../view/Kst4ContestApplication.java | 21 +++++++++++++++++++ .../kst4contest/view/compose/MainMenuBar.kt | 3 +++ .../kst4contest/view/compose/MainMenuModel.kt | 5 +++++ .../view/compose/MainMenuModelTest.kt | 16 ++++++++++++++ .../view/compose/MainMenuRowScreenTest.kt | 2 ++ 9 files changed, 85 insertions(+) diff --git a/app-desktop/src/main/i18n/strings_de.properties b/app-desktop/src/main/i18n/strings_de.properties index 17b67403..e79f0026 100644 --- a/app-desktop/src/main/i18n/strings_de.properties +++ b/app-desktop/src/main/i18n/strings_de.properties @@ -537,3 +537,9 @@ wizard.summary.turnedOff=Wird abgeschaltet: Zweitchat. wizard.summary.integrationsUnchanged=Logprogramm, Rotor, AirScout und DX-Cluster-Server behalten ihre gespeicherten Werte. Im Einstellungsfenster prüfen. wizard.summary.none=keine wizard.summary.passwordSet=gesetzt + +menu.setupWizard=Einrichtungsassistent... +alert.setupWizardTitle=Einrichtungsassistent +alert.setupWizardQuestion=Sitzung beenden und den Einrichtungsassistenten starten? +alert.setupWizardBody=Die ON4KST-Verbindung wird geschlossen, und alle Fenster werden nach dem Assistenten neu aufgebaut. Für einzelne Änderungen im laufenden Betrieb ist das Einstellungsfenster da. +dialog.startSetupWizard=Assistent starten diff --git a/app-desktop/src/main/i18n/strings_en.properties b/app-desktop/src/main/i18n/strings_en.properties index c81b6bf7..4b444d3f 100644 --- a/app-desktop/src/main/i18n/strings_en.properties +++ b/app-desktop/src/main/i18n/strings_en.properties @@ -546,3 +546,9 @@ wizard.summary.turnedOff=Will be switched off: second chat. wizard.summary.integrationsUnchanged=Log program, rotator, AirScout and DX cluster server keep their stored settings. Check them in the settings window. wizard.summary.none=none wizard.summary.passwordSet=set + +menu.setupWizard=Setup assistant... +alert.setupWizardTitle=Setup assistant +alert.setupWizardQuestion=End the session and start the setup assistant? +alert.setupWizardBody=The ON4KST connection is closed and all windows are rebuilt after the assistant. For single changes during operation use the settings window. +dialog.startSetupWizard=Start assistant diff --git a/app-desktop/src/main/java/kst4contest/view/ApplicationRuntimeLauncher.java b/app-desktop/src/main/java/kst4contest/view/ApplicationRuntimeLauncher.java index 60400f34..1721d779 100644 --- a/app-desktop/src/main/java/kst4contest/view/ApplicationRuntimeLauncher.java +++ b/app-desktop/src/main/java/kst4contest/view/ApplicationRuntimeLauncher.java @@ -4,6 +4,7 @@ import kst4contest.controller.ActiveOperatorProfile; import kst4contest.controller.OperatorProfilePaths; import kst4contest.controller.OperatorProfileStore; import kst4contest.model.OperatorProfile; +import kst4contest.model.OperatorProfileSelection; import java.util.logging.Level; import java.util.logging.Logger; @@ -82,6 +83,26 @@ public final class ApplicationRuntimeLauncher { return SETUP_WIZARD_REQUESTED.getAndSet(false); } + /** + * Rebuilds the runtime of the active profile with the setup wizard in front of it. + * + *

The running runtime is torn down first and the wizard shown afterwards, not the + * other way round: a runtime shutting down flushes its pending layout write, and that + * must not land on the file the wizard has just written.

+ * + * @return true if the new runtime was built + */ + public static boolean rerunSetupWizard() { + OperatorProfileSelection active = ActiveOperatorProfile.get(); + + if (active == null) { + return false; + } + + requestSetupWizard(); + return switchProfile(active.getProfile()); + } + /** * Replaces the running runtime with one bound to another operator profile. * diff --git a/app-desktop/src/main/java/kst4contest/view/ComposeMenuActions.java b/app-desktop/src/main/java/kst4contest/view/ComposeMenuActions.java index 505fc3f5..2833b2c1 100644 --- a/app-desktop/src/main/java/kst4contest/view/ComposeMenuActions.java +++ b/app-desktop/src/main/java/kst4contest/view/ComposeMenuActions.java @@ -54,6 +54,11 @@ public final class ComposeMenuActions implements MainMenuActions { application.runOnUi(application::menuActionToggleSettingsWindow); } + @Override + public void openSetupWizard() { + application.runOnUi(application::menuActionOpenSetupWizard); + } + @Override public void toggleMonitorWindow() { application.runOnUi(application::menuActionToggleMonitorWindow); diff --git a/app-desktop/src/main/java/kst4contest/view/Kst4ContestApplication.java b/app-desktop/src/main/java/kst4contest/view/Kst4ContestApplication.java index d16bd3bb..73588381 100644 --- a/app-desktop/src/main/java/kst4contest/view/Kst4ContestApplication.java +++ b/app-desktop/src/main/java/kst4contest/view/Kst4ContestApplication.java @@ -4046,6 +4046,27 @@ public class Kst4ContestApplication implements StatusUpdateListener, SettingsHos } } + /** + * Options -> setup assistant. Rebuilds the runtime of the active profile with the wizard + * in front of it, which costs the running session; hence the question, and hence the + * settings edits are settled first, as before a profile switch. + */ + void menuActionOpenSetupWizard() { + SettingsWindow.settleThen(() -> { + boolean confirmed = ComposeAlert.confirm( + kst4contest.view.i18n.CurrentStrings.get().getAlertSetupWizardTitle(), + kst4contest.view.i18n.CurrentStrings.get().getAlertSetupWizardQuestion(), + kst4contest.view.i18n.CurrentStrings.get().getAlertSetupWizardBody(), + kst4contest.view.i18n.CurrentStrings.get().getDialogStartSetupWizard(), + kst4contest.view.i18n.CurrentStrings.get().getDialogCancel(), + chatcontroller.getChatPreferences().isGUI_darkModeActive()); + + if (confirmed) { + ApplicationRuntimeLauncher.rerunSetupWizard(); + } + }); + } + /** Windows -> open or close the cluster / stranger-QSO monitor window. */ void menuActionToggleMonitorWindow() { if (MonitorWindow.isOpen()) { diff --git a/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuBar.kt b/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuBar.kt index 897ddc92..e529302d 100644 --- a/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuBar.kt +++ b/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuBar.kt @@ -55,6 +55,9 @@ interface MainMenuActions { fun setQrgAsNameInChat() fun toggleAwayState() fun toggleSettingsWindow() + + /** Ends the session after asking and runs the setup wizard for the active profile. */ + fun openSetupWizard() fun toggleMonitorWindow() fun toggleStationMap() fun useDarkDesign() diff --git a/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuModel.kt b/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuModel.kt index eb1a5cd6..f95c6904 100644 --- a/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuModel.kt +++ b/app-desktop/src/main/kotlin/kst4contest/view/compose/MainMenuModel.kt @@ -87,6 +87,11 @@ fun mainMenuModel( enabled = true, actions::toggleSettingsWindow, ), + /* + * Always usable, like the profile switch: it rebuilds the runtime and asks before + * it gives the session up. + */ + MenuEntry.Item(strings.menuSetupWizard, state.canSwitchProfile, actions::openSetupWizard), ), ), MenuSpec( diff --git a/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuModelTest.kt b/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuModelTest.kt index 6014d611..830f528f 100644 --- a/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuModelTest.kt +++ b/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuModelTest.kt @@ -28,6 +28,7 @@ class MainMenuModelTest { override fun setQrgAsNameInChat() { calls += "setQrgAsNameInChat" } override fun toggleAwayState() { calls += "toggleAwayState" } override fun toggleSettingsWindow() { calls += "toggleSettingsWindow" } + override fun openSetupWizard() { calls += "openSetupWizard" } override fun toggleMonitorWindow() { calls += "toggleMonitorWindow" } override fun toggleStationMap() { calls += "toggleStationMap" } override fun useDarkDesign() { calls += "useDarkDesign" } @@ -181,4 +182,19 @@ class MainMenuModelTest { "every item must reach an action; one of them did nothing", ) } + + @Test + fun theSetupAssistantIsReachableFromOptionsWhateverTheConnection() { + for (connectionState in On4KstConnectionState.values()) { + val actions = RecordingActions() + val model = model(connectionState = connectionState, actions = actions) + val entry = items(model.single { it.title == "Options" }).single { it.label == "Setup assistant..." } + + // Like the profile switch: it gives the session up itself, after asking. + assertTrue(entry.enabled, "the assistant must be reachable while $connectionState") + + entry.onClick() + assertEquals("openSetupWizard", actions.calls.last()) + } + } } diff --git a/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuRowScreenTest.kt b/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuRowScreenTest.kt index 7e6e08f4..c8cb1019 100644 --- a/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuRowScreenTest.kt +++ b/app-desktop/src/test/kotlin/kst4contest/view/compose/MainMenuRowScreenTest.kt @@ -55,6 +55,7 @@ class MainMenuRowScreenTest { override fun setQrgAsNameInChat() { calls += "setQrgAsNameInChat" } override fun toggleAwayState() { calls += "toggleAwayState" } override fun toggleSettingsWindow() { calls += "toggleSettingsWindow" } + override fun openSetupWizard() { calls += "openSetupWizard" } override fun toggleMonitorWindow() { calls += "toggleMonitorWindow" } override fun toggleStationMap() { calls += "toggleStationMap" } override fun useDarkDesign() { calls += "useDarkDesign" } @@ -116,6 +117,7 @@ class MainMenuRowScreenTest { Triple("Options", "Set QRG as name in Chat (main category)", "setQrgAsNameInChat"), Triple("Options", "Show me as AWAY FROM chat!", "toggleAwayState"), Triple("Options", "Show options", "toggleSettingsWindow"), + Triple("Options", "Setup assistant...", "openSetupWizard"), Triple("Windows", "Show cluster / stranger QSOs", "toggleMonitorWindow"), Triple("Windows", "Show / hide station map", "toggleStationMap"), Triple("Windows", "Use dark mode design", "useDarkDesign"),