-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add system tray functionality
- Update pubspec.yaml with tray_manager dependency. - Initialize system tray in app.dart and handle menu item clicks.
- Loading branch information
1 parent
1140d1c
commit 5e3c96b
Showing
15 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:tray_manager/tray_manager.dart'; | ||
import 'package:window_manager/window_manager.dart'; | ||
|
||
import '../../persistence_utils.dart'; | ||
|
||
class SystemTray with TrayListener { | ||
Future<void> init() async { | ||
trayManager.addListener(this); | ||
await trayManager.setIcon(trayIcon()); | ||
await trayManager.setContextMenu(Menu(items: trayMenuItems)); | ||
} | ||
|
||
// KDE@Arch Linux, this feature does not work. | ||
// @override | ||
// void onTrayIconMouseDown() { | ||
// print('onTrayIconMouseDown'); | ||
// } | ||
|
||
// KDE@Arch Linux, this feature does not work. | ||
// @override | ||
// void onTrayIconRightMouseDown() { | ||
// print('onTrayIconRightMouseDown'); | ||
// } | ||
|
||
@override | ||
void onTrayMenuItemClick(MenuItem menuItem) { | ||
switch (menuItem.key) { | ||
case 'restore_window': | ||
windowManager.isVisible().then((value) { | ||
if (value) { | ||
windowManager.hide(); | ||
} else { | ||
windowManager.show(); | ||
} | ||
}); | ||
case 'close_application': | ||
windowManager.close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters