feat: Add "Start minimized", "Start at login" options. Use single instance of application.#39
Conversation
Add core/startup.py for Windows registry Run and macOS LaunchAgent. Adjust v5 migration: map start_with_windows only when present, drop legacy key. Tests for startup helpers, config migration, and autostart plist path.
Backend syncs OS login items and applies user toggles. ScrollPage: gate login row on supportsStartAtLogin; start minimized independent. Update backend unit tests.
QLocalServer/socket second-instance handoff shows main window. launchHidden from start_minimized and --start-hidden; tray notice when minimized. Add single-instance unit tests.
- Change start_minimized fallback from True to False so the app doesn't start hidden on first launch when the config key is missing. - Wrap apply_login_startup in try/except so registry or launchctl errors emit a status message instead of crashing.
|
Thanks for this great contribution @awkure! Really nice work on the single-instance guard, cross-platform login startup, and decoupling start minimized from start at login. I made a couple of small fixes before merging:
All tests passing. Merging now! |
5f3522a to
4b4036f
Compare
- Patch os.path.abspath in startup build_run_command tests so Windows paths resolve correctly on Linux - Use string-based patch for QLocalServer.removeServer to avoid AttributeError when PySide6 is unavailable - Patch os.path.basename/abspath in Windows exe path test for cross-platform compatibility - Fix autostart plist test to compare raw string instead of Path object
Summary
This branch improves how Mouser starts: optional tray-only launch from config, cross-platform “start at login” via
core.startup, and a Qt local-socket single-instance guard that brings the existing window forward when a second launch is attempted.Changes
core/startup.py— New module that applies login startup on Windows (HKCU Run) and macOS (LaunchAgent plist +launchctl), with helpers to build the stored command line for frozen and script runs.core/config.py— Version 5 migration now maps legacystart_with_windowsonly when that key exists, defaultsstart_at_loginotherwise, and removes the old key after migration.ui/backend.py— Replaces the previous autostart integration withcore.startup: sync on init when supported, clearstart_at_loginwhen unsupported, and callapply_login_startupwhen the user toggles the setting.ui/qml/ScrollPage.qml— Copy and layout tweaks: “start at login” row hidden when unsupported; “start minimized” is independent of login and always available; improved wrapping for the description text.main_qml.py— Readsstart_minimized(and--start-hidden) to setlaunchHidden; addsQLocalServer/QLocalSocketsingle-instance logic with activation message to show the main window; optional tray balloon when starting minimized with a system tray.tests/test_startup.pyfor the new module;tests/test_single_instance.pyfor instance helpers; updates totests/test_config.py,tests/test_backend.py, and a small path assertion fix intests/test_autostart.py.How to verify
python -m unittest tests.test_startup tests.test_config tests.test_backend tests.test_single_instance tests.test_autostart.Notes
core.autostartremains for existing macOS-specific helpers/tests; runtime login registration is handled bycore.startup.