From: Stefan Reinauer Date: Fri, 12 Jun 2026 04:31:19 +0000 (-0700) Subject: od-unix: seed Qt launcher from default.uae at startup X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=75bf1dc172c1a5813dd2dc1f2c9a6a6dccead997;p=francis%2Fwinuae.git od-unix: seed Qt launcher from default.uae at startup The shared core loads /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. --- diff --git a/README_unix.md b/README_unix.md index dbceec48..dbb3ae32 100644 --- a/README_unix.md +++ b/README_unix.md @@ -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. diff --git a/od-unix/gui.cpp b/od-unix/gui.cpp index ecffb8d1..21ffc623 100644 --- a/od-unix/gui.cpp +++ b/od-unix/gui.cpp @@ -11,9 +11,11 @@ #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) { diff --git a/od-unix/qt/launcher.cpp b/od-unix/qt/launcher.cpp index 8402ace5..d3708c88 100644 --- a/od-unix/qt/launcher.cpp +++ b/od-unix/qt/launcher.cpp @@ -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()); diff --git a/od-unix/qt/launcher.h b/od-unix/qt/launcher.h index f4b829e0..d0362fc8 100644 --- a/od-unix/qt/launcher.h +++ b/od-unix/qt/launcher.h @@ -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); diff --git a/od-unix/qt/launcher_bridge.cpp b/od-unix/qt/launcher_bridge.cpp index 9b860fbf..7a576420 100644 --- a/od-unix/qt/launcher_bridge.cpp +++ b/od-unix/qt/launcher_bridge.cpp @@ -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"); diff --git a/od-unix/qt/launcher_bridge.h b/od-unix/qt/launcher_bridge.h index 8062510e..ba6bf4d1 100644 --- a/od-unix/qt/launcher_bridge.h +++ b/od-unix/qt/launcher_bridge.h @@ -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);