From 740e1654e879ed1dee08f3f546f98a7125419d1b Mon Sep 17 00:00:00 2001 From: Kristen McWilliam <9575627+Merrit@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:28:04 -0400 Subject: [PATCH 1/2] feat: make hidden at startup setting more obvious and smarter Resolves #189 --- lib/settings/widgets/integration_section.dart | 26 ++++++++++++++----- lib/window/app_window.dart | 4 ++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/settings/widgets/integration_section.dart b/lib/settings/widgets/integration_section.dart index 273d80a5..b49f06ff 100644 --- a/lib/settings/widgets/integration_section.dart +++ b/lib/settings/widgets/integration_section.dart @@ -46,8 +46,12 @@ class _CloseToTrayTile extends StatelessWidget { builder: (context, state) { return Switch( value: state.closeToTray, - onChanged: (value) async { + onChanged: (bool value) async { await settingsCubit.updateCloseToTray(value); + + if (state.startHiddenInTray && !value) { + await settingsCubit.updateStartHiddenInTray(false); + } }, ); }, @@ -69,8 +73,12 @@ class _AutostartTile extends StatelessWidget { AppLocalizations.of(context)!.startAutomatically, ), value: state.autoStart, - onChanged: (_) async { + onChanged: (bool value) async { await settingsCubit.toggleAutostart(); + + if (state.startHiddenInTray && !value) { + await settingsCubit.updateStartHiddenInTray(false); + } }, ); }, @@ -85,17 +93,21 @@ class _StartHiddenTile extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - if (!state.closeToTray || !state.autoStart) { - return const SizedBox(); - } - return SwitchListTile( secondary: const Icon(Icons.auto_awesome), title: Text( AppLocalizations.of(context)!.startInTray, ), value: state.startHiddenInTray, - onChanged: (value) async { + onChanged: (bool value) async { + if (!state.closeToTray && value) { + await settingsCubit.updateCloseToTray(true); + } + + if (!state.autoStart && value) { + await settingsCubit.toggleAutostart(); + } + await settingsCubit.updateStartHiddenInTray(value); }, ); diff --git a/lib/window/app_window.dart b/lib/window/app_window.dart index bf92f2e7..aecfed64 100644 --- a/lib/window/app_window.dart +++ b/lib/window/app_window.dart @@ -16,12 +16,14 @@ class AppWindow { Future initialize() async { await windowManager.ensureInitialized(); + final bool startHiddenInTray = + await _storageRepository.getValue('startHiddenInTray') ?? false; const WindowOptions windowOptions = WindowOptions(); windowManager.waitUntilReadyToShow(windowOptions, () async { await windowManager.setPreventClose(true); await setWindowSizeAndPosition(); - await windowManager.show(); + if (!startHiddenInTray) await windowManager.show(); }); } From b01be765c8e5f1d9751970efdb898d4362441ddf Mon Sep 17 00:00:00 2001 From: Kristen McWilliam <9575627+Merrit@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:44:35 -0400 Subject: [PATCH 2/2] fix: prevent hotkey from suspending Nyrna Resolves #190 --- lib/active_window/src/active_window.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/active_window/src/active_window.dart b/lib/active_window/src/active_window.dart index babd6863..2a2a9079 100644 --- a/lib/active_window/src/active_window.dart +++ b/lib/active_window/src/active_window.dart @@ -81,6 +81,12 @@ class ActiveWindow { final window = await _nativePlatform.activeWindow(); + final String executable = window.process.executable; + if (executable == 'nyrna' || executable == 'nyrna.exe') { + log.w('Active window is Nyrna, not suspending.'); + return false; + } + log.i('Active window: $window'); if (defaultTargetPlatform == TargetPlatform.windows) {