From 10676243daabc37ab35a069830c309073bc5437f Mon Sep 17 00:00:00 2001 From: Artem Chepurnyi Date: Tue, 23 Apr 2024 21:03:22 +0300 Subject: [PATCH] improvement: Add Show Keyguard option to the tray icon --- .../src/commonMain/resources/MR/base/strings.xml | 3 +++ .../kotlin/com/artemchep/keyguard/Main.kt | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/common/src/commonMain/resources/MR/base/strings.xml b/common/src/commonMain/resources/MR/base/strings.xml index c0949926..511a3822 100644 --- a/common/src/commonMain/resources/MR/base/strings.xml +++ b/common/src/commonMain/resources/MR/base/strings.xml @@ -2,8 +2,11 @@ OK Close + Quit Yes No + + Show Keyguard Name Account name diff --git a/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt b/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt index 35c2bc97..ded48e8a 100644 --- a/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt +++ b/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt @@ -204,6 +204,12 @@ fun main() { val isWindowOpenState = remember { mutableStateOf(true) } + val onWindowOpen = remember(isWindowOpenState) { + // lambda + { + isWindowOpenState.value = true + } + } // Show a tray icon and allow the app to be collapsed into // the tray on supported platforms. @@ -222,12 +228,14 @@ fun main() { Tray( icon = painterResource(Res.images.ic_keyguard), state = trayState, - onAction = { - isWindowOpenState.value = true - }, + onAction = onWindowOpen, menu = { Item( - stringResource(Res.strings.close), + stringResource(Res.strings.show_keyguard), + onClick = onWindowOpen, + ) + Item( + stringResource(Res.strings.quit), onClick = ::exitApplication, ) },