improvement: Add Show Keyguard option to the tray icon

This commit is contained in:
Artem Chepurnyi 2024-04-23 21:03:22 +03:00
parent 8a520656cc
commit 10676243da
2 changed files with 15 additions and 4 deletions

View File

@ -2,8 +2,11 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="close">Close</string> <string name="close">Close</string>
<string name="quit">Quit</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="no">No</string> <string name="no">No</string>
<!-- On click brings Keyguard app to the front -->
<string name="show_keyguard">Show Keyguard</string>
<!-- A name of a thing, such as an account --> <!-- A name of a thing, such as an account -->
<string name="generic_name">Name</string> <string name="generic_name">Name</string>
<string name="account_name">Account name</string> <string name="account_name">Account name</string>

View File

@ -204,6 +204,12 @@ fun main() {
val isWindowOpenState = remember { val isWindowOpenState = remember {
mutableStateOf(true) mutableStateOf(true)
} }
val onWindowOpen = remember(isWindowOpenState) {
// lambda
{
isWindowOpenState.value = true
}
}
// Show a tray icon and allow the app to be collapsed into // Show a tray icon and allow the app to be collapsed into
// the tray on supported platforms. // the tray on supported platforms.
@ -222,12 +228,14 @@ fun main() {
Tray( Tray(
icon = painterResource(Res.images.ic_keyguard), icon = painterResource(Res.images.ic_keyguard),
state = trayState, state = trayState,
onAction = { onAction = onWindowOpen,
isWindowOpenState.value = true
},
menu = { menu = {
Item( Item(
stringResource(Res.strings.close), stringResource(Res.strings.show_keyguard),
onClick = onWindowOpen,
)
Item(
stringResource(Res.strings.quit),
onClick = ::exitApplication, onClick = ::exitApplication,
) )
}, },