Add headless mode to desktop
This commit is contained in:
@@ -50,12 +50,10 @@ class SystemTrayController extends _$SystemTrayController
|
||||
|
||||
Future<void> _updateTray() async {
|
||||
final t = ref.watch(translationsProvider);
|
||||
final isVisible = await windowManager.isVisible();
|
||||
final trayMenu = Menu(
|
||||
items: [
|
||||
MenuItem.checkbox(
|
||||
MenuItem(
|
||||
label: t.tray.dashboard,
|
||||
checked: isVisible,
|
||||
onClick: handleClickShowApp,
|
||||
),
|
||||
if (mode != null) ...[
|
||||
@@ -85,6 +83,11 @@ class SystemTrayController extends _$SystemTrayController
|
||||
await trayManager.setContextMenu(trayMenu);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onTrayIconMouseDown() async {
|
||||
await windowManager.show();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onTrayIconRightMouseDown() async {
|
||||
super.onTrayIconRightMouseDown();
|
||||
@@ -92,12 +95,9 @@ class SystemTrayController extends _$SystemTrayController
|
||||
}
|
||||
|
||||
Future<void> handleClickShowApp(MenuItem menuItem) async {
|
||||
if (menuItem.checked == true) {
|
||||
await windowManager.close();
|
||||
} else {
|
||||
if (await windowManager.isVisible()) return;
|
||||
await windowManager.show();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handleClickModeItem(
|
||||
TunnelMode mode,
|
||||
|
||||
@@ -11,9 +11,15 @@ class WindowManagerService with WindowListener {
|
||||
center: true,
|
||||
);
|
||||
await windowManager.waitUntilReadyToShow(windowOptions);
|
||||
await windowManager.setPreventClose(true);
|
||||
windowManager.addListener(this);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onWindowClose() async {
|
||||
await windowManager.hide();
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
windowManager.removeListener(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user