Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #192

Merged
merged 2 commits into from
Oct 20, 2023
Merged

Dev #192

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/active_window/src/active_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 19 additions & 7 deletions lib/settings/widgets/integration_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
);
},
Expand All @@ -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);
}
},
);
},
Expand All @@ -85,17 +93,21 @@ class _StartHiddenTile extends StatelessWidget {
Widget build(BuildContext context) {
return BlocBuilder<SettingsCubit, SettingsState>(
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);
},
);
Expand Down
4 changes: 3 additions & 1 deletion lib/window/app_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ class AppWindow {

Future<void> 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();
});
}

Expand Down