]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
od-unix: seed Qt launcher from default.uae at startup
authorStefan Reinauer <stefan.reinauer@coreboot.org>
Fri, 12 Jun 2026 04:31:19 +0000 (21:31 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Wed, 17 Jun 2026 19:24:40 +0000 (12:24 -0700)
The shared core loads <configurationpath>/default.uae into the prefs at
startup (main.cpp real_main), but the Qt launcher built its state from
scratch, so the default configuration had no visible effect unless the
GUI was disabled. Pass the file as the launcher's initial config path
when it exists, matching the Windows "save as default.uae" behavior.

Configs given on the command line keep precedence: the launcher's own
argument parsing decides, exposed through the bridge so gui_init does
not duplicate it. The bridge no longer infers runtime mode from "an
initial config path is present"; gui_display passes it explicitly.

README_unix.md
od-unix/gui.cpp
od-unix/qt/launcher.cpp
od-unix/qt/launcher.h
od-unix/qt/launcher_bridge.cpp
od-unix/qt/launcher_bridge.h

index dbceec482dea4981d98df6d859dff900ca3267fd..dbb3ae324ec65c10aeafcb95caeef31902d724bf 100644 (file)
@@ -331,7 +331,7 @@ When the integrated Qt UI is built, `winuae_unix` opens the configuration UI by
   -s use_gui=no
 ```
 
-The executable also tries to load `~/default.uae` by default. A missing default config is ignored silently; explicit `-config` / `-f` load failures are still reported.
+The executable also tries to load `default.uae` from the configuration path by default, and the Qt configuration UI starts with it loaded when it exists — save a configuration named `default` to set your startup defaults, like on Windows. Configs given on the command line take precedence. A missing default config is ignored silently; explicit `-config` / `-f` load failures are still reported.
 
 Unix path expansion is supported for `~/`, `$VAR`, and `${VAR}` in core config paths and Qt file/config boundaries. Relative config and media paths are resolved against the process working directory, matching the non-relative Windows save mode; the Windows-style relative-path save option is not enabled on Unix yet. The Qt Paths page saves runtime-visible target path settings such as `unix.screenshot_path`, `unix.rip_path`, `unix.video_path`, and `statefile_path`; legacy `unix.ui.*` path settings are still accepted when loading older configs. `~user` expansion is not implemented; use an absolute path for another user's home directory.
 
index ecffb8d10bde13da835a2a9e64dab460aeb8d319..21ffc6239172bbb2b0ec3d2f0895162b44790c59 100644 (file)
 #include "custom.h"
 #include "inputdevice.h"
 #include "gui.h"
+#include "target.h"
 #include "target_main.h"
 #include "savestate.h"
 #include "sounddep/sound.h"
+#include "uae.h"
 
 #ifdef WINUAE_UNIX_WITH_INTEGRATED_QT_UI
 #include "qt/launcher_bridge.h"
@@ -38,7 +40,23 @@ int target_main_handle_early(int argc, TCHAR **argv)
 int gui_init(void)
 {
 #ifdef WINUAE_UNIX_WITH_INTEGRATED_QT_UI
-    const int action = runWinUaeQtLauncherForPrefs(unix_gui_argc, unix_gui_argv, &changed_prefs, 0);
+    /* Seed the launcher from default.uae like the Windows GUI: the core
+     * already loaded it into the prefs (main.cpp real_main), but the Qt
+     * launcher builds its state from the configuration file. */
+    TCHAR default_config[MAX_DPATH];
+    fetch_configurationpath(default_config, sizeof default_config / sizeof default_config[0]);
+    _tcscat(default_config, OPTIONSFILENAME);
+    /* Command-line configs are resolved by the launcher itself and win
+     * over default.uae, like on Windows. */
+    const bool have_default = !winUaeQtLauncherArgumentsSpecifyConfig(unix_gui_argc, unix_gui_argv)
+        && access(default_config, R_OK) == 0;
+    const int action = runWinUaeQtLauncherForPrefsWithConfig(
+        unix_gui_argc,
+        unix_gui_argv,
+        &changed_prefs,
+        have_default ? default_config : nullptr,
+        0,
+        nullptr);
     if (action == WINUAE_QT_LAUNCHER_START) {
         return 1;
     }
@@ -248,6 +266,7 @@ void gui_display(int shortcut)
             unix_gui_argv,
             &changed_prefs,
             have_snapshot ? snapshot_path : nullptr,
+            1,
             &exit_code);
 
         if (have_snapshot) {
index 8402ace5f730fd77cfd28bd0aaad7220ca0f7317..d3708c883fd07245ff4f2c48eec4dced383df40d 100644 (file)
@@ -16836,6 +16836,11 @@ static void armQtSmokeExit(QDialog &dialog, QApplication *app = nullptr)
     });
 }
 
+bool winUaeQtArgumentsSpecifyConfig(const QStringList &arguments)
+{
+    return !initialConfigPathFromArguments(arguments).isEmpty();
+}
+
 WinUaeQtLauncherResult runWinUaeQtLauncherForConfig(QApplication &app)
 {
     return runWinUaeQtLauncherForConfig(app, QString());
index f4b829e01df0b66479bc9915cd0564da4f66d4cd..d0362fc8bfd03a1f5c86c091ce2ac783d20eb49e 100644 (file)
@@ -134,6 +134,7 @@ struct WinUaeQtHardwareInfoProvider {
     void (*runProWizard)(void *context) = nullptr;
 };
 
+bool winUaeQtArgumentsSpecifyConfig(const QStringList &arguments);
 WinUaeQtLauncherResult runWinUaeQtLauncherForConfig(QApplication &app);
 WinUaeQtLauncherResult runWinUaeQtLauncherForConfig(QApplication &app, const QString &initialConfigPath);
 WinUaeQtLauncherResult runWinUaeQtLauncherForConfig(QApplication &app, const QString &initialConfigPath, const WinUaeQtHardwareInfoProvider &hardwareProvider);
index 9b860fbf8561ad4e9e6ae298f718317cf3e2e914..7a5764207dd53f5e4aabd82c711ff5f2511ea2dc 100644 (file)
@@ -510,17 +510,27 @@ static WinUaeQtHardwareInfoProvider bridgeHardwareProvider(struct uae_prefs *pre
     return provider;
 }
 
+int winUaeQtLauncherArgumentsSpecifyConfig(int argc, char **argv)
+{
+    QStringList arguments;
+    arguments.reserve(argc);
+    for (int i = 0; i < argc; i++) {
+        arguments.append(QString::fromLocal8Bit(argv[i]));
+    }
+    return winUaeQtArgumentsSpecifyConfig(arguments) ? 1 : 0;
+}
+
 int runWinUaeQtLauncherForPrefs(int argc, char **argv, struct uae_prefs *prefs, int *exitCode)
 {
-    return runWinUaeQtLauncherForPrefsWithConfig(argc, argv, prefs, nullptr, exitCode);
+    return runWinUaeQtLauncherForPrefsWithConfig(argc, argv, prefs, nullptr, 0, exitCode);
 }
 
-int runWinUaeQtLauncherForPrefsWithConfig(int argc, char **argv, struct uae_prefs *prefs, const char *initialConfigPath, int *exitCode)
+int runWinUaeQtLauncherForPrefsWithConfig(int argc, char **argv, struct uae_prefs *prefs, const char *initialConfigPath, int runtimeActions, int *exitCode)
 {
     const QString initialPath = initialConfigPath && initialConfigPath[0]
         ? QString::fromLocal8Bit(initialConfigPath)
         : QString();
-    WinUaeQtLauncherResult result = runWinUaeQtLauncherForConfig(argc, argv, initialPath, bridgeHardwareProvider(prefs, !initialPath.isEmpty()));
+    WinUaeQtLauncherResult result = runWinUaeQtLauncherForConfig(argc, argv, initialPath, bridgeHardwareProvider(prefs, runtimeActions != 0));
     if (result.status == WinUaeQtLauncherStatus::StartRequested) {
         if (!applyWinUaeQtConfigToPrefs(result.config, prefs)) {
             fprintf(stderr, "Unix Qt UI failed: no preferences target available\n");
index 8062510efc11a1439631f579230a5d4f73ca652a..ba6bf4d1550a1df210c524088ce34be7b1f1a96b 100644 (file)
@@ -10,7 +10,8 @@ enum {
     WINUAE_QT_LAUNCHER_ERROR = 3
 };
 
+int winUaeQtLauncherArgumentsSpecifyConfig(int argc, char **argv);
 int runWinUaeQtLauncherForPrefs(int argc, char **argv, struct uae_prefs *prefs, int *exit_code);
-int runWinUaeQtLauncherForPrefsWithConfig(int argc, char **argv, struct uae_prefs *prefs, const char *initial_config_path, int *exit_code);
+int runWinUaeQtLauncherForPrefsWithConfig(int argc, char **argv, struct uae_prefs *prefs, const char *initial_config_path, int runtime_actions, int *exit_code);
 int runWinUaeQtRuntimeFileDialog(int argc, char **argv, int shortcut, const char *initial_path, char *selected_path, size_t selected_path_len, int *exit_code);
 int runWinUaeQtMessageBox(int argc, char **argv, int flags, const char *message, int *exit_code);