diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index f18e6ac9..e8ee372b 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -32,6 +32,16 @@ "reset": "Reset screen corners radius" } }, + "lockscreen": { + "section": { + "label": "Lock screen", + "description": "Configure lock screen behavior." + }, + "lock-on-suspend": { + "label": "Lock on suspend", + "description": "Automatically lock the screen when suspending the system." + } + }, "fonts": { "reset-scaling": "Reset scaling", "section": { diff --git a/Assets/settings-default.json b/Assets/settings-default.json index ce680d75..27f2b735 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -65,7 +65,8 @@ "screenRadiusRatio": 1, "animationSpeed": 1, "animationDisabled": false, - "compactLockScreen": false + "compactLockScreen": false, + "lockOnSuspend": true }, "location": { "name": "Tokyo", diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 1f925537..a0306c13 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -191,6 +191,7 @@ Singleton { property real animationSpeed: 1.0 property bool animationDisabled: false property bool compactLockScreen: false + property bool lockOnSuspend: true } // location diff --git a/Modules/SessionMenu/SessionMenu.qml b/Modules/SessionMenu/SessionMenu.qml index 83afaf5f..558452b7 100644 --- a/Modules/SessionMenu/SessionMenu.qml +++ b/Modules/SessionMenu/SessionMenu.qml @@ -14,7 +14,7 @@ NPanel { id: root preferredWidth: 320 * Style.uiScaleRatio - preferredHeight: 360 * Style.uiScaleRatio + preferredHeight: 280 * Style.uiScaleRatio panelAnchorHorizontalCenter: true panelAnchorVerticalCenter: true panelKeyboardFocus: true @@ -31,10 +31,6 @@ NPanel { "action": "lock", "icon": "lock", "title": I18n.tr("session-menu.lock") - }, { - "action": "lockAndSuspend", - "icon": "lock-pause", - "title": I18n.tr("session-menu.lock-and-suspend") }, { "action": "suspend", "icon": "suspend", @@ -96,11 +92,13 @@ NPanel { lockScreen.active = true } break - case "lockAndSuspend": - CompositorService.lockAndSuspend() - break case "suspend": - CompositorService.suspend() + // Check if we should lock before suspending + if (Settings.data.general.lockOnSuspend) { + CompositorService.lockAndSuspend() + } else { + CompositorService.suspend() + } break case "reboot": CompositorService.reboot() diff --git a/Modules/Settings/Tabs/GeneralTab.qml b/Modules/Settings/Tabs/GeneralTab.qml index c4554145..0a63a7fd 100644 --- a/Modules/Settings/Tabs/GeneralTab.qml +++ b/Modules/Settings/Tabs/GeneralTab.qml @@ -189,4 +189,28 @@ ColumnLayout { Layout.topMargin: Style.marginXL Layout.bottomMargin: Style.marginXL } + + // Lock Screen + ColumnLayout { + spacing: Style.marginL + Layout.fillWidth: true + + NHeader { + label: I18n.tr("settings.general.lockscreen.section.label") + description: I18n.tr("settings.general.lockscreen.section.description") + } + + NToggle { + label: I18n.tr("settings.general.lockscreen.lock-on-suspend.label") + description: I18n.tr("settings.general.lockscreen.lock-on-suspend.description") + checked: Settings.data.general.lockOnSuspend + onToggled: Settings.data.general.lockOnSuspend = checked + } + } + + NDivider { + Layout.fillWidth: true + Layout.topMargin: Style.marginXL + Layout.bottomMargin: Style.marginXL + } }