[FIX] Auth Desk (#1262)

## Description

- Don't hide but close app on exit
- Hide window option
- Fix translation of labels of context menu
This commit is contained in:
Prateek Sunal 2024-03-30 19:27:56 +05:30 committed by GitHub
commit e1ac5e7394
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 18 deletions

View file

@ -46,7 +46,6 @@ class _AppState extends State<App> with WindowListener, TrayListener {
Future<void> initWindowManager() async { Future<void> initWindowManager() async {
windowManager.addListener(this); windowManager.addListener(this);
await windowManager.setPreventClose(true);
} }
Future<void> initTrayManager() async { Future<void> initTrayManager() async {
@ -154,11 +153,6 @@ class _AppState extends State<App> with WindowListener, TrayListener {
}; };
} }
@override
void onWindowClose() async {
await windowManager.hide();
}
@override @override
void onWindowResize() { void onWindowResize() {
WindowListenerService.instance.onWindowResize().ignore(); WindowListenerService.instance.onWindowResize().ignore();
@ -187,11 +181,16 @@ class _AppState extends State<App> with WindowListener, TrayListener {
@override @override
void onTrayMenuItemClick(MenuItem menuItem) { void onTrayMenuItemClick(MenuItem menuItem) {
if (menuItem.key == 'show_window') { switch (menuItem.key) {
windowManager.show(); case 'hide_window':
} else if (menuItem.key == 'exit_app') { windowManager.hide();
windowManager.setPreventClose(false); break;
windowManager.close(); case 'show_window':
windowManager.show();
break;
case 'exit_app':
windowManager.close();
break;
} }
} }
} }

View file

@ -43,6 +43,10 @@ Future<void> initSystemTray() async {
await trayManager.setIcon(path); await trayManager.setIcon(path);
Menu menu = Menu( Menu menu = Menu(
items: [ items: [
MenuItem(
key: 'hide_window',
label: 'Hide Window',
),
MenuItem( MenuItem(
key: 'show_window', key: 'show_window',
label: 'Show Window', label: 'Show Window',

View file

@ -98,13 +98,13 @@ class _CodeWidgetState extends State<CodeWidget> {
onSelected: () => _onShowQrPressed(null), onSelected: () => _onShowQrPressed(null),
), ),
MenuItem( MenuItem(
label: 'Edit', label: l10n.edit,
icon: Icons.edit, icon: Icons.edit,
onSelected: () => _onEditPressed(null), onSelected: () => _onEditPressed(null),
), ),
const MenuDivider(), const MenuDivider(),
MenuItem( MenuItem(
label: 'Delete', label: l10n.delete,
value: "Delete", value: "Delete",
icon: Icons.delete, icon: Icons.delete,
onSelected: () => _onDeletePressed(null), onSelected: () => _onDeletePressed(null),

View file

@ -63,7 +63,7 @@ PODS:
- sqlite3/fts5 - sqlite3/fts5
- sqlite3/perf-threadsafe - sqlite3/perf-threadsafe
- sqlite3/rtree - sqlite3/rtree
- system_tray (0.0.1): - tray_manager (0.0.1):
- FlutterMacOS - FlutterMacOS
- url_launcher_macos (0.0.1): - url_launcher_macos (0.0.1):
- FlutterMacOS - FlutterMacOS
@ -91,7 +91,7 @@ DEPENDENCIES:
- sodium_libs (from `Flutter/ephemeral/.symlinks/plugins/sodium_libs/macos`) - sodium_libs (from `Flutter/ephemeral/.symlinks/plugins/sodium_libs/macos`)
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`)
- sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`) - sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`)
- system_tray (from `Flutter/ephemeral/.symlinks/plugins/system_tray/macos`) - tray_manager (from `Flutter/ephemeral/.symlinks/plugins/tray_manager/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
@ -144,8 +144,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin
sqlite3_flutter_libs: sqlite3_flutter_libs:
:path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos :path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos
system_tray: tray_manager:
:path: Flutter/ephemeral/.symlinks/plugins/system_tray/macos :path: Flutter/ephemeral/.symlinks/plugins/tray_manager/macos
url_launcher_macos: url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
window_manager: window_manager:
@ -177,7 +177,7 @@ SPEC CHECKSUMS:
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
sqlite3: 73b7fc691fdc43277614250e04d183740cb15078 sqlite3: 73b7fc691fdc43277614250e04d183740cb15078
sqlite3_flutter_libs: 06a05802529659a272beac4ee1350bfec294f386 sqlite3_flutter_libs: 06a05802529659a272beac4ee1350bfec294f386
system_tray: e53c972838c69589ff2e77d6d3abfd71332f9e5d tray_manager: 9064e219c56d75c476e46b9a21182087930baf90
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8