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